aboutsummaryrefslogtreecommitdiffstats
path: root/test/vcpe/sdcutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/vcpe/sdcutils.py')
-rwxr-xr-xtest/vcpe/sdcutils.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/test/vcpe/sdcutils.py b/test/vcpe/sdcutils.py
index a93872149..1a202b4cf 100755
--- a/test/vcpe/sdcutils.py
+++ b/test/vcpe/sdcutils.py
@@ -16,14 +16,14 @@ class SdcUtils:
self.logger.setLevel(logging.DEBUG)
self.vcpecommon = vcpecommon
- def get_service_list(self):
+ def download_vcpe_service_template(self):
"""
:return:
"""
url = self.vcpecommon.sdc_service_list_url
self.logger.info(url)
- r = requests.get(url, headers=self.vcpecommon.sdc_get_request_headers, auth=self.vcpecommon.sdc_get_request_userpass)
+ r = requests.get(url, headers=self.vcpecommon.sdc_be_request_headers, auth=self.vcpecommon.sdc_be_request_userpass)
self.logger.debug(r)
data = r.json()
@@ -34,9 +34,9 @@ class SdcUtils:
self.logger.debug('---------------------------------------------------------------')
for service in data:
- if service['name'].startswith('demoVCPE'):
+ if service['name'].startswith('demoVCPE') or service['name'].startswith('vCPEResCust'):
self.logger.debug('service name = %s, url = %s' % (service['name'], service['toscaModelURL']))
- self.download_file(self.vcpecommon.sdc_url_prefix + service['toscaModelURL'])
+ self.download_file(self.vcpecommon.sdc_be_url_prefix + service['toscaModelURL'])
def get_filename_from_cd(self, cd):
"""
@@ -48,7 +48,42 @@ class SdcUtils:
def download_file(self, url):
self.logger.info(url)
- response = requests.get(url, headers=self.vcpecommon.sdc_get_request_headers, auth=self.vcpecommon.sdc_get_request_userpass)
+ response = requests.get(url, headers=self.vcpecommon.sdc_be_request_headers, auth=self.vcpecommon.sdc_be_request_userpass)
filename = 'csar/' + self.get_filename_from_cd(response.headers.get('Content-Disposition'))
open(filename, 'wb').write(response.content)
+ def create_allotted_resource_subcategory(self, newSubcategory):
+ """
+ :param newSubcategory: a new subcategory under Allotted Resource, like BRG
+ :return:
+ """
+ url = self.vcpecommon.sdc_get_category_list_url
+ self.logger.info(url)
+ resp = requests.get(url, headers=self.vcpecommon.sdc_fe_request_headers, auth=self.vcpecommon.sdc_fe_request_userpass)
+ data = resp.json()
+
+ self.logger.debug('---------------------------------------------------------------')
+ self.logger.debug('------- Creation request submitted to SDC, got response --------')
+ self.logger.debug('response code = %s' % resp.status_code )
+ self.logger.debug(json.dumps(data, indent=4, sort_keys=True))
+ self.logger.debug('---------------------------------------------------------------')
+
+ if data['resourceCategories']:
+ for category in data['resourceCategories']:
+ if category['name'] == 'Allotted Resource':
+ for subcategory in category['subcategories']:
+ if subcategory['name'] == newSubcategory:
+ self.logger.debug('Subcategory %s already exists' % newSubcategory)
+ return
+ self.logger.debug('Creating a new subcategory %s' % newSubcategory)
+ url = self.vcpecommon.sdc_create_allotted_resource_subcategory_url
+ self.logger.info(url)
+ details = {"name" : newSubcategory}
+ resp = requests.post(url, headers=self.vcpecommon.sdc_fe_request_headers, auth=self.vcpecommon.sdc_fe_request_userpass, json=details)
+ self.logger.debug('---------------------------------------------------------------')
+ self.logger.debug('------- Creation subcategory request submitted to SDC, got response --------')
+ self.logger.debug('response code = %s' % resp.status_code )
+ self.logger.debug('---------------------------------------------------------------')
+
+
+