aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2019-04-30 19:18:21 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-30 19:18:21 +0000
commit7c5fc1b556b3310ea4d77bb44a22dcb9e02d8d55 (patch)
tree9cee4e2f6e346152a33c3de3d0d289115dd891f1 /test
parent7e8354540b4c6e6b9b97a1fa3121a48dfa394aae (diff)
parent0e319ef66c3172ae1aef36151b32b8bf9ceacf74 (diff)
Merge "Add allotted resource subcategory BRG in SDC"
Diffstat (limited to 'test')
-rwxr-xr-xtest/vcpe/sdcutils.py45
-rwxr-xr-xtest/vcpe/vcpe.py22
-rwxr-xr-xtest/vcpe/vcpecommon.py17
3 files changed, 69 insertions, 15 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('---------------------------------------------------------------')
+
+
+
diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py
index f9c1778da..375a04e12 100755
--- a/test/vcpe/vcpe.py
+++ b/test/vcpe/vcpe.py
@@ -183,10 +183,22 @@ def init_so_sdnc():
vgw_vfmod_name_index= 0
vcpecommon.save_object(vgw_vfmod_name_index, vcpecommon.vgw_vfmod_name_index_file)
-def download_vcpe_service_templates():
+
+def init():
vcpecommon = VcpeCommon()
+ init_sdc(vcpecommon)
+ download_vcpe_service_templates(vcpecommon)
+
+
+def init_sdc(vcpecommon):
sdc = sdcutils.SdcUtils(vcpecommon)
- sdc.get_service_list()
+ sdc.create_allotted_resource_subcategory('BRG')
+
+
+def download_vcpe_service_templates(vcpecommon):
+ sdc = sdcutils.SdcUtils(vcpecommon)
+ sdc.download_vcpe_service_template()
+
def tmp_sniro():
logger = logging.getLogger(__name__)
@@ -197,10 +209,12 @@ def tmp_sniro():
# Setting up SNIRO
config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg'])
+
def test():
vcpecommon = VcpeCommon()
print("oom-k8s-04 public ip: %s" % (vcpecommon.get_vm_public_ip_by_nova('oom-k8s-04')))
+
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
@@ -220,9 +234,7 @@ if __name__ == '__main__':
if sys.argv[1] == 'sdc':
print('Under development')
elif sys.argv[1] == 'init':
- if 'y' == raw_input('Ready to add customer service data to SDNC and SO DBs? This is needed only once.'
- 'y/n: ').lower():
- download_vcpe_service_templates()
+ init()
init_so_sdnc()
elif sys.argv[1] == 'infra':
if 'y' == raw_input('Ready to deploy infrastructure? y/n: ').lower():
diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py
index 77e362271..47ba23851 100755
--- a/test/vcpe/vcpecommon.py
+++ b/test/vcpe/vcpecommon.py
@@ -132,11 +132,18 @@ class VcpeCommon:
#############################################################################################
# SDC urls
- self.sdc_get_request_userpass = 'vid','Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U'
- self.sdc_get_request_headers = {'X-ECOMP-InstanceID': 'VID'}
- self.sdc_port = '30205'
- self.sdc_url_prefix = 'http://' + self.hosts['sdc'] + ':' + self.sdc_port
- self.sdc_service_list_url = self.sdc_url_prefix + '/sdc/v1/catalog/services'
+ self.sdc_be_port = '30205'
+ self.sdc_be_request_userpass = 'vid', 'Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U'
+ self.sdc_be_request_headers = {'X-ECOMP-InstanceID': 'VID'}
+ self.sdc_be_url_prefix = 'http://' + self.hosts['sdc'] + ':' + self.sdc_be_port
+ self.sdc_service_list_url = self.sdc_be_url_prefix + '/sdc/v1/catalog/services'
+
+ self.sdc_fe_port = '30206'
+ self.sdc_fe_request_userpass = 'beep', 'boop'
+ self.sdc_fe_request_headers = {'USER_ID': 'demo', 'Content-Type': 'application/json'}
+ self.sdc_fe_url_prefix = 'http://' + self.hosts['sdc'] + ':' + self.sdc_fe_port
+ self.sdc_get_category_list_url = self.sdc_fe_url_prefix + '/sdc1/feProxy/rest/v1/categories'
+ self.sdc_create_allotted_resource_subcategory_url = self.sdc_fe_url_prefix + '/sdc1/feProxy/rest/v1/category/resources/resourceNewCategory.allotted%20resource/subCategory'
#############################################################################################
# SDNC urls