merge: 合并OMC分支
This commit is contained in:
@@ -2,24 +2,15 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"nms_cxy/lib/global"
|
||||
"nms_cxy/lib/log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"nms_cxy/lib/global"
|
||||
"nms_cxy/lib/log"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type DbConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
Backup string `yaml:"backup"`
|
||||
}
|
||||
|
||||
// Yaml struct of config
|
||||
type YamlConfig struct {
|
||||
Logger struct {
|
||||
@@ -29,16 +20,23 @@ type YamlConfig struct {
|
||||
Count int `yaml:"count"`
|
||||
} `yaml:"logger"`
|
||||
|
||||
Rest []struct {
|
||||
IPv4 string `yaml:"ipv4"`
|
||||
IPv6 string `yaml:"ipv6"`
|
||||
Port uint16 `yaml:"port"`
|
||||
Scheme string `yaml:"scheme"`
|
||||
ClientAuthType int `yaml:"clientAuthType"`
|
||||
CaFile string `yaml:"caFile"`
|
||||
CertFile string `yaml:"certFile"`
|
||||
KeyFile string `yaml:"keyFile"`
|
||||
} `yaml:"rest"`
|
||||
Pprof struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Addr string `yaml:"addr"`
|
||||
} `yaml:"pprof"`
|
||||
|
||||
// Rest []struct {
|
||||
// IPv4 string `yaml:"ipv4"`
|
||||
// IPv6 string `yaml:"ipv6"`
|
||||
// Port uint16 `yaml:"port"`
|
||||
// Scheme string `yaml:"scheme"`
|
||||
// ClientAuthType int `yaml:"clientAuthType"`
|
||||
// CaFile string `yaml:"caFile"`
|
||||
// CertFile string `yaml:"certFile"`
|
||||
// KeyFile string `yaml:"keyFile"`
|
||||
// } `yaml:"rest"`
|
||||
|
||||
Rest []RestParam
|
||||
|
||||
WebServer struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
@@ -83,39 +81,9 @@ type YamlConfig struct {
|
||||
CmdTimeout int `yaml:"cmdTimeout"`
|
||||
} `yaml:"omc"`
|
||||
|
||||
Alarm struct {
|
||||
ForwardAlarm bool `yaml:"forwardAlarm"`
|
||||
Email struct {
|
||||
Smtp string `yaml:"smtp"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
TlsSkipVerify bool `yaml:"tlsSkipVerify"`
|
||||
} `yaml:"email"`
|
||||
SMS struct {
|
||||
ApiURL string `yaml:"apiURL"`
|
||||
AccessKeyID string `yaml:"AccessKeyID"`
|
||||
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||
SignName string `yaml:"signName"`
|
||||
TemplateCode string `yaml:"templateCode"`
|
||||
} `yaml:"sms"`
|
||||
SMSC struct {
|
||||
Addr string `yaml:"addr"`
|
||||
UserName string `yaml:"userName"`
|
||||
Password string `yaml:"password"`
|
||||
} `yaml:"smsc"`
|
||||
} `yaml:"alarm"`
|
||||
Alarm AlarmConfig `yaml:"alarm"`
|
||||
|
||||
MML struct {
|
||||
Port int `yaml:"port"`
|
||||
Port2 int `yaml:"port2"`
|
||||
Sleep int64 `yaml:"sleep"`
|
||||
DeadLine int64 `yaml:"deadLine"`
|
||||
User string `yaml:"user"`
|
||||
Password string `ymal:"password"`
|
||||
MmlHome string `yaml:"mmlHome"`
|
||||
Upload string `yaml:"upload"`
|
||||
} `yaml:"mml"`
|
||||
MML MMLParam `yaml:"mml"`
|
||||
|
||||
NE struct {
|
||||
Addr string `yaml:"addr"`
|
||||
@@ -156,6 +124,67 @@ type YamlConfig struct {
|
||||
} `yaml:"testConfig"`
|
||||
}
|
||||
|
||||
type RestParam struct {
|
||||
IPv4 string `yaml:"ipv4"`
|
||||
IPv6 string `yaml:"ipv6"`
|
||||
Port uint16 `yaml:"port"`
|
||||
Scheme string `yaml:"scheme,omitempty" default:"http"`
|
||||
ClientAuthType int `yaml:"clientAuthType"`
|
||||
CaFile string `yaml:"caFile"`
|
||||
CertFile string `yaml:"certFile"`
|
||||
KeyFile string `yaml:"keyFile"`
|
||||
}
|
||||
|
||||
type DbConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
ConnParam string `yaml:"connParam,omitempty"`
|
||||
Backup string `yaml:"backup"`
|
||||
}
|
||||
|
||||
type AlarmConfig struct {
|
||||
SplitEventAlarm bool `yaml:"splitEventAlarm"`
|
||||
ForwardAlarm bool `yaml:"forwardAlarm"`
|
||||
SMProxy string `yaml:"smProxy"`
|
||||
Email struct {
|
||||
Smtp string `yaml:"smtp"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
TlsSkipVerify bool `yaml:"tlsSkipVerify"`
|
||||
} `yaml:"email"`
|
||||
SMS struct {
|
||||
ApiURL string `yaml:"apiURL"`
|
||||
AccessKeyID string `yaml:"AccessKeyID"`
|
||||
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||
SignName string `yaml:"signName"`
|
||||
TemplateCode string `yaml:"templateCode"`
|
||||
} `yaml:"sms"`
|
||||
SMSC struct {
|
||||
Addr string `yaml:"addr"`
|
||||
SystemID string `yaml:"systemID"`
|
||||
Password string `yaml:"password"`
|
||||
SystemType string `yaml:"systemType"`
|
||||
} `yaml:"smsc"`
|
||||
}
|
||||
|
||||
type MMLParam struct {
|
||||
Port int `yaml:"port"`
|
||||
Port2 int `yaml:"port2"`
|
||||
Sleep int64 `yaml:"sleep"`
|
||||
DeadLine int64 `yaml:"deadLine"`
|
||||
SizeRow int16 `yaml:"sizeRow"`
|
||||
SizeCol int16 `yaml:"sizeCol"`
|
||||
BufferSize int `yaml:"bufferSize"`
|
||||
User string `yaml:"user"`
|
||||
Password string `ymal:"password"`
|
||||
MmlHome string `yaml:"mmlHome"`
|
||||
}
|
||||
|
||||
type TestDatas struct {
|
||||
UDM struct {
|
||||
CapUsed uint32 `yaml:"capUsed"`
|
||||
@@ -187,7 +216,25 @@ type TestDataMap struct {
|
||||
NeTestDatas []map[string]NeTestData
|
||||
}
|
||||
|
||||
var yamlConfig YamlConfig
|
||||
var yamlConfig YamlConfig = NewYamlConfig()
|
||||
|
||||
// set default value for yaml config
|
||||
func NewYamlConfig() YamlConfig {
|
||||
return YamlConfig{
|
||||
Database: DbConfig{
|
||||
Type: "mysql",
|
||||
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True",
|
||||
},
|
||||
MML: MMLParam{
|
||||
SizeRow: 200,
|
||||
SizeCol: 120,
|
||||
BufferSize: 65535,
|
||||
},
|
||||
Alarm: AlarmConfig{
|
||||
SplitEventAlarm: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ReadConfig(configFile string) {
|
||||
yamlFile, err := os.ReadFile(configFile)
|
||||
@@ -323,10 +370,27 @@ func ReadTestConfigYaml(pfile string) (ret error) {
|
||||
}
|
||||
|
||||
func GetDefaultUserAgent() string {
|
||||
return "OMC/" + global.Version
|
||||
return "OMC-restagent/" + global.Version
|
||||
}
|
||||
|
||||
// const defaultConfigFile = "./etc/omc.yaml"
|
||||
func GetOMCHostUrl() string {
|
||||
var omcip string = "127.0.0.1"
|
||||
var rest RestParam = yamlConfig.Rest[0]
|
||||
var port uint16 = rest.Port
|
||||
if rest.IPv4 != "0.0.0.0" && rest.IPv4 != "" {
|
||||
omcip = rest.IPv4
|
||||
} else if rest.IPv6 != "::" && rest.IPv6 != "" {
|
||||
omcip = "[" + rest.IPv6 + "]"
|
||||
}
|
||||
var scheme string = "http"
|
||||
if rest.Scheme != "" {
|
||||
scheme = rest.Scheme
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s://%s:%d", scheme, omcip, port)
|
||||
}
|
||||
|
||||
// const defaultConfigFile = "./etc/restconf.yaml"
|
||||
|
||||
// func init() {
|
||||
// cfile := flag.String("c", defaultConfigFile, "config file")
|
||||
@@ -337,7 +401,7 @@ func GetDefaultUserAgent() string {
|
||||
// //global.GoVer = "go version go1.15.7 linux/arm64"
|
||||
// flag.Parse()
|
||||
// if *pv {
|
||||
// fmt.Printf("OMC version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
|
||||
// fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
|
||||
// os.Exit(0)
|
||||
// }
|
||||
// if *ph {
|
||||
|
||||
@@ -2,30 +2,35 @@
|
||||
# level: /trace/debug/info/warn/error/fatal, default: debug
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
# pprof: false(default)/true to disable/enable pprof
|
||||
logger:
|
||||
file: d:/local.git/nms_cxy/omc/log/omc.log
|
||||
file: ./etc/omc/log/omc.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 2
|
||||
|
||||
pprof:
|
||||
enabled: true
|
||||
addr: :36060
|
||||
|
||||
# rest agent listen ipv4/v6 and port, support multiple routines
|
||||
# ip: 0.0.0.0 or ::0, support IPv4/v6
|
||||
# clientAuthType: 0:NoClientCert (default), 1:RequestClientCert, 2:RequireAnyClientCert,
|
||||
# clientAuthType: 0:NoClientCert (default), 1:RequestClientCert, 2:RequireAnyClientCert,
|
||||
# 3:VerifyClientCertIfGiven, 4:RequireAndVerifyClientCerts
|
||||
rest:
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
ipv6:
|
||||
port: 33040
|
||||
|
||||
webServer:
|
||||
enabled: false
|
||||
rootDir: d:/local.git/fe.ems.vue3/dist
|
||||
listen:
|
||||
rootDir: ./etc/omc/dist
|
||||
listen:
|
||||
- addr: :80
|
||||
schema: http
|
||||
- addr: :443
|
||||
scheme: https
|
||||
clientAuthType: 0
|
||||
clientAuthType: 0
|
||||
caFile: ./etc/certs/omc-ca.crt
|
||||
certFile: ./etc/certs/omc-server.crt
|
||||
keyFile: ./etc/certs/omc-server.key
|
||||
@@ -34,10 +39,11 @@ database:
|
||||
type: mysql
|
||||
user: root
|
||||
password: "root@1234"
|
||||
host: "192.168.5.59"
|
||||
host: "192.168.8.58"
|
||||
port: 3306
|
||||
name: omc_db_nms_cxy
|
||||
backup: d:/local.git/be.ems/omc/database
|
||||
name: "omc_db_nms_cxy"
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: ./etc/omc/database
|
||||
|
||||
# Redis 缓存数据,数据源声明全小写
|
||||
redis:
|
||||
@@ -45,42 +51,44 @@ redis:
|
||||
# OMC系统使用库
|
||||
default:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.5.59" # Redis host
|
||||
host: "192.168.8.58" # Redis host
|
||||
password: "redis@1234"
|
||||
db: 10 # Redis db_num
|
||||
# UDM网元用户库
|
||||
udmuser:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.13.140"
|
||||
password: ""
|
||||
port: 36379 # Redis port
|
||||
host: "192.168.8.58"
|
||||
password: "helloearth"
|
||||
db: 0 # Redis db_num
|
||||
# 多个数据源时可以用这个指定默认的数据源
|
||||
defaultDataSourceName: "default"
|
||||
|
||||
# sleep: time delay for after write buffer (millisecond)
|
||||
# deadLine: timeout for io read and write (second)
|
||||
# deadLine: timeout for io read and write (second)
|
||||
mml:
|
||||
port: 4100
|
||||
port2: 5002
|
||||
sleep: 200
|
||||
deadLine: 10
|
||||
sizeRow: 600
|
||||
sizeCol: 128
|
||||
bufferSize: 65535
|
||||
user: admin
|
||||
password: admin
|
||||
mmlHome: ./mmlhome
|
||||
upload: /home/agtuser
|
||||
|
||||
# NE config
|
||||
ne:
|
||||
user: agtuser
|
||||
user: omcuser
|
||||
etcdir: /usr/local/etc
|
||||
bindir: /usr/local/bin
|
||||
omcdir: /usr/local/omc
|
||||
scpdir: /tmp
|
||||
licensedir: /usr/local/etc/{neType}/license
|
||||
# backup etc list of IMS,no space
|
||||
etcListIMS: "{*.yaml,mmtel,vars.cfg}"
|
||||
etcListDefault: "{*.yaml,*.conf,*.cfg}"
|
||||
# true/false to overwrite config file when dpkg ne software
|
||||
# backup etc list of IMS,no space
|
||||
etcListIMS: '{*.yaml,mmtel,vars.cfg}'
|
||||
etcListDefault: '{*.yaml,*.conf,*.cfg}'
|
||||
# true/false to overwrite config file when dpkg ne software
|
||||
dpkgOverwrite: false
|
||||
# dpkg timeout (second)
|
||||
dpkgTimeout: 180
|
||||
@@ -100,24 +108,25 @@ omc:
|
||||
checksign: false
|
||||
rootDir: ./
|
||||
binDir: ./bin
|
||||
backup: ./backup
|
||||
upload: ./upload
|
||||
frontUpload: d:/local.git/fe.ems/upload
|
||||
frontTraceDir: d:/local.git/fe.ems/trace
|
||||
software: ./software
|
||||
license: ./license
|
||||
backup: ./etc/omc/backup
|
||||
upload: ./etc/omc/upload
|
||||
frontUpload: ./etc/omc/upload
|
||||
frontTraceDir: ./etc/omc/trace
|
||||
software: ./etc/omc/software
|
||||
license: ./etc/omc/license
|
||||
gtpUri: gtp:192.168.2.219:2152
|
||||
checkContentType: false
|
||||
testMode: false
|
||||
rbacMode: true
|
||||
runDir:
|
||||
runDir:
|
||||
cmdTimeout: 120
|
||||
|
||||
# Alarm module setting
|
||||
# Forward interface:
|
||||
# email/sms
|
||||
# smProxy: sms(Short Message Service)/smsc(SMS Centre)
|
||||
alarm:
|
||||
forwardAlarm: true
|
||||
forwardAlarm: false
|
||||
email:
|
||||
smtp: mail.agrandtech.com
|
||||
port: 25
|
||||
@@ -125,17 +134,19 @@ alarm:
|
||||
password: "1000smtp@omc!"
|
||||
# TLS skip verify: true/false
|
||||
tlsSkipVerify: true
|
||||
smProxy: smsc
|
||||
sms:
|
||||
apiURL: http://smsc.xxx.com.cn/
|
||||
apiURL: http://smsc.xxx.com/
|
||||
accessKeyID: xxxx
|
||||
accessKeySecret: xxxx
|
||||
signName: xxx SMSC
|
||||
templateCode: 1000
|
||||
smsc:
|
||||
addr: "192.168.14.211:2775"
|
||||
userName: OMC
|
||||
password: "123456"
|
||||
|
||||
addr: "192.168.13.114:2775"
|
||||
systemID: "omc"
|
||||
password: "omc123"
|
||||
systemType: "UTRAN"
|
||||
|
||||
#User authorized information
|
||||
# crypt: mysql/md5/bcrypt
|
||||
# token: true/false to check accessToken
|
||||
@@ -150,7 +161,7 @@ auth:
|
||||
publicKey: ./etc/certs/omc_pub.key
|
||||
privateKey: ./etc/certs/omc_pri.key
|
||||
|
||||
# Parameter for limit number
|
||||
# Parameter for limit number
|
||||
# rmuid_maxnum: the max number of rmUID, default: 50
|
||||
# alarmid_maxnum: the max number of AlarmID, default: 50
|
||||
# pmid_maxnum: the max number of pmID, default: 50
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
# file: log file name
|
||||
# level: /trace/debug/info/warn/error/fatal, default: debug
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
logger:
|
||||
file: d:/local.git/nms_cxy/omc/log/omc-t.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 2
|
||||
|
||||
# rest agent listen ipv4/v6 and port, support multiple routines
|
||||
# ip: 0.0.0.0 or ::0, support IPv4/v6
|
||||
rest:
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
port: 33030
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
port: 36060
|
||||
|
||||
database:
|
||||
type: mysql
|
||||
user: root
|
||||
password: 1000omc@kp!
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
backup: d:/local.git/nms_cxy/omc/database
|
||||
|
||||
# Redis 缓存数据,数据源声明全小写
|
||||
redis:
|
||||
dataSource:
|
||||
# OMC系统使用库
|
||||
default:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.2.166" # Redis host
|
||||
password: ""
|
||||
db: 10 # Redis db_num
|
||||
# UDM网元用户库
|
||||
udmuser:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.2.166"
|
||||
password: ""
|
||||
db: 0 # Redis db_num
|
||||
# 多个数据源时可以用这个指定默认的数据源
|
||||
defaultDataSourceName: "default"
|
||||
|
||||
mml:
|
||||
port: 4100
|
||||
sleep: 200
|
||||
user: admin
|
||||
password: admin
|
||||
mmlHome: ./mmlhome
|
||||
|
||||
ne:
|
||||
user: root
|
||||
etcdir: /usr/local/etc
|
||||
bindir: /usr/local/bin
|
||||
omcdir: /usr/local/omc
|
||||
scpdir: /tmp
|
||||
licensedir: /usr/local/etc/{neType}/license
|
||||
|
||||
# chk2ne: true/false, if put OmcNeConfig parameters to NE
|
||||
omc:
|
||||
uriPrefix: "/omc/rest"
|
||||
neType: OMC
|
||||
neId: 001
|
||||
rmUID: 4400HX101
|
||||
neName: OMC
|
||||
province: GD
|
||||
vendor: ""
|
||||
dn: 4600
|
||||
chk2ne: false
|
||||
sn: 13750650
|
||||
checksign: false
|
||||
backup: ./backup
|
||||
upload: ./upload
|
||||
frontUpload: d:/local.git/fe.ems/upload
|
||||
frontTraceDir: d:/local.git/fe.ems/trace
|
||||
software: ./software
|
||||
license: ./license
|
||||
gtpUri: gtp:192.168.2.119:2152
|
||||
checkContentType: false
|
||||
testMode: false
|
||||
rbacMode: true
|
||||
runDir:
|
||||
|
||||
# Alarm module setting
|
||||
# Forward interface:
|
||||
# email/sms
|
||||
alarm:
|
||||
forwardAlarm: true
|
||||
email:
|
||||
smtp: smtp@xxx.com.cn
|
||||
port: 25
|
||||
user: smtpuser
|
||||
password: smtpuser@omc
|
||||
sms:
|
||||
apiURL: http://smsc.xxx.com.cn/
|
||||
accessKeyID: xxxx
|
||||
accessKeySecret: xxxx
|
||||
signName: xxx SMSC
|
||||
templateCode: 1000
|
||||
|
||||
#User authorized information
|
||||
# crypt: mysql/md5/bcrypt
|
||||
# token: true/false to check accessToken
|
||||
# expires for session, unit: second
|
||||
# Support single/multiple session of user
|
||||
auth:
|
||||
crypt: bcrypt
|
||||
token: true
|
||||
expires: 1800
|
||||
session: multiple
|
||||
publicKey: ./etc/certs/omc_pub.key
|
||||
privateKey: ./etc/certs/omc_pri.key
|
||||
|
||||
# Parameter for limit number
|
||||
# rmuid_maxnum: the max number of rmUID, default: 50
|
||||
# alarmid_maxnum: the max number of AlarmID, default: 50
|
||||
# pmid_maxnum: the max number of pmID, default: 50
|
||||
# subid_maxnum: the max number of subscription ID, default: 20
|
||||
# uri_maxlen: the max length of uri, default: 8192
|
||||
# rmuid_regexp: regexp pattern of rmUID
|
||||
params:
|
||||
rmuidmaxnum: 50
|
||||
alarmidmaxnum: 50
|
||||
pmidmaxnum: 50
|
||||
subidmaxnum: 20
|
||||
urimaxlen: 2100000
|
||||
rmuidregexp: "[0-9]{4}[A-Z]{2}[A-Z]{2}[0-9A-Z]{1}[0-9A-Z]{3}[0-9A-Z]{1,16}"
|
||||
testConfig:
|
||||
enabled: true
|
||||
file: ./etc/testconfig.yaml
|
||||
@@ -1,18 +1,18 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2403.3
|
||||
VERSION = 2.2407.1
|
||||
LIBDIR = nms_cxy/lib
|
||||
BINNAME = omc
|
||||
|
||||
.PHONY: build $(BINNAME)
|
||||
build $(BINNAME):
|
||||
go build -o $(BINNAME) -v -ldflags "-X '$(LIBDIR)/global.Version=$(VERSION)' \
|
||||
go build -o $(BINNAME) -v -ldflags "-s -w -X '$(LIBDIR)/global.Version=$(VERSION)' \
|
||||
-X '$(LIBDIR)/global.BuildTime=`date`' \
|
||||
-X '$(LIBDIR)/global.GoVer=`go version`'"
|
||||
|
||||
run: $(BINNAME)
|
||||
./$(BINNAME)
|
||||
run: $(BINNAME)
|
||||
./$(BINNAME)
|
||||
|
||||
clean:
|
||||
rm ./$(BINNAME)
|
||||
|
||||
34
omc/omc.go
34
omc/omc.go
@@ -9,10 +9,13 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
_ "net/http/pprof"
|
||||
|
||||
"nms_cxy/features/dbrest"
|
||||
"nms_cxy/features/event"
|
||||
"nms_cxy/features/fm"
|
||||
"nms_cxy/features/lm"
|
||||
"nms_cxy/features/mml"
|
||||
"nms_cxy/features/pm"
|
||||
"nms_cxy/lib/dborm"
|
||||
"nms_cxy/lib/global"
|
||||
@@ -21,7 +24,6 @@ import (
|
||||
"nms_cxy/omc/config"
|
||||
"nms_cxy/src"
|
||||
"nms_cxy/src/framework/middleware"
|
||||
libSession "nms_cxy/src/lib_features/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/net/http2"
|
||||
@@ -138,61 +140,69 @@ func HttpListenWebServer(addr string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// src 配置中心初始加载
|
||||
src.ConfigurationInit()
|
||||
app := src.AppEngine()
|
||||
|
||||
conf := config.GetYamlConfig()
|
||||
|
||||
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc", config.GetLogLevel())
|
||||
fmt.Printf("OMC version: %s\n", global.Version)
|
||||
if conf.Pprof.Enabled {
|
||||
// 启用pprof HTTP服务
|
||||
go func() {
|
||||
fmt.Println(http.ListenAndServe(conf.Pprof.Addr, nil))
|
||||
}()
|
||||
}
|
||||
|
||||
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:", config.GetLogLevel())
|
||||
fmt.Printf("OMC restagent version: %s\n", global.Version)
|
||||
log.Infof("========================= OMC startup =========================")
|
||||
log.Infof("OMC version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||
log.Infof("OMC restagent version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||
|
||||
err := dborm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = fm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = pm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = dbrest.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dbrest.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = lm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("lm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
|
||||
mml.InitMML()
|
||||
|
||||
// 将 mux.Router 注册到 gin.Engine
|
||||
|
||||
// 默认路由组
|
||||
defaultUriGroup := app.Group(config.DefaultUriPrefix)
|
||||
defaultUriGroup.Use(middleware.PreAuthorize(nil))
|
||||
defaultUriGroup.Use(libSession.SessionHeader())
|
||||
defaultUriGroup.Any("/*any", gin.WrapH(routes.NewRouter()))
|
||||
// 可配置前缀路由组
|
||||
uriGroup := app.Group(config.UriPrefix)
|
||||
uriGroup.Use(libSession.SessionHeader())
|
||||
uriGroup.Any("/*any", gin.WrapH(routes.NewRouter()))
|
||||
// AMF上报的UE事件, 无前缀,暂时特殊处理
|
||||
app.POST(event.UriUEEvent, event.PostUEEventFromAMF)
|
||||
app.POST(event.UriUEEventAMF, event.PostUEEventFromAMF)
|
||||
|
||||
for _, rest := range conf.Rest {
|
||||
// ipv4 goroutines
|
||||
|
||||
Reference in New Issue
Block a user