From: ecaiyanlinux Date: Sat, 4 Jul 2020 14:50:43 +0000 (+0200) Subject: Add data scripts for nonrtric k8s deployment X-Git-Tag: f-release~81 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fdep.git;a=commitdiff_plain;h=f183066766c133065ecfaa0659ca3dfcd2fe1ac1 Add data scripts for nonrtric k8s deployment populate some data into nonrtric k8s deployment for demo/test purpose fix some minor issues in current k8s deployment Signed-off-by: ecaiyanlinux Change-Id: Ice087741ad452ac4eb0aeb3a2a6dcf7e10f5caa1 --- diff --git a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml index 5d361260..84ba0ed0 100644 --- a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml +++ b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml @@ -133,15 +133,41 @@ policymanagementservice: ric: | [ { - "name":"ric1", - "baseUrl":"http://192.168.130.80:32080/a1mediator", - "controller": "controller1", - "managedElementIds": - [ - "kista_1", - "kista_2" - ] - } + "name":"ric1", + "baseUrl":"https://a1-sim-osc-0.a1-sim:8185", + "controller": "controller1", + "managedElementIds":[ + "kista_1", + "kista_2" + ] + }, + { + "name":"ric2", + "baseUrl":"https://a1-sim-osc-1.a1-sim:8185", + "controller": "controller1", + "managedElementIds":[ + "kista_1", + "kista_2" + ] + }, + { + "name":"ric3", + "baseUrl":"https://a1-sim-std-0.a1-sim:8185", + "controller": "controller1", + "managedElementIds":[ + "kista_1", + "kista_2" + ] + }, + { + "name":"ric4", + "baseUrl":"https://a1-sim-std-1.a1-sim:8185", + "controller": "controller1", + "managedElementIds":[ + "kista_1", + "kista_2" + ] + } ] streams_publishes: | { diff --git a/nonrtric/data/README.md b/nonrtric/data/README.md new file mode 100644 index 00000000..3815ef2e --- /dev/null +++ b/nonrtric/data/README.md @@ -0,0 +1,24 @@ +# O-RAN-SC Non-RealTime RIC data + +In this folder, there are some scripts to populate data into nonrtric k8s deployment + +# How to run the scripts + +bash prepare_data.sh + +## License + +Copyright (C) 2020 Nordix Foundation. +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. + +For more information about license please see the [LICENSE](LICENSE.txt) file for details. diff --git a/nonrtric/data/prepare_data.sh b/nonrtric/data/prepare_data.sh new file mode 100755 index 00000000..e1b6a572 --- /dev/null +++ b/nonrtric/data/prepare_data.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# ============LICENSE_END================================================= +# + +# This script is populating some data into nonrtric for demo/test purpose. +# First this script copies data/ folder into one of the rics, in below case a1-sim-osc-0. +# Then from the ric, run populate_data.sh. +# populate_data.sh creats policy type/ service/ polocies. +# +# Why we run the scripts in the ric, not from the host? +# Because a1-simulators(ric) are deployed in statefulset, +# they are not exposed to outside the k8s cluster. +# And we must create policy type into the ric first. + +kubectl -n nonrtric cp run_in_k8s a1-sim-osc-0:/usr/src/app/ +kubectl -n nonrtric exec -it a1-sim-osc-0 -- bash -c 'cd run_in_k8s/ && ./populate_data.sh' \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/populate_data.sh b/nonrtric/data/run_in_k8s/populate_data.sh new file mode 100755 index 00000000..69cd28c0 --- /dev/null +++ b/nonrtric/data/run_in_k8s/populate_data.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# ============LICENSE_END================================================= +# + +# The scripts in data/ will generate some dummy data in the running system. +# It will create: +# one policy type in a1-sim-OSC_0 +# one service in policy agent +# five policies in a1-sim-OSC_0 +# one policy in a1-sim-STD_0 + +policy_agent_host="policymanagementservice" +policy_agent_port="9080" +a1_sim_osc_0_host="a1-sim-osc-0.a1-sim" +a1_sim_osc_0_port="8085" +a1_sim_osc_1_host="a1-sim-osc-1.a1-sim" +a1_sim_osc_1_port="8085" +a1_sim_std_0_host="a1-sim-std-0.a1-sim" +a1_sim_std_0_port="8085" +a1_sim_std_1_host="a1-sim-std-1.a1-sim" +a1_sim_std_1_port="8085" +httpx=http + +echo "policy agent status:" +curl -skw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/status +echo -e "\n" + +echo "ric1 version:" +curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/interface +echo -e "\n" + +echo "ric2 version:" +curl -skw " %{http_code}" $httpx://$a1_sim_osc_1_host:$a1_sim_osc_1_port/counter/interface +echo -e "\n" + +echo "ric3 version:" +curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/interface +echo -e "\n" + +echo "ric4 version:" +curl -skw " %{http_code}" $httpx://$a1_sim_std_1_host:$a1_sim_std_1_port/counter/interface +echo -e "\n" + +echo "create policy type 1 to ric1:" +curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json +echo -e "\n" + +echo "create policy type 1 to ric2:" +curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_osc_1_host:$a1_sim_osc_1_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json +echo -e "\n" + +for i in {1..12}; do + echo "policy types from policy agent:" + curlString="curl -skw %{http_code} $httpx://$policy_agent_host:$policy_agent_port/policy_types" + res=$($curlString) + echo "$res" + expect="[\"\",\"1\"]200" + if [ "$res" == "$expect" ]; then + echo -e "\n" + break; + else + sleep $i + fi +done + +echo "create service 1 to policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/service" --data-binary @testdata/service.json +echo -e "\n" + +echo "create policy 2000 to ric1 with type1 and service1 via policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2000&ric=ric1&service=service1&type=1" --data-binary @testdata/policy.json +echo -e "\n" + +echo "create policy 2001 to ric1 with type1 and service1 via policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2001&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3101}}' +echo -e "\n" + +echo "create policy 2002 to ric1 with type1 and service1 via policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2002&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3102}}' +echo -e "\n" + +echo "create policy 2003 to ric1 with type1 and service1 via policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2003&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3103}}' +echo -e "\n" + +echo "create policy 2004 to ric1 with type1 and service1 via policy agent:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2004&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3104}}' +echo -e "\n" + +echo "policy numbers from ric1:" +curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/num_instances +echo -e "\n" + +echo "create policy 2100 to ric3 with service1 via policy agent, no type:" +curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2100&ric=ric3&service=service1" --data-binary @testdata/policy.json +echo -e "\n" + +echo "policy numbers from ric3:" +curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/num_instances +echo -e "\n" + +echo "policy id 2000 from policy agent:" +curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2000 +echo -e "\n" + +echo "policy id 2100 from policy agent:" +curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2100 +echo -e "\n" \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/testdata/OSC/policy_type.json b/nonrtric/data/run_in_k8s/testdata/OSC/policy_type.json new file mode 100644 index 00000000..537d86f7 --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/OSC/policy_type.json @@ -0,0 +1,45 @@ +{ + "name": "pt1", + "description": "pt1 policy type", + "policy_type_id": 1, + "create_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OSC_Type1_1.0.0", + "description": "Type 1 policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjective": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + }, + "additionalProperties": false, + "required": [ + "scope", "qosObjective" + ] + } +} diff --git a/nonrtric/data/run_in_k8s/testdata/policy.json b/nonrtric/data/run_in_k8s/testdata/policy.json new file mode 100644 index 00000000..119ba8b2 --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/policy.json @@ -0,0 +1,9 @@ +{ + "scope": { + "ueId": "ue3100", + "qosId": "qos3100" + }, + "qosObjective": { + "priorityLevel": 3100 + } +} diff --git a/nonrtric/data/run_in_k8s/testdata/service.json b/nonrtric/data/run_in_k8s/testdata/service.json new file mode 100644 index 00000000..1b973fce --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/service.json @@ -0,0 +1 @@ +{"callbackUrl": "http://callback-receiver:8090/callbacks/1","keepAliveIntervalSeconds": "3600","serviceName": "service1"}