Add A1 STD V2 simulators
[it/dep.git] / nonrtric / data / run_in_k8s / populate_data.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 #  ========================================================================
6 #  Licensed under the Apache License, Version 2.0 (the "License");
7 #  you may not use this file except in compliance with the License.
8 #  You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #  Unless required by applicable law or agreed to in writing, software
13 #  distributed under the License is distributed on an "AS IS" BASIS,
14 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #  See the License for the specific language governing permissions and
16 #  limitations under the License.
17 #  ============LICENSE_END=================================================
18 #
19
20 # The scripts in data/ will generate some dummy data in the running system.
21 # It will create:
22 # one policy type in a1-sim-OSC_0
23 # one service in policy agent
24 # five policies in a1-sim-OSC_0
25 # one policy in a1-sim-STD_0
26 # one policy type in a1-sim-STD2_0
27 # one policy in a1-sim-STD2_0
28
29 policy_agent_host="policymanagementservice"
30 policy_agent_port="9080"
31 a1_sim_osc_0_host="a1-sim-osc-0.a1-sim"
32 a1_sim_osc_0_port="8085"
33 a1_sim_osc_1_host="a1-sim-osc-1.a1-sim"
34 a1_sim_osc_1_port="8085"
35 a1_sim_std_0_host="a1-sim-std-0.a1-sim"
36 a1_sim_std_0_port="8085"
37 a1_sim_std_1_host="a1-sim-std-1.a1-sim"
38 a1_sim_std_1_port="8085"
39 a1_sim_std2_0_host="a1-sim-std2-0.a1-sim"
40 a1_sim_std2_0_port="8085"
41 a1_sim_std2_1_host="a1-sim-std2-1.a1-sim"
42 a1_sim_std2_1_port="8085"
43 httpx=http
44
45 echo "policy agent status:"
46 curl -skw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/status
47 echo -e "\n"
48
49 echo "ric1 version:"
50 curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/interface
51 echo -e "\n"
52
53 echo "ric2 version:"
54 curl -skw " %{http_code}" $httpx://$a1_sim_osc_1_host:$a1_sim_osc_1_port/counter/interface
55 echo -e "\n"
56
57 echo "ric3 version:"
58 curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/interface
59 echo -e "\n"
60
61 echo "ric4 version:"
62 curl -skw " %{http_code}" $httpx://$a1_sim_std_1_host:$a1_sim_std_1_port/counter/interface
63 echo -e "\n"
64
65 echo "ric5 version:"
66 curl -skw " %{http_code}" $httpx://$a1_sim_std2_0_host:$a1_sim_std_0_port/counter/interface
67 echo -e "\n"
68
69 echo "ric6 version:"
70 curl -skw " %{http_code}" $httpx://$a1_sim_std2_1_host:$a1_sim_std_1_port/counter/interface
71 echo -e "\n"
72
73 echo "create policy type 1 to ric1:"
74 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
75 echo -e "\n"
76
77 echo "create policy type 1 to ric2:"
78 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
79 echo -e "\n"
80
81 echo "create policy type 2 to STD2 ric5:"
82 curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_std2_0_host:$a1_sim_std2_0_port/policytype?id=2 -H Content-Type:application/json --data-binary @testdata/STD/policy_type.json
83 echo -e "\n"
84
85 echo "create policy type 2 to STD2 ric6:"
86 curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_std2_1_host:$a1_sim_std2_1_port/policytype?id=2 -H Content-Type:application/json --data-binary @testdata/STD/policy_type.json
87 echo -e "\n"
88
89 for i in {1..12}; do
90         echo "policy types from policy agent:"
91     curlString="curl -skw %{http_code} $httpx://$policy_agent_host:$policy_agent_port/policy_types"
92     res=$($curlString)
93     echo "$res"
94     expect="[\"\",\"1\",\"2\"]200"
95     if [ "$res" == "$expect" ]; then
96         echo -e "\n"
97         break;
98     else
99         sleep $i
100     fi
101 done
102
103 echo "create service 1 to policy agent:"
104 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
105 echo -e "\n"
106
107 echo "create policy 2000 to ric1 with type1 and service1 via policy agent:"
108 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
109 echo -e "\n"
110
111 echo "create policy 2001 to ric1 with type1 and service1 via policy agent:"
112 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}}'
113 echo -e "\n"
114
115 echo "create policy 2002 to ric1 with type1 and service1 via policy agent:"
116 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}}'
117 echo -e "\n"
118
119 echo "create policy 2003 to ric1 with type1 and service1 via policy agent:"
120 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}}'
121 echo -e "\n"
122
123 echo "create policy 2004 to ric1 with type1 and service1 via policy agent:"
124 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}}'
125 echo -e "\n"
126
127 echo "create policy 2200 to ric5 with type1 and service1 via policy agent:"
128 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/v2/policies" --data-binary @testdata/STD/policy.json
129 echo -e "\n"
130
131 echo "policy numbers from ric1:"
132 curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/num_instances
133 echo -e "\n"
134
135 echo "create policy 2100 to ric3 with service1 via policy agent, no type:"
136 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
137 echo -e "\n"
138
139 echo "policy numbers from ric3:"
140 curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/num_instances
141 echo -e "\n"
142
143 echo "policy id 2000 from policy agent:"
144 curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2000
145 echo -e "\n"
146
147 echo "policy id 2100 from policy agent:"
148 curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2100
149 echo -e "\n"