From 6da530720bf0f8eaee944795994353475f11b666 Mon Sep 17 00:00:00 2001 From: brianchennn Date: Thu, 25 May 2023 10:59:37 +0000 Subject: [PATCH] fix: flow rules and & add Precedence attribute --- .golangci.yml | 1 - frontend/src/metadata/index.js | 9 ++- .../pages/Subscribers/SubscriberOverview.js | 13 +++- .../Subscribers/components/SubscriberModal.js | 65 +++++++++++-------- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 23246f69..02ed57d6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,7 +29,6 @@ run: # "/" will be replaced by current OS file path separator to properly work # on Windows. skip-files: - - "api_.*\\.go$" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes diff --git a/frontend/src/metadata/index.js b/frontend/src/metadata/index.js index 55cebc99..36d18c46 100644 --- a/frontend/src/metadata/index.js +++ b/frontend/src/metadata/index.js @@ -245,11 +245,18 @@ let subModalSchema = { $ref: "#/definitions/IPFilter", title: "IP Filter" }, + precedence: { + type: "integer", + title: "Precedence", + minimum: 1, + maximum: 256, + default: 128, + }, "5qi": { type: "integer", minimum: 0, maximum: 255, - title: "5QI" + title: "5QI", }, gbrUL: { $ref: "#/definitions/bitRate", diff --git a/frontend/src/pages/Subscribers/SubscriberOverview.js b/frontend/src/pages/Subscribers/SubscriberOverview.js index 826e0904..f1cd1052 100644 --- a/frontend/src/pages/Subscribers/SubscriberOverview.js +++ b/frontend/src/pages/Subscribers/SubscriberOverview.js @@ -35,12 +35,19 @@ class SubscriberOverview extends Component { let i = 0; subscriber.QosFlows.forEach(QosFlow => { if (QosFlow.snssai === FlowRule.snssai && - QosFlow.dnn === FlowRule.dnn && - QosFlow["5qi"] === FlowRule.qfi) { + QosFlow.dnn === FlowRule.dnn && + QosFlow["5qi"] === FlowRule.qfi) + { if (origiData.QosFlows[i].flowRules === undefined) { origiData.QosFlows[i].flowRules = []; } - origiData.QosFlows[i].flowRules.push(Object.assign({ precedence: FlowRule.precedence, filter: FlowRule.filter })) + origiData.QosFlows[i].flowRules.push(Object.assign( + { + precedence: FlowRule.precedence, + filter: FlowRule.filter, + }, + FlowRule + )) } i++; }) diff --git a/frontend/src/pages/Subscribers/components/SubscriberModal.js b/frontend/src/pages/Subscribers/components/SubscriberModal.js index f74e0428..af5f85af 100644 --- a/frontend/src/pages/Subscribers/components/SubscriberModal.js +++ b/frontend/src/pages/Subscribers/components/SubscriberModal.js @@ -93,35 +93,50 @@ function smDatasFromSliceConfiguration(sliceConfiguration) { function qosFlowsFromSliceConfiguration(sliceConfigurations) { var qosFlows = []; - sliceConfigurations.forEach(slice => { - slice.dnnConfigurations.forEach(dnn => { - if (dnn.qosFlows !== undefined) { - dnn.qosFlows.forEach(qosFlow => { + sliceConfigurations.forEach(sliceConfiguration => { + sliceConfiguration.dnnConfigurations.forEach(dnnConfiguration => { + if (dnnConfiguration.flowRules !== undefined) { + dnnConfiguration.flowRules.forEach(flowRule => { qosFlows.push( - Object.assign({ snssai: snssaiToString(slice.snssai), dnn: dnn.dnn, qfi: qosFlow["5qi"] }, - qosFlow)) + Object.assign( + { + snssai: snssaiToString(sliceConfiguration.snssai), + dnn: dnnConfiguration.dnn, + qfi: flowRule["5qi"] + }, + flowRule + ) + ) }) } }) }) + return qosFlows } function flowRulesFromSliceConfiguration(sliceConfigurations) { var flowRules = [] - sliceConfigurations.forEach(slice => { - slice.dnnConfigurations.forEach(dnn => { - if (dnn.qosFlows !== undefined) { - dnn.qosFlows.forEach(qosFlow => { - if (qosFlow.flowRules !== undefined) { - qosFlow.flowRules.forEach(flowRule => { - flowRules.push(Object.assign({ snssai: snssaiToString(slice.snssai), dnn: dnn.dnn, qfi: qosFlow["5qi"] }, flowRule)) - }) - } + sliceConfigurations.forEach(sliceConfiguration => { + sliceConfiguration.dnnConfigurations.forEach(dnnConfiguration => { + if (dnnConfiguration.flowRules !== undefined){ + dnnConfiguration.flowRules.forEach(flowRule => { + flowRules.push( + Object.assign( + { + filter: flowRule.filter, + precedence: flowRule.precedence, + snssai: snssaiToString(sliceConfiguration.snssai), + dnn: dnnConfiguration.dnn, + qfi: flowRule["5qi"], + } + ) + ) }) } }) }) + return flowRules } @@ -156,10 +171,10 @@ function sliceConfigurationsFromSubscriber(subscriber) { const dnnConfigs = sessionManagementSubscriptionData.find(data => data.singleNssai.sst === sliceConf.snssai.sst && data.singleNssai.sd === sliceConf.snssai.sd).dnnConfigurations; sliceConf.dnnConfigurations = Object.keys(dnnConfigs).map(dnn => { - let qosFlows = []; + let flowRules = []; const qosFlowsData = subscriber["QosFlows"]; if (qosFlowsData && qosFlowsData.length !== 0) { - qosFlows = qosFlowsData + flowRules = qosFlowsData .filter(rule => rule.snssai === snssaiToString(sliceConf.snssai) && dnn === rule.dnn) .map(rule => { return { @@ -168,14 +183,12 @@ function sliceConfigurationsFromSubscriber(subscriber) { gbrDL: rule.gbrDL, mbrUL: rule.mbrUL, mbrDL: rule.mbrDL, - flowRules: rule.flowRules + precedence: rule.flowRules[0].precedence, + filter: rule.flowRules[0].filter } }) } - - - let staticIps = ""; const staticIpAddress = dnnConfigs[dnn].staticIpAddress if (staticIpAddress && staticIpAddress.length !== 0) { @@ -190,7 +203,7 @@ function sliceConfigurationsFromSubscriber(subscriber) { uplinkAmbr: dnnConfigs[dnn].sessionAmbr.uplink, downlinkAmbr: dnnConfigs[dnn].sessionAmbr.downlink, "5qi": dnnConfigs[dnn]["5gQosProfile"]["5qi"], - qosFlows: qosFlows, + flowRules: flowRules, // new upSecurityChk: true, upIntegrity: dnnConfigs[dnn].upSecurity.upIntegr, upConfidentiality: dnnConfigs[dnn].upSecurity.upConfid @@ -202,11 +215,11 @@ function sliceConfigurationsFromSubscriber(subscriber) { uplinkAmbr: dnnConfigs[dnn].sessionAmbr.uplink, downlinkAmbr: dnnConfigs[dnn].sessionAmbr.downlink, "5qi": dnnConfigs[dnn]["5gQosProfile"]["5qi"], - qosFlows: qosFlows + flowRules: flowRules // new }; }); }); - + return sliceConfigurations; } @@ -344,8 +357,8 @@ class SubscriberModal extends Component { "subscribedSnssaiInfos": _.fromPairs( _.map(formData["sliceConfigurations"], slice => [snssaiToString(slice.snssai), { - "dnnInfos": _.map(slice.dnnConfigurations, dnnCofig => { - return { "dnn": dnnCofig.dnn } + "dnnInfos": _.map(slice.dnnConfigurations, dnnConfig => { + return { "dnn": dnnConfig.dnn } }) }])) },