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
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 # ./prepareDmaapMsg.sh [dmaap-mr url] [a1-sim-OSC url] [a1-sim-STD url] [a1-sim-STD2 url] [http/https]
30 dmaap_mr_url=${1:-localhost:3904}
31 a1_sim_OSC_url=${2:-localhost:8085}
32 a1_sim_STD_url=${3:-localhost:8085}
33 a1_sim_STD_v2_url=${4:-localhost:8085}
34 policy_agent_url=${5:-localhost:9081}
37 echo "using dmaap-mr url: "$dmaap_mr_url
38 echo "using a1-sim-OSC url: "$a1_sim_OSC_url
39 echo "using a1-sim-STD url: "$a1_sim_STD_url
40 echo "using a1-sim-STD-v2 url: "$a1_sim_STD_v2_url
41 echo "using policy-agent url: "$policy_agent_url
42 echo "using protocol: "$httpx
45 echo "dmaap-mr topics: $httpx://$dmaap_mr_url/topics/listAll"
46 curl -skw %{http_code} $httpx://$dmaap_mr_url/topics/listAll
49 echo "dmaap-mr create topic A1-POLICY-AGENT-READ:"
50 curl -skw %{http_code} -X POST "$httpx://$dmaap_mr_url/topics/create" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"topicName\": \"A1-POLICY-AGENT-READ\", \"topicDescription\": \"test topic\", \"partitionCount\": 1, \"replicationCount\": 1, \"transactionEnabled\": \"false\"}"
53 echo "dmaap-mr create topic A1-POLICY-AGENT-WRITE:"
54 curl -skw %{http_code} -X POST "$httpx://$dmaap_mr_url/topics/create" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"topicName\": \"A1-POLICY-AGENT-WRITE\", \"topicDescription\": \"test topic\", \"partitionCount\": 1, \"replicationCount\": 1, \"transactionEnabled\": \"false\"}"
57 echo "dmaap-mr topics:"
58 curl -skw %{http_code} $httpx://$dmaap_mr_url/topics/listAll
62 curl -skw %{http_code} $httpx://$a1_sim_OSC_url/counter/interface
66 curl -skw %{http_code} $httpx://$a1_sim_STD_url/counter/interface
70 curl -skw %{http_code} $httpx://$a1_sim_STD_v2_url/counter/interface
73 echo "create policy type 1 to ric1:"
74 curl -X PUT -skw %{http_code} $httpx://$a1_sim_OSC_url/policytype?id=1 -H Content-Type:application/json --data-binary @../data/OSC/policy_type.json
77 echo "create policy type 2 to ric3:"
78 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 @../data/v2/policy_type.json
82 echo "policy types from policy agent:"
83 curlString="curl -skw %{http_code} $httpx://$policy_agent_url/policy_types"
86 expect="[\"\",\"1\",\"2\"]200"
87 if [ "$res" == "$expect" ]; then
95 ## Using PMS v1 interface
96 echo "create service 1 to policy agent via dmaap_mr:"
97 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v1/dmaap-msg-service-create.json
100 echo "get result from mr of previous request:"
101 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
104 echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
105 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v1/dmaap-msg-policy-create.json
108 echo "get result from mr of previous request:"
109 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
112 echo "get policy from policy agent via dmaap_mr:"
113 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v1/dmaap-msg-policy-get.json
116 echo "get result from mr of previous request:"
117 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
120 ## Using PMS v2 interface
121 echo "create service 2 to policy agent via dmaap_mr:"
122 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v2/dmaap-msg-service-create.json
125 echo "get result from mr of previous request:"
126 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
129 echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
130 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v2/dmaap-msg-policy-create.json
133 echo "get result from mr of previous request:"
134 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
137 echo "get policy from policy agent via dmaap_mr:"
138 curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-READ/" --data-binary @../data/dmaap/v2/dmaap-msg-policy-get.json
141 echo "get result from mr of previous request:"
142 curl -X GET "$httpx://$dmaap_mr_url/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
145 ## Get metric from rics
146 echo "policy numbers from ric1:"
147 curl -skw %{http_code} $httpx://$a1_sim_OSC_url/counter/num_instances
150 echo "policy numbers from ric2:"
151 curl -skw %{http_code} $httpx://$a1_sim_STD_url/counter/num_instances
154 echo "policy numbers from ric3:"
155 curl -skw %{http_code} $httpx://$a1_sim_STD_v2_url/counter/num_instances