MML
This commit is contained in:
@@ -52,6 +52,9 @@ omc:
|
|||||||
filter: ""
|
filter: ""
|
||||||
display: "NE ID"
|
display: "NE ID"
|
||||||
comment: ""
|
comment: ""
|
||||||
|
licenseManagement:
|
||||||
|
display: "License Management"
|
||||||
|
mml:
|
||||||
- operation: "dsp"
|
- operation: "dsp"
|
||||||
object: "licenseinfo"
|
object: "licenseinfo"
|
||||||
display: "Display NE License Information"
|
display: "Display NE License Information"
|
||||||
@@ -127,11 +130,142 @@ omc:
|
|||||||
comment: ""
|
comment: ""
|
||||||
- name: "number"
|
- name: "number"
|
||||||
alias: "dep_number"
|
alias: "dep_number"
|
||||||
type: "string"
|
type: "int"
|
||||||
optional: "false"
|
optional: "false"
|
||||||
filter: ""
|
filter: ""
|
||||||
display: "Deployment number"
|
display: "Deployment number"
|
||||||
comment: ""
|
comment: ""
|
||||||
|
- operation: "rel"
|
||||||
|
object: "license"
|
||||||
|
display: "Batch Release NE License"
|
||||||
|
params:
|
||||||
|
- name: "netype"
|
||||||
|
alias: "ne_type"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE type"
|
||||||
|
comment: ""
|
||||||
|
- name: "neid"
|
||||||
|
alias: "ne_id"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE ID"
|
||||||
|
comment: ""
|
||||||
|
- name: "capcity"
|
||||||
|
alias: "capcity"
|
||||||
|
type: "int"
|
||||||
|
optional: "false"
|
||||||
|
apostr: "false"
|
||||||
|
loc: "false"
|
||||||
|
filter: ""
|
||||||
|
display: "Release number"
|
||||||
|
comment: ""
|
||||||
|
- operation: "ins"
|
||||||
|
object: "license"
|
||||||
|
display: "Install NE License"
|
||||||
|
params:
|
||||||
|
- name: "netype"
|
||||||
|
alias: "ne_type"
|
||||||
|
type: "string"
|
||||||
|
optional: "false"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE type"
|
||||||
|
comment: ""
|
||||||
|
- name: "neid"
|
||||||
|
alias: "ne_id"
|
||||||
|
type: "string"
|
||||||
|
optional: "false"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE ID"
|
||||||
|
comment: ""
|
||||||
|
- name: "capcity"
|
||||||
|
alias: "capcity"
|
||||||
|
type: "int"
|
||||||
|
optional: "false"
|
||||||
|
loc: "false"
|
||||||
|
filter: ""
|
||||||
|
display: "Install number"
|
||||||
|
comment: ""
|
||||||
|
- operation: "adj"
|
||||||
|
object: "license"
|
||||||
|
display: "Adjustment NE License"
|
||||||
|
params:
|
||||||
|
- name: "netype"
|
||||||
|
alias: "ne_type"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE type"
|
||||||
|
comment: ""
|
||||||
|
- name: "neid"
|
||||||
|
alias: "ne_id"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
loc: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE ID"
|
||||||
|
comment: ""
|
||||||
|
- name: "number"
|
||||||
|
alias: "number"
|
||||||
|
type: "int"
|
||||||
|
optional: "false"
|
||||||
|
loc: "false"
|
||||||
|
filter: ""
|
||||||
|
display: "Adjustment number"
|
||||||
|
comment: ""
|
||||||
|
- operation: "exp"
|
||||||
|
object: "license"
|
||||||
|
display: "Export NE License"
|
||||||
|
params:
|
||||||
|
- name: "netype"
|
||||||
|
alias: "ne_type"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE type"
|
||||||
|
comment: ""
|
||||||
|
- name: "neid"
|
||||||
|
alias: "ne_id"
|
||||||
|
type: "string"
|
||||||
|
optional: "true"
|
||||||
|
apostr: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE ID"
|
||||||
|
comment: ""
|
||||||
|
- operation: "uni"
|
||||||
|
object: "license"
|
||||||
|
display: "Uninstall NE License"
|
||||||
|
params:
|
||||||
|
- name: "netype"
|
||||||
|
alias: "ne_type"
|
||||||
|
type: "string"
|
||||||
|
optional: "false"
|
||||||
|
apostr: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE type"
|
||||||
|
comment: ""
|
||||||
|
- name: "neid"
|
||||||
|
alias: "ne_id"
|
||||||
|
type: "string"
|
||||||
|
optional: "false"
|
||||||
|
apostr: "true"
|
||||||
|
filter: ""
|
||||||
|
display: "NE ID"
|
||||||
|
comment: ""
|
||||||
- operation: "dsp"
|
- operation: "dsp"
|
||||||
object: "nelink"
|
object: "nelink"
|
||||||
display: "Display NE Interface Link Status"
|
display: "Display NE Interface Link Status"
|
||||||
|
|||||||
@@ -783,8 +783,8 @@
|
|||||||
"length": 12
|
"length": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "capability",
|
"name": "capcity",
|
||||||
"display": "License capability",
|
"display": "License capcity",
|
||||||
"length": 11
|
"length": 11
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -941,4 +941,35 @@
|
|||||||
"bodyFmt": "PutDB",
|
"bodyFmt": "PutDB",
|
||||||
"bodyKey": "ne_license",
|
"bodyKey": "ne_license",
|
||||||
"callFunc": "DeploymentLicense"
|
"callFunc": "DeploymentLicense"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bodyFmt": "PutDB",
|
||||||
|
"bodyKey": "ne_license",
|
||||||
|
"callFunc": "AdjustmentLicense"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bodyFmt": "PutDB",
|
||||||
|
"bodyKey": "ne_license",
|
||||||
|
"callFunc": "InstallLicense"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bodyFmt": "PutDB",
|
||||||
|
"bodyKey": "ne_license",
|
||||||
|
"cols": [
|
||||||
|
{
|
||||||
|
"name": "updated_at",
|
||||||
|
"alias": "updated_at",
|
||||||
|
"type": "string",
|
||||||
|
"length": 20,
|
||||||
|
"value": "2023-08-17 23:38:53"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bodyFmt": "PutDB",
|
||||||
|
"bodyKey": "ne_license"
|
||||||
}
|
}
|
||||||
@@ -1499,3 +1499,42 @@ func IsPermissionAllowed(token, method, dbname, tbname string) (bool, error) {
|
|||||||
|
|
||||||
return exist, nil
|
return exist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NeLicense struct {
|
||||||
|
NeType string `json:"neType" xorm:"ne_type"`
|
||||||
|
NeID string `json:"neID" xorm:"ne_id"`
|
||||||
|
Capability int `json:"capability"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func XormAdjustmentNeLicense(neType, neID string, value int) (int64, error) {
|
||||||
|
//neLicense := NeLicense{NeType: neType, NeID: neID, Capability: value}
|
||||||
|
// session.LogoutTime.Valid = true
|
||||||
|
// session.LogoutTime.Time = time.Now()
|
||||||
|
res, err := xEngine.Exec("update ne_license set capcity=capcity+? where IFNULL(ne_type, '')=? and IFNULL(ne_id, '')=?", value, neType, neID)
|
||||||
|
// defer xSession.Close()
|
||||||
|
|
||||||
|
//affected, err := xSession.Table("ne_license").Where("ne_type=? and ne_id=?", neType, neID).Update(&neLicense)
|
||||||
|
|
||||||
|
// //affected, err := xSession.Table("ne_license").SQL("ne_tye=? and ne_id=?", neType, neID).Update(session)
|
||||||
|
// err := xSession.SQL("update ne_license set capability=capability+? where ne_type=? and ne_id=?", value, neType, neID)
|
||||||
|
//xSession.Commit()
|
||||||
|
affected, err := res.RowsAffected()
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func XormUpdateNeLicense(neType, neID string, capcity int) (int64, error) {
|
||||||
|
var err error
|
||||||
|
var res sql.Result
|
||||||
|
if neType != "" && neID != "" {
|
||||||
|
res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=? and ne_id=?", capcity, neType, neID)
|
||||||
|
} else if neType != "" && neID == "" {
|
||||||
|
res, err = xEngine.Exec("update ne_license set capcity=? where ne_type=?", capcity, neType)
|
||||||
|
} else if neType == "" && neID != "" {
|
||||||
|
res, err = xEngine.Exec("update ne_license set capcity=? where ne_id=?", capcity, neID)
|
||||||
|
} else {
|
||||||
|
res, err = xEngine.Exec("update ne_license set capcity=?", capcity)
|
||||||
|
}
|
||||||
|
|
||||||
|
affected, err := res.RowsAffected()
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -330,31 +330,100 @@ func parseRequestUri(httpUri string, mmlMap *dborm.MmlHttpMap, mml *MmlCommand)
|
|||||||
return requestURI
|
return requestURI
|
||||||
}
|
}
|
||||||
|
|
||||||
// func DeploymentLicense(mml *MmlCommand, requestURI, token, agent string) {
|
func DeploymentLicense(mml *MmlCommand, omcMmlVar *MmlVar, outputJson *dborm.MmlOutput) *[]byte {
|
||||||
// client := resty.New()
|
var output []byte
|
||||||
// srcLicDep := &struct {
|
log.Debug("mml:", mml)
|
||||||
// NeType string `json:"ne_type"`
|
var srcNeType, srcNeid, dstNeType, dstNeId, value string
|
||||||
// NeID string `json:"ne_id"`
|
for _, Param := range mml.Params {
|
||||||
// Capability string `json:"capability"`
|
switch Param.Name {
|
||||||
// }{
|
case "srcnetype":
|
||||||
// NeType: fmt.Sprintf("%v", mml.NaMap["srcnetype"]),
|
srcNeType = Param.Value
|
||||||
// NeID: fmt.Sprintf("%v", mml.NaMap["srcneid"]),
|
case "srcneid":
|
||||||
// Capability: capability - strconv.Atoi(fmt.Sprintf("%v", mml.NaMap["number"])),
|
srcNeid = Param.Value
|
||||||
// }
|
case "dstnetype":
|
||||||
// response, err := client.R().
|
dstNeType = Param.Value
|
||||||
// EnableTrace().
|
case "dstneid":
|
||||||
// SetHeaders(map[string]string{"accessToken": token}).
|
dstNeId = Param.Value
|
||||||
// SetHeaders(map[string]string{"User-Agent": agent}).
|
case "number":
|
||||||
// SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
value = Param.Value
|
||||||
// SetBody(*body).
|
}
|
||||||
// Put(requestURI)
|
}
|
||||||
// if err != nil {
|
intValue, _ := strconv.Atoi(value)
|
||||||
// log.Error("Failed to Put:", err)
|
log.Debugf("srcNeType:%s, srcNeid:%s dstNeType:%s dstNeId:%s intValue:%d", srcNeType, srcNeid, dstNeType, dstNeId, intValue)
|
||||||
// output = ParseErrorOutput(err)
|
a1, err := dborm.XormAdjustmentNeLicense(srcNeType, srcNeid, intValue)
|
||||||
// } else {
|
if err != nil {
|
||||||
// output = ParseOutputResponse(omcMmlVar, outputJson, response)
|
log.Error("Failed to Put:", err)
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
a2, err := dborm.XormAdjustmentNeLicense(dstNeType, dstNeId, -intValue)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed to Put:", err)
|
||||||
|
output = *ParseErrorOutput(err)
|
||||||
|
} else {
|
||||||
|
//response := &resty.Response{StatusCode: http.StatusOK}
|
||||||
|
//output = ParseOutputResponse(omcMmlVar, outputJson, response.)
|
||||||
|
str := fmt.Sprintf("RetCode = 0 operation succeeded\n\nAffected rows = %d \n\n", a1+a2)
|
||||||
|
output = []byte(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &output
|
||||||
|
}
|
||||||
|
|
||||||
|
func AdjustmentLicense(mml *MmlCommand, omcMmlVar *MmlVar, outputJson *dborm.MmlOutput) *[]byte {
|
||||||
|
var output []byte
|
||||||
|
log.Debug("mml:", mml)
|
||||||
|
var neType, neid, number string
|
||||||
|
for _, Param := range mml.Params {
|
||||||
|
switch Param.Name {
|
||||||
|
case "netype":
|
||||||
|
neType = Param.Value
|
||||||
|
case "neid":
|
||||||
|
neid = Param.Value
|
||||||
|
case "number":
|
||||||
|
number = Param.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intValue, _ := strconv.Atoi(number)
|
||||||
|
log.Debugf("neType:%s, neid:%s intValue:%d", neType, neid, intValue)
|
||||||
|
affected, err := dborm.XormAdjustmentNeLicense(neType, neid, intValue)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed to XormAdjustmentNeLicense:", err)
|
||||||
|
output = *ParseErrorOutput(err)
|
||||||
|
} else {
|
||||||
|
str := fmt.Sprintf("RetCode = 0 operation succeeded\n\nAffected rows = %d \n\n", affected)
|
||||||
|
output = []byte(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &output
|
||||||
|
}
|
||||||
|
|
||||||
|
func InstallLicense(mml *MmlCommand, omcMmlVar *MmlVar, outputJson *dborm.MmlOutput) *[]byte {
|
||||||
|
var output []byte
|
||||||
|
log.Debug("mml:", mml)
|
||||||
|
var neType, neid, number string
|
||||||
|
for _, Param := range mml.Params {
|
||||||
|
switch Param.Name {
|
||||||
|
case "netype":
|
||||||
|
neType = Param.Value
|
||||||
|
case "neid":
|
||||||
|
neid = Param.Value
|
||||||
|
case "number":
|
||||||
|
number = Param.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intValue, _ := strconv.Atoi(number)
|
||||||
|
log.Debugf("neType:%s, neid:%s intValue:%d", neType, neid, intValue)
|
||||||
|
affected, err := dborm.XormUpdateNeLicense(neType, neid, intValue)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed to XormUpdateNeLicense:", err)
|
||||||
|
output = *ParseErrorOutput(err)
|
||||||
|
} else {
|
||||||
|
str := fmt.Sprintf("RetCode = 0 operation succeeded\n\nAffected rows = %d \n\n", affected)
|
||||||
|
output = []byte(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &output
|
||||||
|
}
|
||||||
|
|
||||||
func TransMml2HttpReq(omcMmlVar *MmlVar, mml *MmlCommand) (*[]byte, error) {
|
func TransMml2HttpReq(omcMmlVar *MmlVar, mml *MmlCommand) (*[]byte, error) {
|
||||||
log.Info("TransMml2HttpReq processing ...")
|
log.Info("TransMml2HttpReq processing ...")
|
||||||
@@ -431,18 +500,22 @@ func TransMml2HttpReq(omcMmlVar *MmlVar, mml *MmlCommand) (*[]byte, error) {
|
|||||||
output = ParseOutputResponse(omcMmlVar, outputJson, response)
|
output = ParseOutputResponse(omcMmlVar, outputJson, response)
|
||||||
}
|
}
|
||||||
case "put":
|
case "put":
|
||||||
|
switch inputJson.CallFunc {
|
||||||
|
case "DeploymentLicense":
|
||||||
|
output = DeploymentLicense(mml, omcMmlVar, outputJson)
|
||||||
|
return output, nil
|
||||||
|
case "AdjustmentLicense":
|
||||||
|
output = AdjustmentLicense(mml, omcMmlVar, outputJson)
|
||||||
|
return output, nil
|
||||||
|
case "InstallLicense":
|
||||||
|
output = InstallLicense(mml, omcMmlVar, outputJson)
|
||||||
|
return output, nil
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
requestURI = parseRequestUri(omcMmlVar.HttpUri, mmlMap, mml)
|
requestURI = parseRequestUri(omcMmlVar.HttpUri, mmlMap, mml)
|
||||||
body := ParseInputBody(inputJson, mml)
|
|
||||||
log.Debugf("method: Put requestURI: %s", requestURI)
|
log.Debugf("method: Put requestURI: %s", requestURI)
|
||||||
|
body := ParseInputBody(inputJson, mml)
|
||||||
// switch inputJson.CallFunc {
|
|
||||||
// case "DeploymentLicense":
|
|
||||||
// DeploymentLicense(inputJson, requestURI, omcMmlVar)
|
|
||||||
// //output = ParseOutputResponse(inputJson, outputJson, response)
|
|
||||||
// return output, nil
|
|
||||||
// default:
|
|
||||||
// }
|
|
||||||
|
|
||||||
response, err := client.R().
|
response, err := client.R().
|
||||||
EnableTrace().
|
EnableTrace().
|
||||||
SetHeaders(map[string]string{"accessToken": omcMmlVar.SessionToken}).
|
SetHeaders(map[string]string{"accessToken": omcMmlVar.SessionToken}).
|
||||||
|
|||||||
Reference in New Issue
Block a user