From: subhash kumar singh Date: Fri, 6 May 2022 20:32:50 +0000 (+0000) Subject: Support Transaction ID in ServiceUpdateAck X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F8185%2F1;p=ric-plt%2Fe2mgr.git Support Transaction ID in ServiceUpdateAck Support transaction ID in ServiceUpdateAck message. Signed-off-by: subhash kumar singh Change-Id: I2a5b445bf3c032eee9882d14036e2662b46711f3 --- diff --git a/E2Manager/handlers/rmrmsghandlers/ric_service_update_handler.go b/E2Manager/handlers/rmrmsghandlers/ric_service_update_handler.go index 94f9272..15f89a8 100644 --- a/E2Manager/handlers/rmrmsghandlers/ric_service_update_handler.go +++ b/E2Manager/handlers/rmrmsghandlers/ric_service_update_handler.go @@ -104,7 +104,7 @@ func (h *RicServiceUpdateHandler) Handle(request *models.NotificationRequest) { return } - updateAck := models.NewServiceUpdateAck(ackFunctionIds) + updateAck := models.NewServiceUpdateAck(ackFunctionIds, ricServiceUpdate.E2APPDU.InitiatingMessage.Value.RICServiceUpdate.ProtocolIEs.RICServiceUpdateIEs[0].Value.TransactionID) err = h.sendUpdateAck(updateAck, nodebInfo, request) if err != nil { h.logger.Errorf("#RicServiceUpdate.Handle - failed to send RIC_SERVICE_UPDATE_ACK message to RMR: %s", err) diff --git a/E2Manager/models/constants.go b/E2Manager/models/constants.go new file mode 100644 index 0000000..1a33212 --- /dev/null +++ b/E2Manager/models/constants.go @@ -0,0 +1,29 @@ +// +// 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 + +const ( + ProtocolIE_ID_id_RANfunctionID_Item = "6" + ProtocolIE_ID_id_RANfunctionsAccepted = "9" + ProtocolIE_ID_id_TransactionID = "49" +) + +const ( + SuccessfulOutcome_value_PR_RICserviceUpdateAcknowledge = "3" +) diff --git a/E2Manager/models/ric_service_update_ack_message.go b/E2Manager/models/ric_service_update_ack_message.go index 1388f14..81cc12c 100644 --- a/E2Manager/models/ric_service_update_ack_message.go +++ b/E2Manager/models/ric_service_update_ack_message.go @@ -19,89 +19,123 @@ package models import ( - "encoding/xml" + "encoding/xml" ) type RicServiceAckRANFunctionIDItem struct { Text string `xml:",chardata"` - RanFunctionID uint32 `xml:"ranFunctionID"` - RanFunctionRevision uint32 `xml:"ranFunctionRevision"` + RanFunctionID uint32 `xml:"ranFunctionID"` + RanFunctionRevision uint32 `xml:"ranFunctionRevision"` } type RICserviceUpdateAcknowledgeProtocolIESingleContainer struct { - Text string `xml:",chardata"` - Id string `xml:"id"` - Criticality struct { - Text string `xml:",chardata"` - //Ignore string `xml:"ignore"` - Reject string `xml:"reject"` - } `xml:"criticality"` - Value struct { - Text string `xml:",chardata"` - RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"` - } `xml:"value"` + Text string `xml:",chardata"` + Id string `xml:"id"` + Criticality struct { + Text string `xml:",chardata"` + //Ignore string `xml:"ignore"` + Reject string `xml:"reject"` + } `xml:"criticality"` + Value struct { + Text string `xml:",chardata"` + RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"` + } `xml:"value"` } type RICserviceUpdateAcknowledgeIEs struct { Text string `xml:",chardata"` - ID string `xml:"id"` - Criticality struct { - Text string `xml:",chardata"` - Reject string `xml:"reject"` - } `xml:"criticality"` - Value struct { + ID string `xml:"id"` + Criticality struct { Text string `xml:",chardata"` - RANfunctionsIDList struct { - Text string `xml:",chardata"` - ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` - } `xml:"RANfunctionsID-List"` - }`xml:"value"` + Reject string `xml:"reject"` + } `xml:"criticality"` + Value interface{} `xml:"value"` } +type RICserviceUpdateAcknowledgeTransactionID struct { + Text string `xml:",chardata"` + TransactionID string `xml:"TransactionID"` +} + +type RICserviceUpdateAcknowledgeRANfunctionsList struct { + Text string `xml:",chardata"` + RANfunctionsIDList struct { + Text string `xml:",chardata"` + ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` + } `xml:"RANfunctionsID-List"` +} type RicServiceUpdateAckSuccessfulOutcome struct { - XMLName xml.Name `xml:"successfulOutcome"` - Text string `xml:",chardata"` - ProcedureCode string `xml:"procedureCode"` - Criticality struct { - Text string `xml:",chardata"` - Reject string `xml:"reject"` - } `xml:"criticality"` + XMLName xml.Name `xml:"successfulOutcome"` + Text string `xml:",chardata"` + ProcedureCode string `xml:"procedureCode"` + Criticality struct { + Text string `xml:",chardata"` + Reject string `xml:"reject"` + } `xml:"criticality"` Value struct { - Text string `xml:",chardata"` - RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"` + Text string `xml:",chardata"` + RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"` } `xml:"value"` } type RICserviceUpdateAcknowledge struct { Text string `xml:",chardata"` ProtocolIEs struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"` } `xml:"protocolIEs"` } type RicServiceUpdateAckE2APPDU struct { - XMLName xml.Name `xml:"E2AP-PDU"` - Text string `xml:",chardata"` - InitiatingMessage interface{} + XMLName xml.Name `xml:"E2AP-PDU"` + Text string `xml:",chardata"` + SuccessfulOutcome interface{} } -func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem) RicServiceUpdateAckE2APPDU { - successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{} - successfulOutcome.ProcedureCode = "7" - if len(ricServiceUpdate) == 0 { - return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome} +func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem, txId string) RicServiceUpdateAckE2APPDU { + + txIE := RICserviceUpdateAcknowledgeIEs{ + ID: ProtocolIE_ID_id_TransactionID, + Value: RICserviceUpdateAcknowledgeTransactionID{ + TransactionID: txId, + }, } - ricServiceUpdateAcknowledgeIEs := make([]RICserviceUpdateAcknowledgeIEs, 1) - ricServiceUpdateAcknowledgeIEs[0].ID = "9" protocolIESingleContainer := make([]RICserviceUpdateAcknowledgeProtocolIESingleContainer, len(ricServiceUpdate)) for i := 0; i < len(ricServiceUpdate); i++ { protocolIESingleContainer[i].Value.RANfunctionIDItem = ricServiceUpdate[i] - protocolIESingleContainer[i].Id = "6" + protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item + } + + // mandatory RANFunctionsAccepted + functionListIE := RICserviceUpdateAcknowledgeIEs{ + ID: ProtocolIE_ID_id_RANfunctionsAccepted, + Value: RICserviceUpdateAcknowledgeRANfunctionsList{ + RANfunctionsIDList: struct { + Text string `xml:",chardata"` + ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` + }{ + ProtocolIESingleContainer: protocolIESingleContainer, + }, + }, } - ricServiceUpdateAcknowledgeIEs[0].Value.RANfunctionsIDList.ProtocolIESingleContainer = protocolIESingleContainer - successfulOutcome.Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs = ricServiceUpdateAcknowledgeIEs - return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome} -} + successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{ + ProcedureCode: SuccessfulOutcome_value_PR_RICserviceUpdateAcknowledge, + Value: struct { + Text string `xml:",chardata"` + RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"` + }{ + RICserviceUpdateAcknowledge: RICserviceUpdateAcknowledge{ + ProtocolIEs: struct { + Text string `xml:",chardata"` + RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"` + }{ + RICserviceUpdateAcknowledgeIEs: []RICserviceUpdateAcknowledgeIEs{txIE, functionListIE}, + }, + }, + }, + } + + return RicServiceUpdateAckE2APPDU{SuccessfulOutcome: successfulOutcome} +} diff --git a/E2Manager/models/ric_service_update_ack_message_test.go b/E2Manager/models/ric_service_update_ack_message_test.go index 8dfd4bb..85f2568 100644 --- a/E2Manager/models/ric_service_update_ack_message_test.go +++ b/E2Manager/models/ric_service_update_ack_message_test.go @@ -21,8 +21,9 @@ package models_test import ( "e2mgr/models" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestRicServiceUpdateAckMessageSuccess(t *testing.T) { @@ -33,20 +34,20 @@ func TestRicServiceUpdateAckMessageSuccess(t *testing.T) { item2, } - serviceUpdateAck := models.NewServiceUpdateAck(serviceupdateAckFunctionIds) - ies := serviceUpdateAck.InitiatingMessage.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs - assert.Equal(t, "9", ies[0].ID) - assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Id) - assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Id) - assert.Equal(t, item1, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Value.RANfunctionIDItem) - assert.Equal(t, item2, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Value.RANfunctionIDItem) + serviceUpdateAck := models.NewServiceUpdateAck(serviceupdateAckFunctionIds, "1234") + ies := serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs + assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionsAccepted, ies[1].ID) + assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionID_Item, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[0].Id) + assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionID_Item, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[1].Id) + assert.Equal(t, item1, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[0].Value.RANfunctionIDItem) + assert.Equal(t, item2, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[1].Value.RANfunctionIDItem) + + txIE := serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs[0] + assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txIE.ID) + assert.Equal(t, "1234", txIE.Value.(models.RICserviceUpdateAcknowledgeTransactionID).TransactionID) } func TestRicServiceUpdateAckMessageNoRanFunctionIdItemsSuccess(t *testing.T) { - successfulOutcome := models.RicServiceUpdateAckSuccessfulOutcome{} - successfulOutcome.ProcedureCode = "7" - - expectedAck := models.RicServiceUpdateAckE2APPDU{InitiatingMessage: successfulOutcome} - serviceUpdateAck := models.NewServiceUpdateAck(nil) - assert.Equal(t, expectedAck, serviceUpdateAck) + serviceUpdateAck := models.NewServiceUpdateAck(nil, "1234") + assert.Equal(t, 2, len(serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs), "Trasaction ID is mandatory IE") }