From 5b26de71a0aae08360a38477150551651a7ef734 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Fri, 21 Jan 2022 16:12:08 +0100 Subject: [PATCH] Update O-RU Fronthaul Recovery usecase The URL and message body to SDNR has been changed. This commit updates the script and Go versions. Issue-ID: NONRTRIC-719 Signed-off-by: elinuxhenrik Change-Id: I23d31dc7b2e6740e102e63dd565753d0dd8ccc48 --- .../internal/linkfailure/linkfailurehandler.go | 16 +++++-------- .../linkfailure/linkfailurehandler_test.go | 10 ++++----- .../goversion/o-ru-to-o-du-map.csv | 22 +++++++++--------- .../goversion/stub/producer/producerstub.go | 2 +- .../goversion/stub/sdnr/sdnrstub.go | 2 +- .../scriptversion/app/main.py | 26 +++++++++++++++++----- .../scriptversion/app/o-ru-to-o-du-map.txt | 22 +++++++++--------- .../scriptversion/simulators/sdnr_simulator.py | 18 +++++++-------- 8 files changed, 63 insertions(+), 55 deletions(-) diff --git a/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler.go b/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler.go index 3aecf45c..26b3ab32 100644 --- a/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler.go +++ b/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler.go @@ -37,8 +37,8 @@ type Configuration struct { SDNRPassword string } -const rawSdnrPath = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=[O-DU-ID]/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=[O-RU-ID]" -const unlockMessage = `{"o-ran-sc-du-hello-world:du-to-ru-connection": [{"name":"[O-RU-ID]","administrative-state":"UNLOCKED"}]}` +const rawSdnrPath = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=[O-DU-ID]/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=[O-DU-ID]/radio-resource-management-policy-ratio=rrm-pol-1" +const unlockMessage = `{"o-ran-sc-du-hello-world:radio-resource-management-policy-ratio":[{"id":"rrm-pol-1","radio-resource-management-policy-max-ratio":25,"radio-resource-management-policy-members":[{"mobile-country-code":"310","mobile-network-code":"150","slice-differentiator":1,"slice-service-type":1}],"radio-resource-management-policy-min-ratio":15,"user-label":"rrm-pol-1","resource-type":"prb","radio-resource-management-policy-dedicated-ratio":20,"administrative-state":"unlocked"}]}` type LinkFailureHandler struct { lookupService repository.LookupService @@ -71,8 +71,7 @@ func (lfh LinkFailureHandler) MessagesHandler(w http.ResponseWriter, r *http.Req func (lfh LinkFailureHandler) sendUnlockMessage(oRuId string) { if oDuId, err := lfh.lookupService.GetODuID(oRuId); err == nil { - sdnrPath := getSdnrPath(oRuId, oDuId) - unlockMessage := lfh.getUnlockMessage(oRuId) + sdnrPath := getSdnrPath(oDuId) if error := restclient.Put(lfh.config.SDNRAddress+sdnrPath, unlockMessage, lfh.client, lfh.config.SDNRUser, lfh.config.SDNRPassword); error == nil { log.Debugf("Sent unlock message for O-RU: %v to O-DU: %v.", oRuId, oDuId) } else { @@ -84,12 +83,7 @@ func (lfh LinkFailureHandler) sendUnlockMessage(oRuId string) { } -func getSdnrPath(oRuId string, oDuId string) string { - sdnrPath := strings.Replace(rawSdnrPath, "[O-DU-ID]", oDuId, 1) - sdnrPath = strings.Replace(sdnrPath, "[O-RU-ID]", oRuId, 1) +func getSdnrPath(oDuId string) string { + sdnrPath := strings.Replace(rawSdnrPath, "[O-DU-ID]", oDuId, -1) return sdnrPath } - -func (lfh LinkFailureHandler) getUnlockMessage(oRuId string) string { - return strings.Replace(unlockMessage, "[O-RU-ID]", oRuId, 1) -} diff --git a/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler_test.go b/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler_test.go index a3df7044..050417f5 100644 --- a/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler_test.go +++ b/test/usecases/oruclosedlooprecovery/goversion/internal/linkfailure/linkfailurehandler_test.go @@ -56,7 +56,7 @@ func Test_MessagesHandlerWithLinkFailure(t *testing.T) { lookupServiceMock := mocks.LookupService{} - lookupServiceMock.On("GetODuID", mock.Anything).Return("HCL-O-DU-1122", nil) + lookupServiceMock.On("GetODuID", mock.Anything).Return("O-DU-1122", nil) handlerUnderTest := NewLinkFailureHandler(&lookupServiceMock, Configuration{ SDNRAddress: "http://localhost:9990", @@ -78,21 +78,21 @@ func Test_MessagesHandlerWithLinkFailure(t *testing.T) { assertions.Equal(http.MethodPut, actualRequest.Method) assertions.Equal("http", actualRequest.URL.Scheme) assertions.Equal("localhost:9990", actualRequest.URL.Host) - expectedSdnrPath := "/rests/data/network-topology:network-topology/topology=topology-netconf/node=HCL-O-DU-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=ERICSSON-O-RU-11220" + expectedSdnrPath := "/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=O-DU-1122/radio-resource-management-policy-ratio=rrm-pol-1" assertions.Equal(expectedSdnrPath, actualRequest.URL.Path) assertions.Equal("application/json; charset=utf-8", actualRequest.Header.Get("Content-Type")) tempRequest, _ := http.NewRequest("", "", nil) tempRequest.SetBasicAuth("admin", "pwd") assertions.Equal(tempRequest.Header.Get("Authorization"), actualRequest.Header.Get("Authorization")) body, _ := ioutil.ReadAll(actualRequest.Body) - expectedBody := []byte(`{"o-ran-sc-du-hello-world:du-to-ru-connection": [{"name":"ERICSSON-O-RU-11220","administrative-state":"UNLOCKED"}]}`) + expectedBody := []byte(`{"o-ran-sc-du-hello-world:radio-resource-management-policy-ratio":[{"id":"rrm-pol-1","radio-resource-management-policy-max-ratio":25,"radio-resource-management-policy-members":[{"mobile-country-code":"310","mobile-network-code":"150","slice-differentiator":1,"slice-service-type":1}],"radio-resource-management-policy-min-ratio":15,"user-label":"rrm-pol-1","resource-type":"prb","radio-resource-management-policy-dedicated-ratio":20,"administrative-state":"unlocked"}]}`) assertions.Equal(expectedBody, body) clientMock.AssertNumberOfCalls(t, "Do", 1) logString := buf.String() assertions.Contains(logString, "Sent unlock message") assertions.Contains(logString, "O-RU: ERICSSON-O-RU-11220") - assertions.Contains(logString, "O-DU: HCL-O-DU-1122") + assertions.Contains(logString, "O-DU: O-DU-1122") } func newRequest(method string, url string, bodyAsBytes []byte, t *testing.T) *http.Request { @@ -117,7 +117,7 @@ func Test_MessagesHandlerWithClearLinkFailure(t *testing.T) { lookupServiceMock := mocks.LookupService{} - lookupServiceMock.On("GetODuID", mock.Anything).Return("HCL-O-DU-1122", nil) + lookupServiceMock.On("GetODuID", mock.Anything).Return("O-DU-1122", nil) handlerUnderTest := NewLinkFailureHandler(&lookupServiceMock, Configuration{}, nil) diff --git a/test/usecases/oruclosedlooprecovery/goversion/o-ru-to-o-du-map.csv b/test/usecases/oruclosedlooprecovery/goversion/o-ru-to-o-du-map.csv index 951337af..2c5417d8 100644 --- a/test/usecases/oruclosedlooprecovery/goversion/o-ru-to-o-du-map.csv +++ b/test/usecases/oruclosedlooprecovery/goversion/o-ru-to-o-du-map.csv @@ -1,11 +1,11 @@ -ERICSSON-O-RU-11220,HCL-O-DU-1122 -ERICSSON-O-RU-11221,HCL-O-DU-1122 -ERICSSON-O-RU-11222,HCL-O-DU-1122 -ERICSSON-O-RU-11223,HCL-O-DU-1122 -ERICSSON-O-RU-11223,HCL-O-DU-1122 -ERICSSON-O-RU-11224,HCL-O-DU-1123 -ERICSSON-O-RU-11225,HCL-O-DU-1123 -ERICSSON-O-RU-11226,HCL-O-DU-1123 -ERICSSON-O-RU-11227,HCL-O-DU-1124 -ERICSSON-O-RU-11228,HCL-O-DU-1125 -ERICSSON-O-RU-11229,HCL-O-DU-1125 \ No newline at end of file +ERICSSON-O-RU-11220,O-DU-1122 +ERICSSON-O-RU-11221,O-DU-1122 +ERICSSON-O-RU-11222,O-DU-1122 +ERICSSON-O-RU-11223,O-DU-1122 +ERICSSON-O-RU-11223,O-DU-1122 +ERICSSON-O-RU-11224,O-DU-1123 +ERICSSON-O-RU-11225,O-DU-1123 +ERICSSON-O-RU-11226,O-DU-1123 +ERICSSON-O-RU-11227,O-DU-1124 +ERICSSON-O-RU-11228,O-DU-1125 +ERICSSON-O-RU-11229,O-DU-1125 \ No newline at end of file diff --git a/test/usecases/oruclosedlooprecovery/goversion/stub/producer/producerstub.go b/test/usecases/oruclosedlooprecovery/goversion/stub/producer/producerstub.go index 4af16cf5..e219e19d 100644 --- a/test/usecases/oruclosedlooprecovery/goversion/stub/producer/producerstub.go +++ b/test/usecases/oruclosedlooprecovery/goversion/stub/producer/producerstub.go @@ -52,7 +52,7 @@ func createJobHandler(w http.ResponseWriter, r *http.Request) { started = true fmt.Println("Start pushing messages for job: ", id) - startPushingMessages() + go startPushingMessages() } func deleteJobHandler(w http.ResponseWriter, r *http.Request) { diff --git a/test/usecases/oruclosedlooprecovery/goversion/stub/sdnr/sdnrstub.go b/test/usecases/oruclosedlooprecovery/goversion/stub/sdnr/sdnrstub.go index fd0af03b..0bcd0f4b 100644 --- a/test/usecases/oruclosedlooprecovery/goversion/stub/sdnr/sdnrstub.go +++ b/test/usecases/oruclosedlooprecovery/goversion/stub/sdnr/sdnrstub.go @@ -34,7 +34,7 @@ func main() { flag.Parse() r := mux.NewRouter() - r.HandleFunc("/rests/data/network-topology:network-topology/topology=topology-netconf/node={O-DU-ID}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection={O-RU-ID}", handleData) + r.HandleFunc("/rests/data/network-topology:network-topology/topology=topology-netconf/node={O-DU-ID}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions={O-DU-ID}/radio-resource-management-policy-ratio=rrm-pol-1", handleData) fmt.Println("Starting SDNR on port: ", *port) fmt.Println(http.ListenAndServe(fmt.Sprintf(":%v", *port), r)) diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/app/main.py b/test/usecases/oruclosedlooprecovery/scriptversion/app/main.py index 8f5b2443..52f0ca85 100644 --- a/test/usecases/oruclosedlooprecovery/scriptversion/app/main.py +++ b/test/usecases/oruclosedlooprecovery/scriptversion/app/main.py @@ -24,14 +24,29 @@ import requests import time MR_PATH = "/events/[TOPIC]/users/test/" -SDNR_PATH = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=[O-DU-ID]/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=[O-RU-ID]" +SDNR_PATH = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=[O-DU-ID]/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=[O-DU-ID]/radio-resource-management-policy-ratio=rrm-pol-1" FAUILT_ID = "28" UNLOCK_MESSAGE = { - "o-ran-sc-du-hello-world:du-to-ru-connection": [ + "o-ran-sc-du-hello-world:radio-resource-management-policy-ratio": + [ { - "name":"", - "administrative-state":"UNLOCKED" + "id":"rrm-pol-1", + "radio-resource-management-policy-max-ratio":25, + "radio-resource-management-policy-members": + [ + { + "mobile-country-code":"310", + "mobile-network-code":"150", + "slice-differentiator":1, + "slice-service-type":1 + } + ], + "radio-resource-management-policy-min-ratio":15, + "user-label":"rrm-pol-1", + "resource-type":"prb", + "radio-resource-management-policy-dedicated-ratio":20, + "administrative-state":"unlocked" } ] } @@ -71,8 +86,7 @@ def handle_link_failure(message, o_ru_to_o_du_map, sdnr_address, sdnr_user, sdnr o_du_id = o_ru_to_o_du_map[o_ru_id] verboseprint("O-DU ID: " + o_du_id) unlock_msg = json.loads(json.dumps(UNLOCK_MESSAGE)) - unlock_msg["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["name"] = o_ru_id - send_path = SDNR_PATH.replace("[O-DU-ID]", o_du_id).replace("[O-RU-ID]", o_ru_id) + send_path = SDNR_PATH.replace("[O-DU-ID]", o_du_id) requests.put(sdnr_address + send_path, auth=(sdnr_user, sdnr_pwd), json=unlock_msg) else: print("ERROR: No mapping for O-RU ID: " + o_ru_id) diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/app/o-ru-to-o-du-map.txt b/test/usecases/oruclosedlooprecovery/scriptversion/app/o-ru-to-o-du-map.txt index c9ec8eae..314495cf 100644 --- a/test/usecases/oruclosedlooprecovery/scriptversion/app/o-ru-to-o-du-map.txt +++ b/test/usecases/oruclosedlooprecovery/scriptversion/app/o-ru-to-o-du-map.txt @@ -1,13 +1,13 @@ { - "ERICSSON-O-RU-11220": "HCL-O-DU-1122", - "ERICSSON-O-RU-11221": "HCL-O-DU-1122", - "ERICSSON-O-RU-11222": "HCL-O-DU-1122", - "ERICSSON-O-RU-11223": "HCL-O-DU-1122", - "ERICSSON-O-RU-11223": "HCL-O-DU-1122", - "ERICSSON-O-RU-11224": "HCL-O-DU-1123", - "ERICSSON-O-RU-11225": "HCL-O-DU-1123", - "ERICSSON-O-RU-11226": "HCL-O-DU-1123", - "ERICSSON-O-RU-11227": "HCL-O-DU-1124", - "ERICSSON-O-RU-11228": "HCL-O-DU-1125", - "ERICSSON-O-RU-11229": "HCL-O-DU-1125", + "ERICSSON-O-RU-11220": "O-DU-1122", + "ERICSSON-O-RU-11221": "O-DU-1122", + "ERICSSON-O-RU-11222": "O-DU-1122", + "ERICSSON-O-RU-11223": "O-DU-1122", + "ERICSSON-O-RU-11223": "O-DU-1122", + "ERICSSON-O-RU-11224": "O-DU-1123", + "ERICSSON-O-RU-11225": "O-DU-1123", + "ERICSSON-O-RU-11226": "O-DU-1123", + "ERICSSON-O-RU-11227": "O-DU-1124", + "ERICSSON-O-RU-11228": "O-DU-1125", + "ERICSSON-O-RU-11229": "O-DU-1125", } \ No newline at end of file diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/simulators/sdnr_simulator.py b/test/usecases/oruclosedlooprecovery/scriptversion/simulators/sdnr_simulator.py index 535c3ee0..a44c0734 100644 --- a/test/usecases/oruclosedlooprecovery/scriptversion/simulators/sdnr_simulator.py +++ b/test/usecases/oruclosedlooprecovery/scriptversion/simulators/sdnr_simulator.py @@ -39,7 +39,7 @@ MR_PATH = "/events/unauthenticated.SEC_FAULT_OUTPUT" # Server info HOST_IP = "::" HOST_PORT = 9990 -APP_URL = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=" +APP_URL = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions=/radio-resource-management-policy-ratio=rrm-pol-1" USERNAME = "admin" PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" @@ -88,17 +88,17 @@ linkFailureMessage = { class AlarmClearThread (threading.Thread): - def __init__(self, sleep_time, o_ru_id): + def __init__(self, sleep_time, o_du_id): threading.Thread.__init__(self) self.sleep_time = sleep_time - self.o_ru_id = o_ru_id + self.o_du_id = o_du_id def run(self): - print(f'Sleeping: {self.sleep_time} before clearing O-DU: {self.o_ru_id}') + print(f'Sleeping: {self.sleep_time} before clearing O-DU: {self.o_du_id}') time.sleep(self.sleep_time) msg_as_json = json.loads(json.dumps(linkFailureMessage)) - msg_as_json["event"]["commonEventHeader"]["sourceName"] = self.o_ru_id - print("Sedning alarm clear for O-RU: " + self.o_ru_id) + msg_as_json["event"]["commonEventHeader"]["sourceName"] = self.o_du_id + print("Sedning alarm clear for O-DU: " + self.o_du_id) requests.post(mr_host + ":" + mr_port + MR_PATH, json=msg_as_json); @@ -118,10 +118,10 @@ def verify_password(username, password): @app.route(APP_URL, methods=['PUT']) @auth.login_required -def sendrequest(o_du_id, o_ru_id): - print("Got request with O-DU ID: " + o_du_id + " and O-RU ID: " + o_ru_id) +def sendrequest(o_du_id, o_du_id2): + print("Got request with O-DU ID: " + o_du_id) random_time = int(10 * random.random()) - alarm_clear_thread = AlarmClearThread(random_time, o_ru_id) + alarm_clear_thread = AlarmClearThread(random_time, o_du_id) alarm_clear_thread.start() return Response(status=200) -- 2.16.6