3 # ============LICENSE_START===============================================
4 # Copyright (C) 2021 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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 # The scripts in data/ will generate some dummy data in the running system.
22 # one policy type in a1-sim-OSC
23 # one service in policy agent
24 # one policy in a1-sim-OSC
25 # one policy in a1-sim-STD
28 # ./preparePmsData.sh [a1-sim-OSC url] [a1-sim-STD-2 url] [policy agent url] [http/https]
30 a1_sim_OSC_url=${1:-localhost:8085}
31 a1_sim_STD_v2_url=${2:-localhost:8085}
32 policy_agent_url=${3:-localhost:8081}
34 SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
36 echo "using a1-sim-OSC url: "$a1_sim_OSC_url
37 echo "using a1-sim-STD-v2 url: "$a1_sim_STD_v2_url
38 echo "using policy-agent url: "$policy_agent_url
39 echo "using protocol: "$httpx
43 if [[ $res != *"$expect"* ]]; then
44 if [ "$res" != "$expect2" ]; then
45 echo "$res is not expected! exit!"
51 echo "policy agent status:"
52 curlString="curl -skw %{http_code} $httpx://$policy_agent_url/status"
60 curlString="curl -skw %{http_code} $httpx://$a1_sim_OSC_url/counter/interface"
68 curlString="curl -skw %{http_code} $httpx://$a1_sim_STD_v2_url/counter/interface"
75 echo "create policy type 1 to ric1:"
76 curlString="curl -X PUT -skw %{http_code} $httpx://$a1_sim_OSC_url/policytype?id=1 -H Content-Type:application/json --data-binary @${SHELL_FOLDER}/../data/OSC/policy_type.json"
79 expect="Policy type 1 is OK"
80 expect2="The policy type already exists and instances exists400"
84 echo "create policy type 2 to ric2:"
85 curlString="curl -skw %{http_code} $httpx://$a1_sim_STD_v2_url/policytype?id=2 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @${SHELL_FOLDER}/../data/v2/policy_type.json"
88 expect="Policy type 2 is OK"
89 expect2="The policy type already exists and instances exists400"
94 echo "policy types from policy agent:"
95 curlString="curl -skw %{http_code} $httpx://$policy_agent_url/a1-policy/v2/policy-types"
98 expect="{\"policytype_ids\":[\"\",\"1\",\"2\"]}200"
99 if [ "$res" == "$expect" ]; then
107 echo "create service ric-registration to policy agent:"
108 curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_url/a1-policy/v2/services" --data-binary @${SHELL_FOLDER}/../data/v2/service.json"
116 echo "create policy aa8feaa88d944d919ef0e83f2172a5000 to ric1 with type 1 and service controlpanel via policy agent:"
117 curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_url/a1-policy/v2/policies" --data-binary @${SHELL_FOLDER}/../data/v2/policy_osc.json"
126 echo "policy numbers from ric1:"
127 curlString="curl -skw %{http_code} $httpx://$a1_sim_OSC_url/counter/num_instances"
134 echo "create policy aa8feaa88d944d919ef0e83f2172a5100 to ric2 with type 2 and service controlpanel via policy agent:"
135 curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_url/a1-policy/v2/policies" --data-binary @${SHELL_FOLDER}/../data/v2/policy_std_v2.json"
143 echo "policy numbers from ric2:"
144 curlString="curl -skw %{http_code} $httpx://$a1_sim_STD_v2_url/counter/num_instances"
151 echo "policy id aa8feaa88d944d919ef0e83f2172a5000 from policy agent:"
152 curlString="curl -s -o /dev/null -I -w %{http_code} $httpx://$policy_agent_url/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5000"
159 echo "policy id aa8feaa88d944d919ef0e83f2172a5100 from policy agent:"
160 curlString="curl -s -o /dev/null -I -w %{http_code} $httpx://$policy_agent_url/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5100"