summaryrefslogtreecommitdiffstats
path: root/vfw_spinup.sh
diff options
context:
space:
mode:
authorzc9211 <zhangchen.bri@chinatelecom.cn>2018-01-31 00:06:26 +0800
committerzc9211 <zhangchen.bri@chinatelecom.cn>2018-01-31 00:07:17 +0800
commit537dab24cc5bd27c5c94b3d1f3eb279596be6132 (patch)
tree79ae1681a35002330401acbad157d7bc1bf3da15 /vfw_spinup.sh
parent3d636def30cd293231e84a7f2ecf7db2dfad334d (diff)
vcpe_testscripts
Change-Id: I8f438c65f1d623f2125e1bf073646e5c2172049d Signed-off-by: zc9211 <zhangchen.bri@chinatelecom.cn>
Diffstat (limited to 'vfw_spinup.sh')
-rw-r--r--vfw_spinup.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/vfw_spinup.sh b/vfw_spinup.sh
new file mode 100644
index 0000000..9c9cd82
--- /dev/null
+++ b/vfw_spinup.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# spin up a new vfw instance
+
+URLSPINUP = 'http://127.0.0.1:18003/vnf/v1'
+URLSTATUS = 'http://127.0.0.1:18002/resmgr/v1/dev?dev_id='
+AUTH = 'admin:admin'
+
+dev_id = "0488033DDN20180118150535B7F76420"
+vnf_name = "vfw_20180118150535"
+esn = "0488033DDN20180118150535B7F76420"
+
+function spinup {
+
+ result = curl -I -H "Content-type: application/json" -X POST -u $AUTH -d '{ "dev_id": $1, "vnf_name": $2, "ctrler_id": "HW_AC_CAMPUS_CQ2", "vnfm_id": "HW_VNFM_CQ", "dev_vendor": "HUAWEI", "dev_model": "VNFM", "vnf_type": "VFW", "vnf_esn": $3, "netconf_cfg": { "ipv4": "192.168.20.129", "mask_bit": 24, "ipv4_gw": "192.168.20.254"}, "wan_cfg": {"ipv4": "192.168.40.40", "mask_bit": 24, "ipv4_gw": "192.168.40.254"}, "status": "Active" }' $URLSPINUP
+ echo 'trying to spin up a new vfw instance'
+ return result
+
+}
+
+function checkstatus {
+
+ URL = {$URLSTATUS}{$1}
+
+ result = curl -I -H "Content-type: application/json" -X GET -u $AUTH $URL
+ status = jq '.status' $result
+ return status
+
+}
+
+data = json
+result = sinup $dev_id $vnf_name $esn
+
+if [ $result -eq 200 ]; then
+
+ echo 'vfw is being spinned up, wait...'
+
+ while true
+ do
+ sleep 30
+ status = checkstatus $dev_id
+ if [ $status -eq "Active" ]; then
+ echo 'vfw is active now!'
+ break
+ done
+
+elif [ $result -gt 300 ]; then
+ echo 'error happens!'
+else
+ echo 'illegal json result!'
+fi
+
+
+