Update test scripts of ns msb_upload 01/95101/2
authoryangyan <yangyanyj@chinamobile.com>
Fri, 6 Sep 2019 02:20:58 +0000 (10:20 +0800)
committeryangyan <yangyanyj@chinamobile.com>
Fri, 6 Sep 2019 02:55:13 +0000 (10:55 +0800)
Change-Id: If5c9a05275c8ab89c7b6f3fe5d415d2ba227e797
Issue-ID: VFC-1510
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
resources/testscripts/ns/Instructions [new file with mode: 0644]
resources/testscripts/ns/msb_create.py [new file with mode: 0644]
resources/testscripts/ns/msb_del.py [new file with mode: 0644]
resources/testscripts/ns/msb_get.py [new file with mode: 0644]
resources/testscripts/ns/msb_upload.py [new file with mode: 0644]

diff --git a/resources/testscripts/ns/Instructions b/resources/testscripts/ns/Instructions
new file mode 100644 (file)
index 0000000..9c40834
--- /dev/null
@@ -0,0 +1,14 @@
+
+# msb_create
+The Python script in this folder is used to register ns to msb.
+ It mainly includes the creation, upload, query acquisition and deletion of msb.
+# msb_upload
+When you execute the msb_create script, you get an ID. At this time, you open the msb_upload script,
+change the file path to the path where you want to upload the CSAR package,
+then execute the msb_upload script and place the ID after executing the command,
+and the ID will be automatically passed in.
+# msb_get
+If you want to query the registration status in msb, you can execute the msb_get script directly.
+# msb_del
+If you want to delete an MSB record, you can execute the msb_del script and put the ID generated
+at the time of creation after execution of the command.
\ No newline at end of file
diff --git a/resources/testscripts/ns/msb_create.py b/resources/testscripts/ns/msb_create.py
new file mode 100644 (file)
index 0000000..cc8b610
--- /dev/null
@@ -0,0 +1,10 @@
+import json
+import httplib2
+ud_data = {'userDefinedData': {"key1": "value1"}}
+headers = {'content-type': 'application/json', 'accept': 'application/json'}
+http = httplib2.Http()
+resp, resp_content = http.request('http://172.30.3.104:30280/api/nsd/v1/ns_descriptors',
+                                  method="POST",
+                                  body=json.dumps(ud_data),
+                                  headers=headers)
+print(resp['status'], resp_content)
diff --git a/resources/testscripts/ns/msb_del.py b/resources/testscripts/ns/msb_del.py
new file mode 100644 (file)
index 0000000..5765773
--- /dev/null
@@ -0,0 +1,6 @@
+import requests
+import sys
+create_id = sys.argv[1]
+
+resp = requests.delete('http://10.12.5.131:30280/api/nsd/v1/ns_descriptors/' + create_id)
+print(resp.status_code)
diff --git a/resources/testscripts/ns/msb_get.py b/resources/testscripts/ns/msb_get.py
new file mode 100644 (file)
index 0000000..575bf8c
--- /dev/null
@@ -0,0 +1,3 @@
+import requests
+resp = requests.get('http://10.12.5.131:30280/api/nsd/v1/ns_descriptors')
+print(resp.status_code, resp.json())
diff --git a/resources/testscripts/ns/msb_upload.py b/resources/testscripts/ns/msb_upload.py
new file mode 100644 (file)
index 0000000..82abfb3
--- /dev/null
@@ -0,0 +1,7 @@
+import requests
+import sys
+create_id = sys.argv[1]
+
+url = 'http://10.12.5.131:30280/api/nsd/v1/ns_descriptors/' + create_id + '/nsd_content'
+resp = requests.put(url, files={'file': open(r"/home/ubuntu/test/test/ns/ns_vgw.csar", 'rb')})
+print(resp.status_code)