Compare commits
5 Commits
85f7e3e4d8
...
0adc47628f
| Author | SHA1 | Date | |
|---|---|---|---|
| 0adc47628f | |||
| 18701c7c41 | |||
| 9e5b4c1bf1 | |||
| 587e7a65f0 | |||
| 7be1132430 |
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@@ -18,7 +18,7 @@
|
|||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "d:/local.git/be.ems/restagent/",
|
"program": "d:/omc.git/be.ems/restagent/",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "d:/local.git/be.ems/sshsvc/sshsvc.go",
|
"program": "d:/omc.git/be.ems/sshsvc/sshsvc.go",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "d:/local.git/be.ems/crontask",
|
"program": "d:/omc.git/be.ems/crontask",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "d:/local.git/be.ems/tools/encode",
|
"program": "d:/omc.git/be.ems/tools/encode",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 版本发布日志
|
# 版本发布日志
|
||||||
|
|
||||||
## 2.2410.2-20241018
|
## 2.2410.3-20241018
|
||||||
|
|
||||||
- 新增 网元主机支持redis配置项
|
- 新增 网元主机支持redis配置项
|
||||||
- 新增 菜单功能iperf3/ping网络测试工具
|
- 新增 菜单功能iperf3/ping网络测试工具
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
||||||
# duration: saved days, default is 30 days
|
# duration: saved days, default is 30 days
|
||||||
logger:
|
logger:
|
||||||
file: d:/local.git/be.ems/captrace/log/captrace.log
|
file: d:/omc.git/be.ems/captrace/log/captrace.log
|
||||||
level: trace
|
level: trace
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 10
|
count: 10
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for rest agent project
|
# Makefile for rest agent project
|
||||||
|
|
||||||
PROJECT = OMC
|
PROJECT = OMC
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
PLATFORM = amd64
|
PLATFORM = amd64
|
||||||
ARMPLATFORM = aarch64
|
ARMPLATFORM = aarch64
|
||||||
BUILDDIR = ../../build
|
BUILDDIR = ../../build
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
||||||
# duration: saved days, default is 30 days
|
# duration: saved days, default is 30 days
|
||||||
logger:
|
logger:
|
||||||
file: d:/local.git/be.ems/crontask/log/crontask.log
|
file: d:/omc.git/be.ems/crontask/log/crontask.log
|
||||||
level: trace
|
level: trace
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 10
|
count: 10
|
||||||
@@ -26,7 +26,7 @@ database:
|
|||||||
port: 33066
|
port: 33066
|
||||||
name: omc_db
|
name: omc_db
|
||||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||||
backup: d:/local.git/be.ems/restagent/database
|
backup: d:/omc.git/be.ems/restagent/database
|
||||||
|
|
||||||
# northbound interface, cm/pm
|
# northbound interface, cm/pm
|
||||||
# duration(day): saved days
|
# duration(day): saved days
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for OMC-OMC-crontask project
|
# Makefile for OMC-OMC-crontask project
|
||||||
|
|
||||||
PROJECT = OMC
|
PROJECT = OMC
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
LIBDIR = be.ems/lib
|
LIBDIR = be.ems/lib
|
||||||
BINNAME = crontask
|
BINNAME = crontask
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for rest agent project
|
# Makefile for rest agent project
|
||||||
|
|
||||||
PROJECT = OMC
|
PROJECT = OMC
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
RelDate = `date +%Y%m%d`
|
RelDate = `date +%Y%m%d`
|
||||||
Release = $(RelDate)
|
Release = $(RelDate)
|
||||||
RelVer = $(VERSION)-$(RelDate)
|
RelVer = $(VERSION)-$(RelDate)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package features
|
|||||||
import (
|
import (
|
||||||
"be.ems/features/cm"
|
"be.ems/features/cm"
|
||||||
"be.ems/features/lm"
|
"be.ems/features/lm"
|
||||||
|
"be.ems/features/nbi"
|
||||||
"be.ems/features/pm"
|
"be.ems/features/pm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,10 +13,10 @@ func InitServiceEngine(r *gin.Engine) {
|
|||||||
log.Info("======init feature group gin.Engine")
|
log.Info("======init feature group gin.Engine")
|
||||||
|
|
||||||
// featuresGroup := r.Group("/")
|
// featuresGroup := r.Group("/")
|
||||||
// 注册 各个features 模块的路由
|
// register features routers
|
||||||
pm.InitSubServiceRoute(r)
|
pm.InitSubServiceRoute(r)
|
||||||
lm.InitSubServiceRoute(r)
|
lm.InitSubServiceRoute(r)
|
||||||
cm.InitSubServiceRoute(r)
|
cm.InitSubServiceRoute(r)
|
||||||
|
nbi.InitSubServiceRoute(r)
|
||||||
// return featuresGroup
|
// return featuresGroup
|
||||||
}
|
}
|
||||||
|
|||||||
257
features/nbi/file/controller.go
Normal file
257
features/nbi/file/controller.go
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
package nbi_file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/zip"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/dborm"
|
||||||
|
"be.ems/lib/file"
|
||||||
|
"be.ems/lib/global"
|
||||||
|
"be.ems/lib/log"
|
||||||
|
"be.ems/lib/services"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SysJobResponse struct {
|
||||||
|
SysJob
|
||||||
|
TableName string `json:"tableName"`
|
||||||
|
TableDisplay string `json:"tableDisplay"`
|
||||||
|
FilePath string `json:"filePath"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TargetParams struct {
|
||||||
|
Duration int `json:"duration"`
|
||||||
|
TableName string `json:"tableName"`
|
||||||
|
Columns string `json:"columns"` // exported column name of time string
|
||||||
|
TimeCol string `json:"timeCol"` // time stamp of column name
|
||||||
|
TimeUnit string `json:"timeUnit"` // timestamp unit: second/micro/milli
|
||||||
|
Extras string `json:"extras"` // extras condition for where
|
||||||
|
FilePath string `json:"filePath"` // file path
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *FileNBI) GetFileList(c *gin.Context) {
|
||||||
|
var querys FileNBIQuery
|
||||||
|
|
||||||
|
querys.Category = c.Param("category")
|
||||||
|
querys.Type = c.Param("type")
|
||||||
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if querys.Path == "" {
|
||||||
|
tableName := ""
|
||||||
|
ok := false
|
||||||
|
switch querys.Category {
|
||||||
|
case "cdr":
|
||||||
|
tableName, ok = CDRTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "log":
|
||||||
|
tableName, ok = LogTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s := SysJob{}
|
||||||
|
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||||
|
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||||
|
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||||
|
Where(where).
|
||||||
|
Get(&querys.Path)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
files, err := file.GetFileInfo(querys.Path, querys.Suffix)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("failed to GetFileInfo:", err)
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// split files list
|
||||||
|
lenNum := int64(len(files))
|
||||||
|
start := (querys.PageNum - 1) * querys.PageSize
|
||||||
|
end := start + querys.PageSize
|
||||||
|
var splitList []file.FileInfo
|
||||||
|
if start >= lenNum {
|
||||||
|
splitList = []file.FileInfo{}
|
||||||
|
} else if end >= lenNum {
|
||||||
|
splitList = files[start:]
|
||||||
|
} else {
|
||||||
|
splitList = files[start:end]
|
||||||
|
}
|
||||||
|
total := len(files)
|
||||||
|
c.JSON(http.StatusOK, services.TotalDataResp(splitList, total))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *FileNBI) Total(c *gin.Context) {
|
||||||
|
dir := c.Query("path")
|
||||||
|
|
||||||
|
fileCount, dirCount, err := file.GetFileAndDirCount(dir)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("failed to GetFileAndDirCount:", err)
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total := fileCount + dirCount
|
||||||
|
c.JSON(http.StatusOK, services.TotalResp(int64(total)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *FileNBI) GetSingleFileHandler(c *gin.Context) {
|
||||||
|
var querys FileNBIQuery
|
||||||
|
|
||||||
|
querys.Category = c.Param("category")
|
||||||
|
querys.Type = c.Param("type")
|
||||||
|
querys.DateIndex = c.Param("dateIndex")
|
||||||
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tableName := ""
|
||||||
|
if querys.Path == "" {
|
||||||
|
ok := false
|
||||||
|
switch querys.Category {
|
||||||
|
case "cdr":
|
||||||
|
tableName, ok = CDRTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "log":
|
||||||
|
tableName, ok = LogTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s := SysJob{}
|
||||||
|
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||||
|
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||||
|
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||||
|
Where(where).
|
||||||
|
Get(&querys.Path)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName := tableName + "_export_" + querys.DateIndex + "0000" + ".csv"
|
||||||
|
filePath := filepath.Join(querys.Path, fileName)
|
||||||
|
|
||||||
|
file, err := os.Open(filePath)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Header("Content-Disposition", "attachment; filename="+fileName)
|
||||||
|
c.Header("Content-Type", "application/octet-stream")
|
||||||
|
c.File(filePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *FileNBI) GetMultiFileHandler(c *gin.Context) {
|
||||||
|
var querys FileNBIQuery
|
||||||
|
|
||||||
|
querys.Category = c.Param("category")
|
||||||
|
querys.Type = c.Param("type")
|
||||||
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tableName := ""
|
||||||
|
if querys.Path == "" {
|
||||||
|
ok := false
|
||||||
|
switch querys.Category {
|
||||||
|
case "cdr":
|
||||||
|
tableName, ok = CDRTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "log":
|
||||||
|
tableName, ok = LogTableMapper[querys.Type]
|
||||||
|
if tableName == "" || !ok {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s := SysJob{}
|
||||||
|
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||||
|
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||||
|
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||||
|
Where(where).
|
||||||
|
Get(&querys.Path)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zipWriter := zip.NewWriter(c.Writer)
|
||||||
|
defer zipWriter.Close()
|
||||||
|
|
||||||
|
for _, fileName := range querys.FileNames {
|
||||||
|
filePath := filepath.Join(querys.Path, fileName)
|
||||||
|
|
||||||
|
file, err := os.Open(filePath)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writer, err := zipWriter.Create(filepath.Base(fileName))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.Copy(writer, file); err != nil {
|
||||||
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
zipFile := tableName + "_export_" + time.Now().Local().Format(global.DateData) + ".zip"
|
||||||
|
c.Header("Content-Disposition", "attachment; filename="+zipFile)
|
||||||
|
c.Header("Content-Type", "application/zip")
|
||||||
|
//c.File(filePath)
|
||||||
|
}
|
||||||
47
features/nbi/file/model.go
Normal file
47
features/nbi/file/model.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package nbi_file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"be.ems/lib/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
INVOKE_FILE_EXPORT = "exportTable"
|
||||||
|
)
|
||||||
|
|
||||||
|
var CDRTableMapper map[string]string = map[string]string{
|
||||||
|
"ims": "cdr_event_ims",
|
||||||
|
"smf": "cdr_event_smf",
|
||||||
|
"smsc": "cdr_event_smsc",
|
||||||
|
"sms": "cdr_event_smsc",
|
||||||
|
}
|
||||||
|
|
||||||
|
var LogTableMapper map[string]string = map[string]string{
|
||||||
|
"operate": "sys_log_operate",
|
||||||
|
"security": "sys_log_login",
|
||||||
|
"alarm": "alarm_log",
|
||||||
|
}
|
||||||
|
|
||||||
|
type SysJob struct {
|
||||||
|
JobID int64 `gorm:"column:job_id;primary_key;auto_increment" json:"job_id"` //任务ID
|
||||||
|
InvokeTarget string `gorm:"column:invoke_target" json:"invoke_target"` //调用目标字符串
|
||||||
|
TargetParams string `gorm:"column:target_params;type:json" json:"target_params,omitempty"` //调用目标传入参数
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysJob) TableName() string {
|
||||||
|
return "sys_job"
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileNBI struct {
|
||||||
|
file.FileInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileNBIQuery struct {
|
||||||
|
Category string `form:"category" binding:"required"`
|
||||||
|
Type string `form:"type" binding:"required"`
|
||||||
|
DateIndex string `form:"dateIndex"`
|
||||||
|
Path string `json:"path" form:"path"`
|
||||||
|
FileNames []string `json:"fileName" form:"fileName"`
|
||||||
|
Suffix string `form:"suffix"`
|
||||||
|
PageNum int64 `form:"pageNum"`
|
||||||
|
PageSize int64 `form:"pageSize"`
|
||||||
|
}
|
||||||
26
features/nbi/file/route.go
Normal file
26
features/nbi/file/route.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package nbi_file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"be.ems/src/framework/middleware"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Register Routes for file_export
|
||||||
|
func Register(r *gin.RouterGroup) {
|
||||||
|
fileNBI := r.Group("/file")
|
||||||
|
{
|
||||||
|
var f *FileNBI
|
||||||
|
fileNBI.GET("/:category/:type/list",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
f.GetFileList,
|
||||||
|
)
|
||||||
|
fileNBI.GET("/:category/:type/:dateIndex",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
f.GetSingleFileHandler,
|
||||||
|
)
|
||||||
|
fileNBI.GET("/:category/:type",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
f.GetMultiFileHandler,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/lib/session"
|
|
||||||
"be.ems/restagent/config"
|
"be.ems/restagent/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ type ApiResponse struct {
|
|||||||
ResultMessage interface{}
|
ResultMessage interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalSession = session.NewSessManager("restagent")
|
//var globalSession = session.NewSessManager("restagent")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
MAX_RMUID_NUM int
|
MAX_RMUID_NUM int
|
||||||
|
|||||||
16
features/nbi/service.go
Normal file
16
features/nbi/service.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// log management package
|
||||||
|
|
||||||
|
package nbi
|
||||||
|
|
||||||
|
import (
|
||||||
|
nbi_file "be.ems/features/nbi/file"
|
||||||
|
"be.ems/lib/log"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitSubServiceRoute(r *gin.Engine) {
|
||||||
|
log.Info("======init North-Bound Interface group gin.Engine")
|
||||||
|
|
||||||
|
nbiGroup := r.Group("/nbi")
|
||||||
|
nbi_file.Register(nbiGroup)
|
||||||
|
}
|
||||||
@@ -54,28 +54,28 @@ func GetNRMByUri(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// error processing ...
|
// error processing ...
|
||||||
// 401-1 response
|
// 401-1 response
|
||||||
token, ret := globalSession.IsCarriedToken(r)
|
// token, ret := globalSession.IsCarriedToken(r)
|
||||||
if ret == false {
|
// if ret == false {
|
||||||
log.Error("AccessToken is not carried")
|
// log.Error("AccessToken is not carried")
|
||||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
// services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 401-2 response
|
// 401-2 response
|
||||||
if globalSession.IsValidToken(token) == false {
|
// if globalSession.IsValidToken(token) == false {
|
||||||
log.Error("AccessToken fails or does not exist")
|
// log.Error("AccessToken fails or does not exist")
|
||||||
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
// services.ResponseUnauthorized401AccessTokenNotExist(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
// response 403 Forbidden, permissions deny
|
// response 403 Forbidden, permissions deny
|
||||||
// todo...
|
// todo...
|
||||||
plist := globalSession.GetPermissionFromSession(token)
|
// plist := globalSession.GetPermissionFromSession(token)
|
||||||
log.Debug("permission list:", plist)
|
// log.Debug("permission list:", plist)
|
||||||
if len(plist) == 0 || plist[0] == false {
|
// if len(plist) == 0 || plist[0] == false {
|
||||||
log.Error("User permission deny")
|
// log.Error("User permission deny")
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
qeuryUri := vars["apiCategory"] + "/" + vars["elementTypeValue"] + "/" + vars["objectTypeValue"]
|
qeuryUri := vars["apiCategory"] + "/" + vars["elementTypeValue"] + "/" + vars["objectTypeValue"]
|
||||||
|
|||||||
@@ -9,14 +9,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type FileInfo struct {
|
type FileInfo struct {
|
||||||
FileType string `json:"fileType"` // 文件类型
|
FileType string `json:"fileType"` // file type: file/directory
|
||||||
FileMode string `json:"fileMode"` // 文件的权限
|
FileMode string `json:"fileMode"` // file mode
|
||||||
LinkCount int64 `json:"linkCount"` // 硬链接数目
|
LinkCount int64 `json:"linkCount"` // link count
|
||||||
Owner string `json:"owner"` // 所属用户
|
Owner string `json:"owner"` // owner
|
||||||
Group string `json:"group"` // 所属组
|
Group string `json:"group"` // group
|
||||||
Size int64 `json:"size"` // 文件的大小
|
Size int64 `json:"size"` // size: xx byte
|
||||||
ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒
|
ModifiedTime int64 `json:"modifiedTime"` // last modified time:seconds
|
||||||
FileName string `json:"fileName"` // 文件的名称
|
FilePath string `json:"filePath"` // file path
|
||||||
|
FileName string `json:"fileName"` // file name
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
||||||
@@ -48,6 +49,7 @@ func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
|||||||
Group: "-",
|
Group: "-",
|
||||||
Size: info.Size(),
|
Size: info.Size(),
|
||||||
ModifiedTime: info.ModTime().Unix(),
|
ModifiedTime: info.ModTime().Unix(),
|
||||||
|
FilePath: dir,
|
||||||
FileName: info.Name(),
|
FileName: info.Name(),
|
||||||
}
|
}
|
||||||
files = append(files, fileInfo)
|
files = append(files, fileInfo)
|
||||||
|
|||||||
4
makefile
4
makefile
@@ -3,13 +3,13 @@
|
|||||||
ProjectL = omc
|
ProjectL = omc
|
||||||
ProjectU = OMC
|
ProjectU = OMC
|
||||||
PROJECT = $(ProjectL)
|
PROJECT = $(ProjectL)
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
RelDate = `date +%Y%m%d`
|
RelDate = `date +%Y%m%d`
|
||||||
Release = $(RelDate)
|
Release = $(RelDate)
|
||||||
RelVer = $(VERSION)-$(RelDate)
|
RelVer = $(VERSION)-$(RelDate)
|
||||||
PLATFORM = amd64
|
PLATFORM = amd64
|
||||||
ARMPLATFORM = aarch64
|
ARMPLATFORM = aarch64
|
||||||
GitLocalRoot = $(HOME)/local.git
|
GitLocalRoot = $(HOME)/omc.git
|
||||||
EmsBuildRoot=$(GitLocalRoot)/build.ems
|
EmsBuildRoot=$(GitLocalRoot)/build.ems
|
||||||
BuildDir = $(EmsBuildRoot)/build
|
BuildDir = $(EmsBuildRoot)/build
|
||||||
BuildOMCDir = $(BuildDir)/usr/local/omc
|
BuildOMCDir = $(BuildDir)/usr/local/omc
|
||||||
|
|||||||
62
misc/upgconf.sh
Normal file
62
misc/upgconf.sh
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
config_file="/usr/local/omc/etc/restconf.yaml"
|
||||||
|
temp_file="/tmp/temp.yaml"
|
||||||
|
|
||||||
|
declare -A insert_lines=(
|
||||||
|
[156]=" dataCoding: 0"
|
||||||
|
[157]=" serviceNumber: \"OMC\""
|
||||||
|
)
|
||||||
|
|
||||||
|
declare -A update_lines=(
|
||||||
|
["deadLine: 10"]="deadLine: 600"
|
||||||
|
)
|
||||||
|
|
||||||
|
# check if exist file
|
||||||
|
if [[ ! -f $config_file ]]; then
|
||||||
|
echo "NOT FOUND config file: $config_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
insert_if_missing() {
|
||||||
|
local line_number="$1"
|
||||||
|
local line_content="$2"
|
||||||
|
local current_content=$(sed -n "${line_number}p" "$config_file")
|
||||||
|
|
||||||
|
if [[ "$current_content" != "$line_content" ]]; then
|
||||||
|
# insert line to config file
|
||||||
|
echo -n "Inserting '$line_content' into line ${line_number} ... "
|
||||||
|
awk -v n="$line_number" -v line="$line_content" 'NR==n {print line} {print}' "$config_file" >"$temp_file" && mv "$temp_file" "$config_file"
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
echo "done"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Exist '$line_content' at line ${line_number}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# function:update line content
|
||||||
|
update_lines_content() {
|
||||||
|
local old_line="$1"
|
||||||
|
local new_line="$2"
|
||||||
|
echo -n "Updating '$old_line' to line '$new_line' ..."
|
||||||
|
sed -i "s/$old_line/$new_line/" "$config_file"
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
echo "done"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#line_numbers=(156 157)
|
||||||
|
line_numbers=$(for key in "${!insert_lines[@]}"; do echo "$key"; done | sort -n)
|
||||||
|
|
||||||
|
# insert process
|
||||||
|
#for line_number in "${line_numbers[@]}"; do
|
||||||
|
#for line_number in "${!insert_lines[@]}"; do
|
||||||
|
for line_number in $line_numbers; do
|
||||||
|
insert_if_missing "$line_number" "${insert_lines[$line_number]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# update process
|
||||||
|
for old_line in "${!update_lines[@]}"; do
|
||||||
|
update_lines_content "$old_line" "${update_lines[$old_line]}"
|
||||||
|
done
|
||||||
4
mkpkg.sh
4
mkpkg.sh
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ProcList="restagent crontask sshsvc captrace data2html"
|
ProcList="restagent crontask sshsvc captrace data2html"
|
||||||
ProjectL=omc
|
ProjectL=omc
|
||||||
VERSION=2.2410.2
|
VERSION=2.2410.3
|
||||||
RelDate=`date +%Y%m%d`
|
RelDate=`date +%Y%m%d`
|
||||||
Release=${RelDate}
|
Release=${RelDate}
|
||||||
RelVer=${VERSION}-${RelDate}
|
RelVer=${VERSION}-${RelDate}
|
||||||
@@ -10,7 +10,7 @@ Ky10Arch=ky10.aarch64
|
|||||||
RpmPkgName=${ProjectL}-${RelVer}.ky10.aarch64.rpm
|
RpmPkgName=${ProjectL}-${RelVer}.ky10.aarch64.rpm
|
||||||
RpmPkgRename=${ProjectL}-r${RelVer}-ky10.rpm
|
RpmPkgRename=${ProjectL}-r${RelVer}-ky10.rpm
|
||||||
DebPkgName=${ProjectL}-r${RelVer}-ub*.deb
|
DebPkgName=${ProjectL}-r${RelVer}-ub*.deb
|
||||||
GitLocalRoot=${HOME}/local.git
|
GitLocalRoot=${HOME}/omc.git
|
||||||
EmsBEDir=${GitLocalRoot}/be.ems
|
EmsBEDir=${GitLocalRoot}/be.ems
|
||||||
EmsBuildRoot=${GitLocalRoot}/build.ems
|
EmsBuildRoot=${GitLocalRoot}/build.ems
|
||||||
RpmArch=`arch`
|
RpmArch=`arch`
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||||
# count: rotation count of log, default is 30 rotation
|
# count: rotation count of log, default is 30 rotation
|
||||||
logger:
|
logger:
|
||||||
file: d:/local.git/be.ems/restagent/log/restagent.log
|
file: d:/omc.git/be.ems/restagent/log/restagent.log
|
||||||
level: trace
|
level: trace
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 2
|
count: 2
|
||||||
@@ -27,7 +27,7 @@ rest:
|
|||||||
|
|
||||||
webServer:
|
webServer:
|
||||||
enabled: false
|
enabled: false
|
||||||
rootDir: d:/local.git/fe.ems.vue3/dist
|
rootDir: d:/omc.git/fe.ems.vue3/dist
|
||||||
listen:
|
listen:
|
||||||
- addr: :80
|
- addr: :80
|
||||||
schema: http
|
schema: http
|
||||||
@@ -46,7 +46,7 @@ database:
|
|||||||
port: 33066
|
port: 33066
|
||||||
name: omc_db
|
name: omc_db
|
||||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||||
backup: d:/local.git/be.ems/restagent/database
|
backup: d:/omc.git/be.ems/restagent/database
|
||||||
|
|
||||||
# Redis 缓存数据,数据源声明全小写
|
# Redis 缓存数据,数据源声明全小写
|
||||||
redis:
|
redis:
|
||||||
@@ -113,8 +113,8 @@ omc:
|
|||||||
binDir: ./bin
|
binDir: ./bin
|
||||||
backup: ./backup
|
backup: ./backup
|
||||||
upload: ./upload
|
upload: ./upload
|
||||||
frontUpload: d:/local.git/fe.ems/upload
|
frontUpload: d:/omc.git/fe.ems/upload
|
||||||
frontTraceDir: d:/local.git/fe.ems/trace
|
frontTraceDir: d:/omc.git/fe.ems/trace
|
||||||
software: ./software
|
software: ./software
|
||||||
license: ./license
|
license: ./license
|
||||||
gtpUri: gtp:192.168.2.219:2152
|
gtpUri: gtp:192.168.2.219:2152
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# count: rotation count of log, default is 30 rotation
|
# count: rotation count of log, default is 30 rotation
|
||||||
# pprof: false(default)/true to disable/enable pprof
|
# pprof: false(default)/true to disable/enable pprof
|
||||||
logger:
|
logger:
|
||||||
file: d:/local.git/be.ems/restagent/log/restagent.log
|
file: d:/omc.git/be.ems/restagent/log/restagent.log
|
||||||
level: trace
|
level: trace
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 2
|
count: 2
|
||||||
@@ -24,7 +24,7 @@ rest:
|
|||||||
|
|
||||||
webServer:
|
webServer:
|
||||||
enabled: true
|
enabled: true
|
||||||
rootDir: d:/local.git/fe.ems.vue3/dist
|
rootDir: d:/omc.git/fe.ems.vue3/dist
|
||||||
listen:
|
listen:
|
||||||
- addr: :80
|
- addr: :80
|
||||||
schema: http
|
schema: http
|
||||||
@@ -43,7 +43,7 @@ database:
|
|||||||
port: 33066
|
port: 33066
|
||||||
name: "omc_db"
|
name: "omc_db"
|
||||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||||
backup: d:/local.git/be.ems/restagent/database
|
backup: d:/omc.git/be.ems/restagent/database
|
||||||
|
|
||||||
# Redis data cache
|
# Redis data cache
|
||||||
redis:
|
redis:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for rest agent project
|
# Makefile for rest agent project
|
||||||
|
|
||||||
PROJECT = OMC
|
PROJECT = OMC
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
PLATFORM = amd64
|
PLATFORM = amd64
|
||||||
ARMPLATFORM = aarch64
|
ARMPLATFORM = aarch64
|
||||||
BUILDDIR = ../../build
|
BUILDDIR = ../../build
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# 项目信息
|
# 项目信息
|
||||||
framework:
|
framework:
|
||||||
name: "OMC"
|
name: "OMC"
|
||||||
version: "2.2410.2"
|
version: "2.2410.3"
|
||||||
|
|
||||||
# 应用服务配置
|
# 应用服务配置
|
||||||
server:
|
server:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||||
# count: rotation count of log, default is 30 rotation
|
# count: rotation count of log, default is 30 rotation
|
||||||
logger:
|
logger:
|
||||||
file: d:/local.git/be.ems/sshsvc/log/sshsvc.log
|
file: d:/omc.git/be.ems/sshsvc/log/sshsvc.log
|
||||||
level: trace
|
level: trace
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 30
|
count: 30
|
||||||
@@ -13,7 +13,7 @@ logger:
|
|||||||
# count: rotation count of log, default is 30 rotation
|
# count: rotation count of log, default is 30 rotation
|
||||||
# level: cmd/ret log cmd/log cmd & result
|
# level: cmd/ret log cmd/log cmd & result
|
||||||
logmml:
|
logmml:
|
||||||
file: d:/local.git/be.ems/sshsvc/mmllog/omcmml.log
|
file: d:/omc.git/be.ems/sshsvc/mmllog/omcmml.log
|
||||||
duration: 24
|
duration: 24
|
||||||
count: 30
|
count: 30
|
||||||
level: ret
|
level: ret
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Makefile for OMC-OMC-crontask project
|
# Makefile for OMC-OMC-crontask project
|
||||||
|
|
||||||
PROJECT = OMC
|
PROJECT = OMC
|
||||||
VERSION = 2.2410.2
|
VERSION = 2.2410.3
|
||||||
LIBDIR = be.ems/lib
|
LIBDIR = be.ems/lib
|
||||||
BINNAME = sshsvc
|
BINNAME = sshsvc
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
Home=/home/simon
|
Home=/home/simon
|
||||||
GitLocalRoot=${Home}/local.git
|
GitLocalRoot=${Home}/omc.git
|
||||||
EmsBEDir=${GitLocalRoot}/be.ems
|
EmsBEDir=${GitLocalRoot}/be.ems
|
||||||
user="root"
|
user="root"
|
||||||
password="1000omc@kp!"
|
password="1000omc@kp!"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
Home=/home/simon
|
Home=/home/simon
|
||||||
GitLocalRoot=${Home}/local.git
|
GitLocalRoot=${Home}/omc.git
|
||||||
EmsBEDir=${GitLocalRoot}/be.ems
|
EmsBEDir=${GitLocalRoot}/be.ems
|
||||||
EMSBuildDir=${GitLocalRoot}/build.ems
|
EMSBuildDir=${GitLocalRoot}/build.ems
|
||||||
user="root"
|
user="root"
|
||||||
|
|||||||
Reference in New Issue
Block a user