From b8e578e67a2d1e3e70a5669197c4ccb093669b23 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Mon, 5 Dec 2022 11:30:15 +0000 Subject: [PATCH] Model for handling Reset Request Added model to handle Reset Request message. Issue-ID: RIC-387 Signed-off-by: subhash kumar singh Change-Id: I5b01386f767b04b313aaf090a8cbe1e0a259a630 --- E2Manager/models/constants.go | 2 + E2Manager/models/e2_reset_request.go | 127 ++++++++++++++++++++++ E2Manager/models/e2_reset_request_test.go | 56 ++++++++++ E2Manager/tests/resources/reset/reset-request.xml | 36 ++++++ 4 files changed, 221 insertions(+) create mode 100644 E2Manager/models/e2_reset_request.go create mode 100644 E2Manager/models/e2_reset_request_test.go create mode 100644 E2Manager/tests/resources/reset/reset-request.xml diff --git a/E2Manager/models/constants.go b/E2Manager/models/constants.go index 143aa5d..cf8bf07 100644 --- a/E2Manager/models/constants.go +++ b/E2Manager/models/constants.go @@ -30,10 +30,12 @@ const ( ProtocolIE_ID_id_E2nodeComponentConfigRemoval = "54" ProtocolIE_ID_id_E2nodeComponentConfigRemovalAck = "56" ProtocolIE_ID_id_E2nodeComponentConfigRemovalAck_Item = "57" + ProtocolIE_ID_id_Cause = "1" ) const ( ProcedureCode_id_RICserviceQuery = "6" ProcedureCode_id_E2nodeConfigurationUpdate = "10" ProcedureCode_id_RICserviceUpdate = "7" + ProcedureCode_id_Reset = "3" ) diff --git a/E2Manager/models/e2_reset_request.go b/E2Manager/models/e2_reset_request.go new file mode 100644 index 0000000..582453f --- /dev/null +++ b/E2Manager/models/e2_reset_request.go @@ -0,0 +1,127 @@ +// +// Copyright 2022 Samsung Electronics Co. +// +// 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 + +import ( + "encoding/xml" +) + +type E2ResetRequestMessage struct { + XMLName xml.Name `xml:"E2ResetRequestMessage"` + Text string `xml:",chardata"` + E2APPDU struct { + XMLName xml.Name `xml:"E2AP-PDU"` + Text string `xml:",chardata"` + InitiatingMessage struct { + 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"` + ResetRequest struct { + Text string `xml:",chardata"` + ProtocolIEs struct { + Text string `xml:",chardata"` + ResetRequestIEs []struct { + Text string `xml:",chardata"` + ID string `xml:"id"` + Criticality struct { + Text string `xml:",chardata"` + Ignore string `xml:"ignore"` + } `xml:"criticality"` + Value struct { + Text string `xml:",chardata"` + TransactionID string `xml:"TransactionID"` + Cause CauseResetRequest `xml:"Cause"` + } `xml:"value"` + } `xml:"ResetRequestIEs"` + } `xml:"protocolIEs"` + } `xml:"ResetRequest"` + } `xml:"value"` + } `xml:"initiatingMessage"` + } `xml:"E2AP-PDU"` +} + +type CauseResetRequest struct { + Text string `xml:",chardata"` + E2Node E2Node `xml:"e2Node"` + RicRequest RicRequest `xml:"ricRequest"` + Misc Misc `xml:"misc"` + Protocol Protocol `xml:"protocol"` + Transport Transport `xml:"transport"` + RicService RicService `xml:"ricService"` +} + +type E2Node struct { + Text string `xml:",chardata"` + E2nodeComponentUnknown *struct{} `xml:"e2node-component-unknown"` +} + +type RicRequest struct { + Text string `xml:",chardata"` + RanFunctionIDInvalid *struct{} `xml:"ran-function-id-invalid"` + ActionNotSupported *struct{} `xml:"action-not-supported"` + ExcessiveActions *struct{} `xml:"excessive-actions"` + DuplicateAction *struct{} `xml:"duplicate-action"` + DuplicateEventTrigger *struct{} `xml:"duplicate-event-trigger"` + FunctionResourceLimit *struct{} `xml:"function-resource-limit"` + RequestIDUnknown *struct{} `xml:"request-id-unknown"` + InconsistentActionSubsequentActionSequence *struct{} `xml:"inconsistent-action-subsequent-action-sequence"` + ControlMessageInvalid *struct{} `xml:"control-message-invalid"` + RicCallProcessIDInvalid *struct{} `xml:"ric-call-process-id-invalid"` + ControlTimerExpired *struct{} `xml:"control-timer-expired"` + ControlFailedToExecute *struct{} `xml:"control-failed-to-execute"` + SystemNotReady *struct{} `xml:"system-not-ready"` + Unspecified *struct{} `xml:"unspecified"` +} + +type Misc struct { + Text string `xml:",chardata"` + ControlProcessingOverload *struct{} `xml:"control-processing-overload"` + HardwareFailure *struct{} `xml:"hardware-failure"` + OmIntervention *struct{} `xml:"om-intervention"` + Unspecified *struct{} `xml:"unspecified"` +} + +type Protocol struct { + Text string `xml:",chardata"` + TransferSyntaxError *struct{} `xml:"transfer-syntax-error"` + AbstractSyntaxErrorReject *struct{} `xml:"abstract-syntax-error-reject"` + AbstractSyntaxErrorIgnoreAndNotify *struct{} `xml:"abstract-syntax-error-ignore-and-notify"` + MessageNotCompatibleWithReceiverState *struct{} `xml:"message-not-compatible-with-receiver-state"` + SemanticError *struct{} `xml:"semantic-error"` + AbstractSyntaxErrorFalselyConstructedMessage *struct{} `xml:"abstract-syntax-error-falsely-constructed-message"` + Unspecified *struct{} `xml:"unspecified"` +} + +type Transport struct { + Text string `xml:",chardata"` + Unspecified *struct{} `xml:"unspecified"` + TransportResourceUnavailable *struct{} `xml:"transport-resource-unavailable"` +} + +type RicService struct { + Text string `xml:",chardata"` + RanFunctionNotSupported *struct{} `xml:"ran-function-not-supported"` + ExcessiveFunctions *struct{} `xml:"excessive-functions"` + RicResourceLimit *struct{} `xml:"ric-resource-limit"` +} diff --git a/E2Manager/models/e2_reset_request_test.go b/E2Manager/models/e2_reset_request_test.go new file mode 100644 index 0000000..0e397c0 --- /dev/null +++ b/E2Manager/models/e2_reset_request_test.go @@ -0,0 +1,56 @@ +// +// Copyright 2022 Samsung Electronics Co. +// +// 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" + "e2mgr/utils" + "encoding/xml" + "testing" + + "github.com/stretchr/testify/assert" +) + +const ( + ResetRequstXMLPath = "../tests/resources/reset/reset-request.xml" +) + +func getResetRequestMessage(t *testing.T, reqXmlPath string) *models.E2ResetRequestMessage { + resetRequest := utils.ReadXmlFile(t, reqXmlPath) + resetRequestMsg := &models.E2ResetRequestMessage{} + err := xml.Unmarshal(utils.NormalizeXml(resetRequest), &resetRequestMsg.E2APPDU) + assert.Nil(t, err) + return resetRequestMsg +} + +func TestParseResetRequest(t *testing.T) { + rr := getResetRequestMessage(t, ResetRequstXMLPath) + assert.NotEqual(t, nil, rr, "xml is not parsed correctly") + assert.Equal(t, models.ProcedureCode_id_Reset, rr.E2APPDU.InitiatingMessage.ProcedureCode) + assert.Equal(t, 2, len(rr.E2APPDU.InitiatingMessage.Value.ResetRequest.ProtocolIEs.ResetRequestIEs)) + + txid := rr.E2APPDU.InitiatingMessage.Value.ResetRequest.ProtocolIEs.ResetRequestIEs[0] + cause := rr.E2APPDU.InitiatingMessage.Value.ResetRequest.ProtocolIEs.ResetRequestIEs[1] + + assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txid.ID) + assert.Equal(t, models.ProtocolIE_ID_id_Cause, cause.ID) + + assert.Equal(t, false, cause.Value.Cause.E2Node.E2nodeComponentUnknown == nil) + assert.Equal(t, true, cause.Value.Cause.Misc.ControlProcessingOverload == nil) +} diff --git a/E2Manager/tests/resources/reset/reset-request.xml b/E2Manager/tests/resources/reset/reset-request.xml new file mode 100644 index 0000000..cc27c05 --- /dev/null +++ b/E2Manager/tests/resources/reset/reset-request.xml @@ -0,0 +1,36 @@ + + + 3 + + + + + + + + 49 + + + + + 1 + + + + 1 + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.16.6