RIFT OSM R1 Initial Submission
[osm/SO.git] / rwcm / test / ping_pong_nsd / ping_vnfd_1_scriptconf_template.cfg
1 #!/bin/bash
2
3 # Rest API config
4 ping_mgmt_ip='<rw_mgmt_ip>'
5 ping_mgmt_port=18888
6
7 # VNF specific configuration
8 pong_server_ip='<rw_connection_point_name pong_vnfd/cp0>'
9 ping_rate=5
10 server_port=5555
11
12 # Make rest API calls to configure VNF
13 curl -D /dev/stdout \
14     -H "Accept: application/vnd.yang.data+xml" \
15     -H "Content-Type: application/vnd.yang.data+json" \
16     -X POST \
17     -d "{\"ip\":\"$pong_server_ip\", \"port\":$server_port}" \
18     http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/server
19 rc=$?
20 if [ $rc -ne 0 ]
21 then
22     echo "Failed to set server info for ping!"
23     exit $rc
24 fi
25
26 curl -D /dev/stdout \
27     -H "Accept: application/vnd.yang.data+xml" \
28     -H "Content-Type: application/vnd.yang.data+json" \
29     -X POST \
30     -d "{\"rate\":$ping_rate}" \
31     http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/rate
32 rc=$?
33 if [ $rc -ne 0 ]
34 then
35     echo "Failed to set ping rate!"
36     exit $rc
37 fi
38
39 output=$(curl -D /dev/stdout \
40     -H "Accept: application/vnd.yang.data+xml" \
41     -H "Content-Type: application/vnd.yang.data+json" \
42     -X POST \
43     -d "{\"enable\":true}" \
44     http://${ping_mgmt_ip}:${ping_mgmt_port}/api/v1/ping/adminstatus/state)
45 if [[ $output == *"Internal Server Error"* ]]
46 then
47     echo $output
48     exit 3
49 else
50     echo $output
51 fi
52
53
54 exit 0