import (
"encoding/xml"
+
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
)
type E2nodeConfigurationUpdateAcknowledgeE2APPDU struct {
E2nodeComponentID E2NodeComponentIDResp `xml:"e2nodeComponentID"`
E2nodeConfigUpdateAck E2nodeConfigUpdateAckResp
}
+
+func prepareAdditionAckList(e2nodeConfigs []entities.E2NodeComponentConfig) []AdditionListProtocolIESingleContainer {
+ additionListAckSingle := []AdditionListProtocolIESingleContainer{}
+ for _, v := range e2nodeConfigs {
+ c := convertEntitiyToModelComponent(v)
+
+ t := AdditionListProtocolIESingleContainer{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigAdditionAck_Item,
+ Value: struct {
+ Text string `xml:",chardata"`
+ E2nodeComponentConfigAdditionAckItem ComponentAckDetail `xml:"E2nodeComponentConfigAdditionAck-Item"`
+ }{
+ E2nodeComponentConfigAdditionAckItem: *c,
+ },
+ }
+ additionListAckSingle = append(additionListAckSingle, t)
+ }
+ return additionListAckSingle
+}
+
+func prepareUpdateAckList(e2nodeConfigs []entities.E2NodeComponentConfig) []UpdateProtocolIESingleContainer {
+ updateListAckSingle := []UpdateProtocolIESingleContainer{}
+ for _, v := range e2nodeConfigs {
+ c := convertEntitiyToModelComponent(v)
+
+ t := UpdateProtocolIESingleContainer{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigUpdateAck_Item,
+ Value: struct {
+ Text string `xml:",chardata"`
+ E2nodeComponentConfigUpdateAckItem ComponentAckDetail `xml:"E2nodeComponentConfigUpdateAck-Item"`
+ }{
+ E2nodeComponentConfigUpdateAckItem: *c,
+ },
+ }
+ updateListAckSingle = append(updateListAckSingle, t)
+ }
+ return updateListAckSingle
+}
+
+func prepareRemovalAckList(e2nodeConfigs []entities.E2NodeComponentConfig) []RemovalProtocolIESingleContainer {
+ removalListAckSingle := []RemovalProtocolIESingleContainer{}
+ for _, v := range e2nodeConfigs {
+ c := convertEntitiyToModelComponent(v)
+
+ t := RemovalProtocolIESingleContainer{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigRemovalAck_Item,
+ Value: struct {
+ Text string `xml:",chardata"`
+ E2nodeComponentConfigRemovalAckItem ComponentAckDetail `xml:"E2nodeComponentConfigRemovalAck-Item"`
+ }{
+ E2nodeComponentConfigRemovalAckItem: *c,
+ },
+ }
+ removalListAckSingle = append(removalListAckSingle, t)
+ }
+ return removalListAckSingle
+}
+
+func updateIDAndStatus(t *ComponentAckDetail, c entities.E2NodeComponentConfig, succss bool) {
+ switch c.E2NodeComponentInterfaceType {
+ case entities.E2NodeComponentInterfaceType_ng:
+ t.E2nodeComponentID.Value = E2NodeIFTypeNG{
+ AMFName: c.GetE2NodeComponentInterfaceTypeNG().AmfName,
+ }
+ case entities.E2NodeComponentInterfaceType_e1:
+ t.E2nodeComponentID.Value = E2NodeIFTypeE1{
+ GNBCUCPID: c.GetE2NodeComponentInterfaceTypeE1().GetGNBCuCpId(),
+ }
+ case entities.E2NodeComponentInterfaceType_s1:
+ t.E2nodeComponentID.Value = E2NodeIFTypeS1{
+ MMENAME: c.GetE2NodeComponentInterfaceTypeS1().GetMmeName(),
+ }
+ case entities.E2NodeComponentInterfaceType_f1:
+ t.E2nodeComponentID.Value = E2NodeIFTypeF1{
+ GNBDUID: c.GetE2NodeComponentInterfaceTypeF1().GetGNBDuId(),
+ }
+ case entities.E2NodeComponentInterfaceType_w1:
+ t.E2nodeComponentID.Value = E2NodeIFTypeW1{
+ NGENBDUID: c.GetE2NodeComponentInterfaceTypeW1().GetNgenbDuId(),
+ }
+ }
+
+ if succss {
+ t.E2nodeConfigUpdateAck = E2nodeConfigUpdateAckResp{
+ Value: struct {
+ XMLName xml.Name `xml:"updateOutcome"`
+ Text string `xml:",chardata"`
+ Success string `xml:"success"`
+ }{},
+ }
+ } else {
+ t.E2nodeConfigUpdateAck = E2nodeConfigUpdateAckResp{
+ Value: struct {
+ XMLName xml.Name `xml:"updateOutcome"`
+ Text string `xml:",chardata"`
+ Success string `xml:"failure"`
+ }{},
+ }
+ }
+}
+
+func updateInterfaceType(t *ComponentAckDetail, c entities.E2NodeComponentConfig) {
+ switch c.E2NodeComponentInterfaceType {
+ case entities.E2NodeComponentInterfaceType_ng:
+ t.E2nodeComponentInterfaceType = E2NodeComponentType{
+ NG: &struct{}{},
+ }
+ case entities.E2NodeComponentInterfaceType_e1:
+ t.E2nodeComponentInterfaceType = E2NodeComponentType{
+ E1: &struct{}{},
+ }
+ case entities.E2NodeComponentInterfaceType_f1:
+ t.E2nodeComponentInterfaceType = E2NodeComponentType{
+ F1: &struct{}{},
+ }
+ case entities.E2NodeComponentInterfaceType_w1:
+ t.E2nodeComponentInterfaceType = E2NodeComponentType{
+ W1: &struct{}{},
+ }
+ case entities.E2NodeComponentInterfaceType_s1:
+ t.E2nodeComponentInterfaceType = E2NodeComponentType{
+ S1: &struct{}{},
+ }
+ }
+}
+
+func convertEntitiyToModelComponent(component entities.E2NodeComponentConfig) *ComponentAckDetail {
+ componentAckDetail := &ComponentAckDetail{}
+ updateInterfaceType(componentAckDetail, component)
+ updateIDAndStatus(componentAckDetail, component, true)
+ return componentAckDetail
+}
+
+func NewE2nodeConfigurationUpdateSuccessResponseMessage(e2nodeConfigupdateMessage *E2nodeConfigurationUpdateMessage) *E2nodeConfigurationUpdateAcknowledgeE2APPDU {
+ successfulOutcome := E2nodeConfigurationUpdateAcknowledgeSuccessfulOutcome{
+ ProcedureCode: ProcedureCode_id_E2nodeConfigurationUpdate,
+ }
+
+ e2nodeConfigurationUpdateAckIEs := []E2nodeConfigurationUpdateAcknowledgeIEs{}
+ txIEs := E2nodeConfigurationUpdateAcknowledgeIEs{
+ ID: ProtocolIE_ID_id_TransactionID,
+ Value: E2nodeConfigurationUpdateAcknowledgeTransID{
+ TransactionID: e2nodeConfigupdateMessage.E2APPDU.InitiatingMessage.Value.E2nodeConfigurationUpdate.ProtocolIEs.E2nodeConfigurationUpdateIEs[0].Value.TransactionID,
+ },
+ }
+
+ e2nodeConfigurationUpdateAckIEs = append(e2nodeConfigurationUpdateAckIEs, txIEs)
+
+ items := e2nodeConfigupdateMessage.ExtractConfigAdditionList()
+ if len(items) > 0 {
+ addtionListAckIEs := E2nodeConfigurationUpdateAcknowledgeIEs{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigAdditionAck,
+ Value: E2nodeComponentConfigAdditionAckList{
+ E2nodeComponentConfigAdditionAckList: struct {
+ Text string `xml:",chardata"`
+ ProtocolIESingleContainer []AdditionListProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+ }{
+ ProtocolIESingleContainer: prepareAdditionAckList(items),
+ },
+ },
+ }
+ e2nodeConfigurationUpdateAckIEs = append(e2nodeConfigurationUpdateAckIEs, addtionListAckIEs)
+ }
+
+ items = e2nodeConfigupdateMessage.ExtractConfigUpdateList()
+ if len(items) > 0 {
+ updateListAckIEs := E2nodeConfigurationUpdateAcknowledgeIEs{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigUpdateAck,
+ Value: E2nodeComponentConfigUpdateAckList{
+ E2nodeComponentConfigUpdateAckList: struct {
+ Text string `xml:",chardata"`
+ ProtocolIESingleContainer []UpdateProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+ }{
+ ProtocolIESingleContainer: prepareUpdateAckList(items),
+ },
+ },
+ }
+ e2nodeConfigurationUpdateAckIEs = append(e2nodeConfigurationUpdateAckIEs, updateListAckIEs)
+ }
+
+ items = e2nodeConfigupdateMessage.ExtractConfigDeletionList()
+ if len(items) > 0 {
+ removalListAckIEs := E2nodeConfigurationUpdateAcknowledgeIEs{
+ ID: ProtocolIE_ID_id_E2nodeComponentConfigRemovalAck,
+ Value: E2nodeComponentConfigRemovalAckList{
+ E2nodeComponentConfigRemovalAckList: struct {
+ Text string `xml:",chardata"`
+ ProtocolIESingleContainer []RemovalProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+ }{
+ ProtocolIESingleContainer: prepareRemovalAckList(items),
+ },
+ },
+ }
+ e2nodeConfigurationUpdateAckIEs = append(e2nodeConfigurationUpdateAckIEs, removalListAckIEs)
+ }
+
+ successfulOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs = e2nodeConfigurationUpdateAckIEs
+ response := &E2nodeConfigurationUpdateAcknowledgeE2APPDU{
+ Outcome: successfulOutcome,
+ }
+ return response
+}
--- /dev/null
+//
+// Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package models_test
+
+import (
+ "e2mgr/models"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestNewE2nodeConfigurationUpdateSuccessResponseMessage(t *testing.T) {
+ configurationUpdate := getTestE2NodeConfigurationUpdateMessage(t, e2NodeConfigurationUpdateXmlPath)
+ ack := models.NewE2nodeConfigurationUpdateSuccessResponseMessage(configurationUpdate)
+ successOutcome := ack.Outcome.(models.E2nodeConfigurationUpdateAcknowledgeSuccessfulOutcome)
+
+ assert.Equal(t, models.ProcedureCode_id_E2nodeConfigurationUpdate, successOutcome.ProcedureCode)
+ assert.Equal(t, 4, len(successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs))
+
+ txIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[0]
+ assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txIE.ID)
+ assert.Equal(t, "1234", txIE.Value.(models.E2nodeConfigurationUpdateAcknowledgeTransID).TransactionID)
+
+ additionIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[1]
+ assert.Equal(t, models.ProtocolIE_ID_id_E2nodeComponentConfigAdditionAck, additionIE.ID)
+ assert.Equal(t, 5, len(additionIE.Value.(models.E2nodeComponentConfigAdditionAckList).E2nodeComponentConfigAdditionAckList.ProtocolIESingleContainer))
+
+ updateIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[2]
+ assert.Equal(t, models.ProtocolIE_ID_id_E2nodeComponentConfigUpdateAck, updateIE.ID)
+ assert.Equal(t, 5, len(updateIE.Value.(models.E2nodeComponentConfigUpdateAckList).E2nodeComponentConfigUpdateAckList.ProtocolIESingleContainer))
+
+ removalIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[3]
+ assert.Equal(t, models.ProtocolIE_ID_id_E2nodeComponentConfigRemovalAck, removalIE.ID)
+ assert.Equal(t, 5, len(removalIE.Value.(models.E2nodeComponentConfigRemovalAckList).E2nodeComponentConfigRemovalAckList.ProtocolIESingleContainer))
+}
+
+func TestNewE2nodeConfigurationUpdateSuccessResponseMessageAdditionOnly(t *testing.T) {
+ configurationUpdate := getTestE2NodeConfigurationUpdateMessage(t, e2NodeConfigurationUpdateOnlyAdditionXmlPath)
+ ack := models.NewE2nodeConfigurationUpdateSuccessResponseMessage(configurationUpdate)
+ successOutcome := ack.Outcome.(models.E2nodeConfigurationUpdateAcknowledgeSuccessfulOutcome)
+
+ assert.Equal(t, models.ProcedureCode_id_E2nodeConfigurationUpdate, successOutcome.ProcedureCode)
+ assert.Equal(t, 2, len(successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs))
+
+ txIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[0]
+ assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txIE.ID)
+ assert.Equal(t, "1234", txIE.Value.(models.E2nodeConfigurationUpdateAcknowledgeTransID).TransactionID)
+
+ additionIE := successOutcome.Value.E2nodeConfigurationUpdateAcknowledge.ProtocolIEs.E2nodeConfigurationUpdateAcknowledgeIEs[1]
+ assert.Equal(t, models.ProtocolIE_ID_id_E2nodeComponentConfigAdditionAck, additionIE.ID)
+ assert.Equal(t, 1, len(additionIE.Value.(models.E2nodeComponentConfigAdditionAckList).E2nodeComponentConfigAdditionAckList.ProtocolIESingleContainer))
+}