From d7b47097ce93f7cfd394bafb012ccf8590f5d4a4 Mon Sep 17 00:00:00 2001 From: yangyan Date: Fri, 6 Sep 2019 10:20:58 +0800 Subject: Update test scripts of ns msb_upload Change-Id: If5c9a05275c8ab89c7b6f3fe5d415d2ba227e797 Issue-ID: VFC-1510 Signed-off-by: yangyan --- resources/testscripts/ns/Instructions | 14 ++++++++++++++ resources/testscripts/ns/msb_create.py | 10 ++++++++++ resources/testscripts/ns/msb_del.py | 6 ++++++ resources/testscripts/ns/msb_get.py | 3 +++ resources/testscripts/ns/msb_upload.py | 7 +++++++ 5 files changed, 40 insertions(+) create mode 100644 resources/testscripts/ns/Instructions create mode 100644 resources/testscripts/ns/msb_create.py create mode 100644 resources/testscripts/ns/msb_del.py create mode 100644 resources/testscripts/ns/msb_get.py create mode 100644 resources/testscripts/ns/msb_upload.py diff --git a/resources/testscripts/ns/Instructions b/resources/testscripts/ns/Instructions new file mode 100644 index 00000000..9c408348 --- /dev/null +++ b/resources/testscripts/ns/Instructions @@ -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 index 00000000..cc8b610c --- /dev/null +++ b/resources/testscripts/ns/msb_create.py @@ -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 index 00000000..5765773b --- /dev/null +++ b/resources/testscripts/ns/msb_del.py @@ -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 index 00000000..575bf8ca --- /dev/null +++ b/resources/testscripts/ns/msb_get.py @@ -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 index 00000000..82abfb36 --- /dev/null +++ b/resources/testscripts/ns/msb_upload.py @@ -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) -- cgit 1.2.3-korg