--- /dev/null
+
+# 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 ns 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_download
+
+By executing this script, you can access the catalog parsing interface and get the parsing content of the
+ uploaded ns package
+
+# msb_get
+If you want to query the registration status in msb, you can execute the msb_get script directly.
+
+# msb_delete
+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.
+
+Note: You should configure the IP and CSAR file path of MSB in const file
+ IP address for MSB service
+ MSB cannot be created repeatedly
+ The request mode of MSB is HTTPS, and the port of public IP is 30283
import json
import httplib2
-full_url = 'https://192.168.235.89:30283/api/nsd/v1/ns_descriptors'
+from testscripts.const import MSB_BASE_URL
+
+full_url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors'
ud_data = {'userDefinedData': {"key2": "value2"}}
headers = {'content-type': 'application/json', 'accept': 'application/json'}
ca_certs = None
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-resp = requests.delete('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/' + id, verify=False)
+resp = requests.delete(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id, verify=False)
print(resp.status_code)
--- /dev/null
+import requests
+import sys
+
+from testscripts.const import MSB_BASE_URL, NS_CSAR_PATH
+
+id = sys.argv[1]
+url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id + '/nsd_content'
+resp = requests.get(url)
+local_file = open(NS_CSAR_PATH, 'wb')
+local_file.write(resp.content)
+local_file.close()
import requests
+from testscripts.const import MSB_BASE_URL
+
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors', verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors', verify=False)
print(resp.status_code, resp.json())
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/' + id, verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id, verify=False)
print(resp.status_code, resp.json())
import requests
+import sys
+from testscripts.const import MSB_BASE_URL, NS_CSAR_PATH
+
+id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-url = 'https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/84090010-6e67-4536-81cc-61ae7b0b4ecd/nsd_content'
-resp = requests.put(url, files={'file': open(r"C:\Users\86187\Desktop\vfc-tests\ns\ns-new\ns_vgw.csar", 'rb')}, verify=False)
+url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/ + id /nsd_content'
+resp = requests.put(url, files={'file': open(NS_CSAR_PATH, 'rb')}, verify=False)
print(resp.status_code)
import json
import httplib2
+from testscripts.const import MSB_BASE_URL, GLOBAL_CUSTOMER_Id, SERVICE_TYPE, CSAR_ID, NS_NAME, DESCRIPTION
+
data = {
"context": {
- "globalCustomerId": "global-customer-id-test1",
- "serviceType": "service-type-test1"
+ "globalCustomerId": GLOBAL_CUSTOMER_Id,
+ "serviceType": SERVICE_TYPE
},
- "csarId": "d5d678dc-80ef-461e-8630-d105f43b0a18",
- "nsName": "ns_vsn",
- "description": "description"
+ "csarId": CSAR_ID,
+ "nsName": NS_NAME,
+ "description": DESCRIPTION
}
-full_url = 'https://192.168.235.89:30283/api/nslcm/v1/ns'
+full_url = MSB_BASE_URL + '/api/nslcm/v1/ns'
headers = {'content-type': 'application/json', 'accept': 'application/json'}
ca_certs = None
auth_type = "rest_no_auth"
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
+requests.packages.urllib3.disable_warnings()
id = sys.argv[1]
-resp = requests.delete('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id, verify=False)
+resp = requests.delete(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id, verify=False)
print(resp.status_code)
import requests
+from testscripts.const import MSB_BASE_URL
+
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/ns', verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/ns', verify=False)
print(resp.status_code, resp.json())
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
requests.packages.urllib3.disable_warnings()
jobId = '1'
if len(sys.argv) > 1:
jobId = sys.argv[1]
-resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/jobs/%s' % jobId, verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/jobs/%s' % jobId, verify=False)
print(resp.status_code, resp.json())
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id, verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id, verify=False)
print(resp.status_code, resp.json())
import json
import httplib2
import sys
+
+from testscripts.const import VNF_PROFILE_ID, VIM_ID, MSB_BASE_URL
+
ns_instance_Id = sys.argv[1]
data = {
"additionalParamForNs": {
"sdnControllerId": "2"
},
"locationConstraints": [{
- "vnfProfileId": "45711f40-3f43-415b-bb45-46e5c6940735",
+ "vnfProfileId": VNF_PROFILE_ID,
"locationConstraints": {
- "vimId": "CPE-DC_RegionOne"
+ "vimId": VIM_ID
}
}]
}
auth_type = "rest_no_auth"
http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == "rest_no_auth"))
http.follow_all_redirects = True
-resp, resp_content = http.request('https://192.168.235.89:30283/api/nslcm/v1/ns/' + ns_instance_Id + '/instantiate',
+resp, resp_content = http.request(MSB_BASE_URL + '/api/nslcm/v1/ns/' + ns_instance_Id + '/instantiate',
method="POST", body=json.dumps(data), headers=headers)
print(resp['status'], resp_content)
--- /dev/null
+This process is ns instantiation process
+When the NS and vnf packages are uploaded and the MSB is registered successfully.
+the instantiation operation begins.
+This process mainly includes ns creation, instantiation, information query acquisition,
+instance termination and data deletion after termination.
+
+# create
+
+Prepare the data before instance creation according to your needs,
+and replace the CSAR ID generated after uploading package management.
+When the execution is completed, an instance ID and other data are returned.
+
+# instance
+
+This process also prepares the data according to the requirement of creating the instance itself,
+returns the instance ID after executing the create script,
+and then executes the script after executing the script command. At this point,
+the instance ID will be passed into the script, and a series of instantiation operations will be started,
+and the virtual machine will be created.
+
+# get
+
+If you want to get some data generated during instance creation, you can execute the script
+The script can query all the instance information in the database.
+
+# get_one
+
+If you want to get some instance data during instance creation, you can execute the script
+The script only queries the content of an instance information,
+executes the script command and puts the created instance ID after the command,
+then the query can be completed.
+
+# terminate
+
+After the instantiation process is successfully created,
+if you want to terminate the instantiation, execute the script.
+The virtual machine generated after the script execution will also stop,
+as well as some data deletion, termination of services.
+After the script command is executed, the instance ID needs to be added after the command.
+
+# delete
+
+Some data will remain after termination. Execute the script to clear the data in the database.
+The instance ID is also required to execute this process.
+The completion of this process indicates the end of an instance creation termination process.
+
+Note: You should configure the IP and CSAR file path of MSB in const file
+ IP address for MSB service
+ NS cannot be created repeatedly
+ Update test scripts of ns_instance
+ The request mode of MSB is HTTPS, and the port of public IP is 30283
import httplib2
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
data = {
"gracefulTerminationTimeout": 600,
auth_type = "rest_no_auth"
http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == "rest_no_auth"))
http.follow_all_redirects = True
-resp, resp_content = http.request('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id + '/terminate',
+resp, resp_content = http.request(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id + '/terminate',
method="POST",
body=json.dumps(data),
headers=headers)
--- /dev/null
+
+# msb_create
+The Python script in this folder is used to register vnf to msb.
+It mainly includes the creation, upload, query acquisition and deletion of msb.
+
+# msb_upload
+When the msb_create script is executed, an ID is obtained.
+At this time, the msb_upload script is opened, the file path is changed to the path of the CSAR package
+you want to upload vnf. Then the msb_upload script is executed and the ID is placed after the
+command is executed, and the ID is automatically passed in.
+
+# msb_download
+
+By executing this script, you can access the catalog parsing interface and get the parsing content of the
+ uploaded vnf package
+
+# msb_get
+If you want to query the registration status in msb, you can execute the msb_get script directly.
+
+# msb_delete
+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.
+
+Note: You should configure the IP and CSAR file path of MSB in const file
+ IP address for MSB service
+ MSB cannot be created repeatedly
+ The request mode of MSB is HTTPS, and the port of public IP is 30283
\ No newline at end of file
import json
import httplib2
-full_url = 'https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages'
+from testscripts.const import MSB_BASE_URL
+
+full_url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages'
ud_data = {'userDefinedData': {"key2": "value2"}}
headers = {'content-type': 'application/json', 'accept': 'application/json'}
ca_certs = None
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-resp = requests.delete('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id, verify=False)
+resp = requests.delete(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id, verify=False)
print(resp.status_code)
--- /dev/null
+import requests
+import sys
+
+from testscripts.const import MSB_BASE_URL, VNF_CSAR_PATH
+
+requests.packages.urllib3.disable_warnings()
+id = sys.argv[1]
+url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content'
+resp = requests.get(url, verify=False)
+local_file = open(VNF_CSAR_PATH, 'wb')
+local_file.write(resp.content)
+local_file.close()
import requests
+from testscripts.const import MSB_BASE_URL
+
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages', verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages', verify=False)
print(resp.status_code, resp.json())
import requests
import sys
+from testscripts.const import MSB_BASE_URL
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-resp = requests.get('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id, verify=False)
+resp = requests.get(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id, verify=False)
print(resp.status_code, resp.json())
import requests
import sys
+from testscripts.const import MSB_BASE_URL, VNF_CSAR_PATH
+
id = sys.argv[1]
requests.packages.urllib3.disable_warnings()
-url = 'https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content'
-resp = requests.put(url, files={'file': open(r"C:\Users\86187\Desktop\vfc-tests\vgw.csar", 'rb')}, verify=False)
+url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content'
+resp = requests.put(url, files={'file': open(VNF_CSAR_PATH, 'rb')}, verify=False)
print(resp.status_code)
--- /dev/null
+MSB_BASE_URL = "You should change it according to your environment"
+NS_CSAR_PATH = r"You should change it according to your environment"
+VNF_CSAR_PATH = r"You should change it according to your environment"
+GLOBAL_CUSTOMER_Id = "You should change it according to your environment"
+SERVICE_TYPE = "You should change it according to your environment"
+CSAR_ID = "You should change it according to your environment"
+NS_NAME = "You should change it according to your environment"
+DESCRIPTION = "description"
+VNF_PROFILE_ID = "You should change it according to your environment"
+VIM_ID = "You should change it according to your environment"