From 766ea3d78adbf38c243fee15db6bd58ffb1458ac Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Wed, 4 May 2022 12:15:16 +0000 Subject: [PATCH] Add method to extract removal list Added method to extract configuration removal item. Note: Xn and X2 interface is not supported. Signed-off-by: subhash kumar singh Change-Id: I28aee1d228d422132eef9a091f2d57270fc15246 --- E2Manager/models/constants.go | 1 + E2Manager/models/e2_node_configuration_update.go | 99 ++++++++++++++++++++++ .../models/e2_node_configuration_update_test.go | 12 +++ .../e2NodeConfigurationUpdate.xml | 6 +- 4 files changed, 115 insertions(+), 3 deletions(-) diff --git a/E2Manager/models/constants.go b/E2Manager/models/constants.go index c67b9a4..2d1d235 100644 --- a/E2Manager/models/constants.go +++ b/E2Manager/models/constants.go @@ -23,6 +23,7 @@ const ( ProtocolIE_ID_id_RANfunctionsAccepted = "9" ProtocolIE_ID_id_TransactionID = "49" ProtocolIE_ID_id_E2nodeComponentConfigAddition = "50" + ProtocolIE_ID_id_E2nodeComponentConfigRemoval = "54" ) const ( diff --git a/E2Manager/models/e2_node_configuration_update.go b/E2Manager/models/e2_node_configuration_update.go index 87c55d6..cbd8beb 100644 --- a/E2Manager/models/e2_node_configuration_update.go +++ b/E2Manager/models/e2_node_configuration_update.go @@ -410,3 +410,102 @@ func (m *E2nodeConfigurationUpdateMessage) ExtractConfigUpdateList() []entities. } return result } + +func (m *E2nodeConfigurationUpdateMessage) ExtractConfigDeletionList() []entities.E2NodeComponentConfig { + var result []entities.E2NodeComponentConfig + e2nodeConfigUpdateIEs := m.E2APPDU.InitiatingMessage.Value.E2nodeConfigurationUpdate.ProtocolIEs.E2nodeConfigurationUpdateIEs + + var deletionList *E2nodeComponentConfigRemovalList + for _, v := range e2nodeConfigUpdateIEs { + if v.ID == ProtocolIE_ID_id_E2nodeComponentConfigRemoval { + deletionList = &(v.Value.E2nodeComponentConfigRemovalList) + break + } + } + + // need not to check for empty addtionList + // as list defined as SIZE(1..maxofE2nodeComponents) + if deletionList != nil { + for _, val := range deletionList.ProtocolIESingleContainer { + componentItem := val.Value.E2nodeComponentConfigRemovalItem + + if componentItem.E2nodeComponentInterfaceType.Ng != nil { // NG Interface + result = append(result, entities.E2NodeComponentConfig{ + E2NodeComponentInterfaceType: entities.E2NodeComponentInterfaceType_ng, + E2NodeComponentID: &entities.E2NodeComponentConfig_E2NodeComponentInterfaceTypeNG{ + E2NodeComponentInterfaceTypeNG: &entities.E2NodeComponentInterfaceNG{ + AmfName: componentItem.E2nodeComponentID.E2nodeComponentInterfaceTypeNG.AmfName, + }, + }, + }) + } + + if componentItem.E2nodeComponentInterfaceType.Xn != nil { // xn inetrface + // TODO - Not Supported Yet + } + + if componentItem.E2nodeComponentInterfaceType.E1 != nil { // e1 interface + gnbCuCpId, err := strconv.ParseInt(componentItem.E2nodeComponentID.E2nodeComponentInterfaceTypeE1.GNBCUCPID, 10, 64) + if err != nil { + continue + } + + result = append(result, entities.E2NodeComponentConfig{ + E2NodeComponentInterfaceType: entities.E2NodeComponentInterfaceType_e1, + E2NodeComponentID: &entities.E2NodeComponentConfig_E2NodeComponentInterfaceTypeE1{ + E2NodeComponentInterfaceTypeE1: &entities.E2NodeComponentInterfaceE1{ + GNBCuCpId: gnbCuCpId, + }, + }, + }) + } + + if componentItem.E2nodeComponentInterfaceType.F1 != nil { // f1 interface + gnbDuId, err := strconv.ParseInt(componentItem.E2nodeComponentID.E2nodeComponentInterfaceTypeF1.GNBDUID, 10, 64) + if err != nil { + continue + } + result = append(result, entities.E2NodeComponentConfig{ + E2NodeComponentInterfaceType: entities.E2NodeComponentInterfaceType_f1, + E2NodeComponentID: &entities.E2NodeComponentConfig_E2NodeComponentInterfaceTypeF1{ + E2NodeComponentInterfaceTypeF1: &entities.E2NodeComponentInterfaceF1{ + GNBDuId: gnbDuId, + }, + }, + }) + } + + if componentItem.E2nodeComponentInterfaceType.W1 != nil { // w1 interface + ngenbDuId, err := strconv.ParseInt(componentItem.E2nodeComponentID.E2nodeComponentInterfaceTypeW1.NgENBDUID, 10, 64) + if err != nil { + continue + } + + result = append(result, entities.E2NodeComponentConfig{ + E2NodeComponentInterfaceType: entities.E2NodeComponentInterfaceType_w1, + E2NodeComponentID: &entities.E2NodeComponentConfig_E2NodeComponentInterfaceTypeW1{ + E2NodeComponentInterfaceTypeW1: &entities.E2NodeComponentInterfaceW1{ + NgenbDuId: ngenbDuId, + }, + }, + }) + } + + if componentItem.E2nodeComponentInterfaceType.S1 != nil { // s1 interface + result = append(result, entities.E2NodeComponentConfig{ + E2NodeComponentInterfaceType: entities.E2NodeComponentInterfaceType_s1, + E2NodeComponentID: &entities.E2NodeComponentConfig_E2NodeComponentInterfaceTypeS1{ + E2NodeComponentInterfaceTypeS1: &entities.E2NodeComponentInterfaceS1{ + MmeName: componentItem.E2nodeComponentID.E2nodeComponentInterfaceTypeS1.MmeName, + }, + }, + }) + } + + if componentItem.E2nodeComponentInterfaceType.X2 != nil { // x2 interface + // TODO - Not Supported Yet + } + } + } + return result +} diff --git a/E2Manager/models/e2_node_configuration_update_test.go b/E2Manager/models/e2_node_configuration_update_test.go index f1bed7d..add48c4 100644 --- a/E2Manager/models/e2_node_configuration_update_test.go +++ b/E2Manager/models/e2_node_configuration_update_test.go @@ -98,3 +98,15 @@ func TestExtractUpdateConfigList(t *testing.T) { assert.Equal(t, 0, len(updateList2), "Update List is not matching") } + +func TestExtractDeleteConfigList(t *testing.T) { + configurationRemoval1 := getTestE2NodeConfigurationUpdateMessage(t, e2NodeConfigurationUpdateXmlPath) + removalList1 := configurationRemoval1.ExtractConfigDeletionList() + + assert.Equal(t, 5, len(removalList1), "Removal List is not matching") + + configurationRemoval2 := getTestE2NodeConfigurationUpdateMessage(t, e2NodeConfigurationUpdateOnlyAdditionXmlPath) + removalList2 := configurationRemoval2.ExtractConfigDeletionList() + + assert.Equal(t, 0, len(removalList2), "Removal List is not matching") +} diff --git a/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml index 86bd1c2..2f81148 100644 --- a/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml +++ b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml @@ -330,7 +330,7 @@ - e1interf + 1234 @@ -344,7 +344,7 @@ - f1interf + 2345 @@ -358,7 +358,7 @@ - w1interf + 3456 -- 2.16.6