Skip to content

Commit

Permalink
Merge pull request #47 from omec-project/dev-configpod-logs
Browse files Browse the repository at this point in the history
Dev configpod logs
  • Loading branch information
thakurajayL authored Oct 19, 2021
2 parents f6df683 + 6902f40 commit bda1b87
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 57 deletions.
17 changes: 9 additions & 8 deletions configapi/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
package configapi

import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/omec-project/webconsole/backend/logger"
"github.com/omec-project/webconsole/configmodels"
"net/http"
)

// DeviceGroupGroupNameDelete -
func DeviceGroupGroupNameDelete(c *gin.Context) {
logger.ConfigLog.Infof("DeviceGroupGroupNameDelete")
logger.ConfigLog.Debugf("DeviceGroupGroupNameDelete")
if ret := DeviceGroupDeleteHandler(c); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand All @@ -33,7 +34,7 @@ func DeviceGroupGroupNameDelete(c *gin.Context) {

// DeviceGroupGroupNamePut -
func DeviceGroupGroupNamePut(c *gin.Context) {
logger.ConfigLog.Infof("DeviceGroupGroupNamePut")
logger.ConfigLog.Debugf("DeviceGroupGroupNamePut")
if ret := DeviceGroupPostHandler(c, configmodels.Put_op); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand All @@ -43,13 +44,13 @@ func DeviceGroupGroupNamePut(c *gin.Context) {

// DeviceGroupGroupNamePatch -
func DeviceGroupGroupNamePatch(c *gin.Context) {
logger.ConfigLog.Infof("DeviceGroupGroupNamePatch")
logger.ConfigLog.Debugf("DeviceGroupGroupNamePatch")
c.JSON(http.StatusOK, gin.H{})
}

// DeviceGroupGroupNamePost -
func DeviceGroupGroupNamePost(c *gin.Context) {
logger.ConfigLog.Infof("DeviceGroupGroupNamePost")
logger.ConfigLog.Debugf("DeviceGroupGroupNamePost")
if ret := DeviceGroupPostHandler(c, configmodels.Post_op); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand All @@ -59,7 +60,7 @@ func DeviceGroupGroupNamePost(c *gin.Context) {

// NetworkSliceSliceNameDelete -
func NetworkSliceSliceNameDelete(c *gin.Context) {
logger.ConfigLog.Infof("Received NetworkSliceSliceNameDelete ")
logger.ConfigLog.Debugf("Received NetworkSliceSliceNameDelete ")
if ret := NetworkSliceDeleteHandler(c); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand All @@ -69,7 +70,7 @@ func NetworkSliceSliceNameDelete(c *gin.Context) {

// NetworkSliceSliceNamePost -
func NetworkSliceSliceNamePost(c *gin.Context) {
logger.ConfigLog.Infof("Received NetworkSliceSliceNamePost ")
logger.ConfigLog.Debugf("Received NetworkSliceSliceNamePost ")
if ret := NetworkSlicePostHandler(c, configmodels.Post_op); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand All @@ -79,7 +80,7 @@ func NetworkSliceSliceNamePost(c *gin.Context) {

// NetworkSliceSliceNamePut -
func NetworkSliceSliceNamePut(c *gin.Context) {
logger.ConfigLog.Infof("Received NetworkSliceSliceNamePut ")
logger.ConfigLog.Debugf("Received NetworkSliceSliceNamePut ")
if ret := NetworkSlicePostHandler(c, configmodels.Put_op); ret == true {
c.JSON(http.StatusOK, gin.H{})
} else {
Expand Down
31 changes: 13 additions & 18 deletions configapi/api_slice_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func DeviceGroupDeleteHandler(c *gin.Context) bool {
var groupName string
var exists bool
if groupName, exists = c.Params.Get("group-name"); exists {
configLog.Infof("Received group %v", groupName)
configLog.Infof("Received Delete Group %v from Roc/simapp", groupName)
}
var msg configmodels.ConfigMessage
msg.MsgType = configmodels.Device_group
msg.MsgMethod = configmodels.Delete_op
msg.DevGroupName = groupName
configChannel <- &msg
configLog.Infof("Delete message for device group %v to main config thread, message %v ", groupName, msg)
configLog.Infof("Successfully Added Device Group [%v] with delete_op to config channel.", groupName)
return true

}
Expand All @@ -62,54 +62,50 @@ func DeviceGroupPostHandler(c *gin.Context, msgOp int) bool {
configLog.Infof(" err ", err)
return false
}
configLog.Infof("Printing request full after binding : %v", request)
req := http_wrapper.NewRequest(c.Request, request)

configLog.Infof("Printing request full : %+v", req)
configLog.Infof("Printing Device Group [%v] : %+v", groupName, req)
configLog.Infof("params : %v", req.Params)
configLog.Infof("Header : %v", req.Header)
configLog.Infof("Query : %v", req.Query)
configLog.Infof("Printing request body : %v", req.Body)
configLog.Infof("URL : %v ", req.URL)

procReq := req.Body.(configmodels.DeviceGroups)
configLog.Infof("Imsis.size : %v", len(procReq.Imsis))
ipdomain := procReq.IpDomainExpanded
configLog.Infof("Imsis.size : %v, Imsis: %v", len(procReq.Imsis), procReq.Imsis)

for i := 0; i < len(procReq.Imsis); i++ {
configLog.Infof("Imsis : %v", procReq.Imsis[i])
}
configLog.Infof("IP Domain Name : %v", procReq.IpDomainName)
ipdomain := procReq.IpDomainExpanded
configLog.Infof("IP Domain details %v", ipdomain)
configLog.Infof("IP Domain details : %v", ipdomain)
configLog.Infof(" dnn name : %v", ipdomain.Dnn)
configLog.Infof(" ue pool : %v", ipdomain.UeIpPool)
configLog.Infof(" dns Primary : %v", ipdomain.DnsPrimary)
configLog.Infof(" dns Secondary : %v", ipdomain.DnsSecondary)
configLog.Infof(" ip mtu : %v", ipdomain.Mtu)
configLog.Infof("Device Group Name : %v ", groupName)

var msg configmodels.ConfigMessage
msg.MsgType = configmodels.Device_group
msg.MsgMethod = msgOp
msg.DevGroup = &request
configLog.Infof("Group %v ", groupName)
msg.DevGroupName = groupName
configChannel <- &msg
configLog.Infof("Post message for device group %v to main config thread, message %v ", groupName, msg)
configLog.Infof("Successfully Added Device Group [%v] to config channel.", groupName)
return true
}

func NetworkSliceDeleteHandler(c *gin.Context) bool {
var sliceName string
var exists bool
if sliceName, exists = c.Params.Get("slice-name"); exists {
configLog.Infof("Received slice : %v", sliceName)
configLog.Infof("Received Deleted slice : %v from Roc/simapp", sliceName)
}
var msg configmodels.ConfigMessage
msg.MsgMethod = configmodels.Delete_op
msg.MsgType = configmodels.Network_slice
msg.SliceName = sliceName
configChannel <- &msg
configLog.Infof("Delete message for Slice %v to main config thread, message %v ", sliceName, msg)
configLog.Infof("Successfully Added Device Group [%v] with delete_op to config channel.", sliceName)
return true
}

Expand All @@ -131,17 +127,16 @@ func NetworkSlicePostHandler(c *gin.Context, msgOp int) bool {
configLog.Infof(" err ", err)
return false
}
configLog.Infof("Printing request full after binding : %v ", request)
//configLog.Infof("Printing request full after binding : %v ", request)

req := http_wrapper.NewRequest(c.Request, request)

configLog.Infof("Printing request full : %v", req)
configLog.Infof("Printing Slice: [%v] received from Roc/Simapp : %v", sliceName, request)
configLog.Infof("params : %v ", req.Params)
configLog.Infof("Header : %v ", req.Header)
configLog.Infof("Query : %v ", req.Query)
configLog.Infof("Printing request body : %v ", req.Body)
configLog.Infof("URL : %v ", req.URL)

procReq := req.Body.(configmodels.Slice)

slice := procReq.SliceId
Expand Down Expand Up @@ -202,6 +197,6 @@ func NetworkSlicePostHandler(c *gin.Context, msgOp int) bool {
msg.Slice = &request
msg.SliceName = sliceName
configChannel <- &msg
configLog.Infof("Post message for Slice %v to main config thread, message %v ", sliceName, msg)
configLog.Infof("Successfully Added Slice [%v] to config channel.", sliceName)
return true
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/antonfisher/nested-logrus-formatter v1.3.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/free5gc/MongoDBLibrary v1.0.0
github.com/free5gc/http2_util v1.0.0
github.com/free5gc/logger_conf v1.0.0
Expand Down
66 changes: 41 additions & 25 deletions proto/server/clientEvtHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,17 @@ func clientEventMachine(client *clientNF) {
}

case configMsg := <-client.outStandingPushConfig:
client.clientLog.Infof("Received new configuration for Client %v ", configMsg)
var lastDevGroup *configmodels.DeviceGroups
var lastSlice *configmodels.Slice

// update config snapshot
if configMsg.DevGroup != nil {
lastDevGroup = client.devgroupsConfigClient[configMsg.DevGroupName]
client.clientLog.Infof("Received new configuration for device Group %v ", configMsg.DevGroupName)
client.clientLog.Debugf("Received configuration for device Group %v ", configMsg.DevGroupName)
client.devgroupsConfigClient[configMsg.DevGroupName] = configMsg.DevGroup
} else if configMsg.DevGroupName != "" && configMsg.MsgMethod == configmodels.Delete_op {
lastDevGroup = client.devgroupsConfigClient[configMsg.DevGroupName]
client.clientLog.Infof("Received delete configuration for device Group %v ", configMsg.DevGroupName)
client.clientLog.Debugf("Received delete configuration for Device Group: %v ", configMsg.DevGroupName)
delete(client.devgroupsConfigClient, configMsg.DevGroupName)
}

Expand All @@ -479,7 +478,7 @@ func clientEventMachine(client *clientNF) {
client.slicesConfigClient[configMsg.SliceName] = configMsg.Slice
} else if configMsg.SliceName != "" && configMsg.MsgMethod == configmodels.Delete_op {
lastSlice = client.slicesConfigClient[configMsg.SliceName]
client.clientLog.Infof("Received delete configuration for slice %v ", configMsg.SliceName)
client.clientLog.Debugf("Received delete configuration for Slice: %v ", configMsg.SliceName)
delete(client.slicesConfigClient, configMsg.SliceName)
}

Expand All @@ -499,6 +498,7 @@ func clientEventMachine(client *clientNF) {
if factory.WebUIConfig.Configuration.Mode5G == false {
//push config to 4G network functions
if client.id == "hss" {
//client.clientLog.Debugf("Received configuration: %v", spew.Sdump(configMsg))
if configMsg.MsgType == configmodels.Sub_data && configMsg.MsgMethod == configmodels.Delete_op {
imsiVal := strings.ReplaceAll(configMsg.Imsi, "imsi-", "")
deleteConfigHss(client, imsiVal)
Expand Down Expand Up @@ -595,6 +595,11 @@ func clientEventMachine(client *clientNF) {
}

func postConfigMme(client *clientNF) {
if len(client.slicesConfigClient) == 0 {
client.clientLog.Infoln("Not posting config to MME since number of slices: 0")
return
}

client.clientLog.Infoln("Post configuration to MME")
config := configMme{}

Expand All @@ -610,13 +615,14 @@ func postConfigMme(client *clientNF) {
client.clientLog.Infof("plmn for mme %v", plmn)
config.PlmnList = append(config.PlmnList, plmn)
}
client.clientLog.Infoln("mme Config after filling details ", config)
client.clientLog.Infoln("Config sending to mme:")
b, err := json.Marshal(config)
if err != nil {
client.clientLog.Infoln("error in marshalling json -", err)
}

reqMsgBody := bytes.NewBuffer(b)
client.clientLog.Infoln("mme reqMsgBody -", reqMsgBody)
client.clientLog.Debugln("mme reqMsgBody -", reqMsgBody)
c := &http.Client{}
httpend := client.ConfigPushUrl
req, err := http.NewRequest(http.MethodPost, httpend, reqMsgBody)
Expand Down Expand Up @@ -670,6 +676,10 @@ func deletedImsis(prev, curr *configmodels.DeviceGroups) (imsis []string) {
return prev.Imsis
}

if prev == nil {
return
}

for _, pval1 := range prev.Imsis {

var found bool
Expand Down Expand Up @@ -727,13 +737,13 @@ func isDeviceGroupInExistingSlices(client *clientNF, name string) bool {
}

func postConfigHss(client *clientNF, lastDevGroup *configmodels.DeviceGroups, lastSlice *configmodels.Slice) {
client.clientLog.Infoln("Post configuration to Hss")
if len(client.slicesConfigClient) == 0 {
client.clientLog.Infoln("slice config not received yet, not pushing subscriber configuration to HSS.")
return
}
client.clientLog.Infoln("postConfigHss API Enter")

for sliceName, sliceConfig := range client.slicesConfigClient {
if sliceConfig == nil {
continue
}
client.clientLog.Infoln("SliceName ", sliceName)

/* handling of disable devicegroup in slice */
if lastSlice != nil && lastSlice.SliceId == sliceConfig.SliceId {
Expand Down Expand Up @@ -836,7 +846,7 @@ func postConfigHss(client *clientNF, lastDevGroup *configmodels.DeviceGroups, la
}

reqMsgBody := bytes.NewBuffer(b)
//client.clientLog.Infoln("reqMsgBody -", reqMsgBody)
client.clientLog.Debugln("reqMsgBody -", reqMsgBody)
c := &http.Client{}
httpend := client.ConfigPushUrl
req, err := http.NewRequest(http.MethodPost, httpend, reqMsgBody)
Expand Down Expand Up @@ -873,7 +883,11 @@ func parseTrafficClass(traffic string) (int32, int32) {
}

func postConfigPcrf(client *clientNF) {
client.clientLog.Infoln("Post configuration to Pcrf")
if len(client.slicesConfigClient) == 0 {
client.clientLog.Infoln("DeviceGroup config received, waiting for first slice config.")
return
}
client.clientLog.Infoln("postConfigPcrf API Enter")
config := configPcrf{}
config.Policies = &PcrfPolicies{
ServiceGroups: make(map[string]*pcrfServiceGroup),
Expand All @@ -885,17 +899,15 @@ func postConfigPcrf(client *clientNF) {
if sliceConfig == nil {
continue
}
client.clientLog.Infoln("Slice ", sliceName)
siteInfo := sliceConfig.SiteInfo
client.clientLog.Infoln("siteInfo ", siteInfo)
//siteInfo := sliceConfig.SiteInfo
//apn profile
for _, d := range sliceConfig.SiteDeviceGroup {
devGroup := client.devgroupsConfigClient[d]
if devGroup == nil {
client.clientLog.Errorln("Device Group doesn't exist: ", d)
client.clientLog.Errorf("Device Group : [%v] doesn't exist in slice [%v]: ", d, sliceName)
continue
}
client.clientLog.Infoln("PCRF devgroup ", d)
//client.clientLog.Infoln("PCRF devgroup ", d)
sgroup := &pcrfServiceGroup{}
pcrfServiceName := d + "-service"
sgroup.Def_service = append(sgroup.Def_service, pcrfServiceName)
Expand Down Expand Up @@ -928,9 +940,9 @@ func postConfigPcrf(client *clientNF) {
}
for _, app := range sliceConfig.ApplicationFilteringRules {
ruleName := d + app.RuleName
client.clientLog.Infoln("rulename ", ruleName)
client.clientLog.Infof("rulename: %v, Rules: %v", ruleName, pcrfService.Rules)
pcrfService.Rules = append(pcrfService.Rules, ruleName)
client.clientLog.Infoln("pcrf Service ", pcrfService.Rules)
//client.clientLog.Infoln("pcrf Service ", pcrfService.Rules)
config.Policies.Services[pcrfServiceName] = pcrfService
pcrfRule := &pcrfRules{}
ruledef := &pcrfRuledef{}
Expand Down Expand Up @@ -975,7 +987,6 @@ func postConfigPcrf(client *clientNF) {
ruleQInfo.ApnAmbrDl = sliceConfig.Qos.Downlink
}
arp := &arpInfo{}
arp.Priority = (arpi & 0x3c) >> 2
arp.PreEmptCap = (arpi & 0x40) >> 6
arp.PreEmpVulner = arpi & 0x1
ruleQInfo.Arp = arp
Expand Down Expand Up @@ -1005,7 +1016,7 @@ func postConfigPcrf(client *clientNF) {
}

reqMsgBody := bytes.NewBuffer(b)
client.clientLog.Infoln("PCRF reqMsgBody -", reqMsgBody)
client.clientLog.Debugln("PCRF reqMsgBody -", reqMsgBody)
c := &http.Client{}
httpend := client.ConfigPushUrl
req, err := http.NewRequest(http.MethodPost, httpend, reqMsgBody)
Expand All @@ -1022,7 +1033,11 @@ func postConfigPcrf(client *clientNF) {
}

func postConfigSpgw(client *clientNF) {
client.clientLog.Infoln("Post configuration to spgw ", client.slicesConfigClient)
if len(client.slicesConfigClient) == 0 {
client.clientLog.Infoln("DeviceGroup config received, waiting for first slice config.")
return
}
client.clientLog.Infoln("postConfigSpgw API Enter")
config := configSpgw{
ApnProfiles: make(map[string]*apnProfile),
UserPlaneProfiles: make(map[string]*userPlaneProfile),
Expand All @@ -1034,7 +1049,7 @@ func postConfigSpgw(client *clientNF) {
continue
}
siteInfo := sliceConfig.SiteInfo
client.clientLog.Infoln("siteInfo.GNodeBs ", siteInfo.GNodeBs)
client.clientLog.Infof("slice: %v, siteInfo.GNodeBs %v", sliceName, siteInfo.GNodeBs)
for _, d := range sliceConfig.SiteDeviceGroup {
devGroup := client.devgroupsConfigClient[d]
if devGroup == nil {
Expand Down Expand Up @@ -1092,8 +1107,9 @@ func postConfigSpgw(client *clientNF) {
if err != nil {
client.clientLog.Infoln("error in marshalling json -", err)
}

reqMsgBody := bytes.NewBuffer(b)
client.clientLog.Infoln("spgw reqMsgBody -", reqMsgBody)
client.clientLog.Debugln("spgw reqMsgBody -", reqMsgBody)
c := &http.Client{}
httpend := client.ConfigPushUrl
req, err := http.NewRequest(http.MethodPost, httpend, reqMsgBody)
Expand Down
Loading

0 comments on commit bda1b87

Please sign in to comment.