diff options
Diffstat (limited to 'test/vcpe')
-rw-r--r-- | test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json | 281 | ||||
-rw-r--r-- | test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json | 237 | ||||
-rw-r--r-- | test/vcpe/preload_templates/template_sniro_data.json | 3 | ||||
-rwxr-xr-x | test/vcpe/soutils.py | 31 | ||||
-rwxr-xr-x | test/vcpe/vcpe.py | 27 | ||||
-rwxr-xr-x | test/vcpe/vcpe_custom_service.py | 2 | ||||
-rwxr-xr-x | test/vcpe/vcpecommon.py | 162 |
7 files changed, 420 insertions, 323 deletions
diff --git a/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json b/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json index 12303f49a..9a9ecc37d 100644 --- a/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json +++ b/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json @@ -1,145 +1,138 @@ { - "VNF-API:input": { - "VNF-API:request-information": { - "VNF-API:request-id": "robot12", - "VNF-API:notification-url": "https://so.onap.org", - "VNF-API:order-number": "robot12", - "VNF-API:request-sub-action": "SUPP", - "VNF-API:request-action": "PreloadVNFRequest", - "VNF-API:source": "VID", - "VNF-API:order-version": "1.0" - }, - "VNF-API:sdnc-request-header": { - "VNF-API:svc-action": "reserve", - "VNF-API:svc-notification-url": "https://son.onap.org", - "VNF-API:svc-request-id": "robot12" - }, - "VNF-API:vnf-topology-information": { - "vnf-topology-identifier": { - "service-type": "${service_type}", - "vnf-type": "${vnf_type}", - "generic-vnf-name": "${generic_vnf_name}", - "generic-vnf-type": "${generic_vnf_type}", - "vnf-name": "${vnf_name}" - }, - "VNF-API:vnf-parameters": [ - - - { - "vnf-parameter-name": "vcpe_image_name", - "vnf-parameter-value": "vbrg-base-ubuntu-16-04-new" - }, - { - "vnf-parameter-name": "vcpe_flavor_name", - "vnf-parameter-value": "m1.medium" - }, - - { - "vnf-parameter-name": "public_net_id", - "vnf-parameter-value": "${public_net_id}" - }, - { - "vnf-parameter-name": "vbrgemu_bng_private_net_id", - "vnf-parameter-value": "${brg_bng_net}" - }, - { - "vnf-parameter-name": "vbrgemu_bng_private_subnet_id", - "vnf-parameter-value": "${brg_bng_subnet}" - }, - { - "vnf-parameter-name": "onap_private_net_id", - "vnf-parameter-value": "${oam_onap_net}" - }, - { - "vnf-parameter-name": "onap_private_subnet_id", - "vnf-parameter-value": "${oam_onap_subnet}" - }, - { - "vnf-parameter-name": "onap_private_net_cidr", - "vnf-parameter-value": "10.0.0.0/16" - }, - - { - "vnf-parameter-name": "compile_state", - "vnf-parameter-value": "done" - }, - { - "vnf-parameter-name": "vbrgemu_bng_private_net_cidr", - "vnf-parameter-value": "10.3.0.0/24" - }, - { - "vnf-parameter-name": "vbrgemu_private_ip_0", - "vnf-parameter-value": "10.3.0.14" - }, - { - "vnf-parameter-name": "sdnc_ip", - "vnf-parameter-value": "10.0.7.1" - }, - { - "vnf-parameter-name": "vbrgemu_name_0", - "vnf-parameter-value": "zdcpe1cpe01brgemu01_${suffix}" - }, - { - "vnf-parameter-name": "vnf_id", - "vnf-parameter-value": "vCPE_Infrastructure_BGREMU_demo_app" - }, - { - "vnf-parameter-name": "vf_module_id", - "vnf-parameter-value": "vCPE_Customer_BRGEMU" - }, - { - "vnf-parameter-name": "repo_url_blob", - "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw" - }, - { - "vnf-parameter-name": "repo_url_artifacts", - "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging" - }, - { - "vnf-parameter-name": "demo_artifacts_version", - "vnf-parameter-value": "1.1.1" - }, - { - "vnf-parameter-name": "install_script_version", - "vnf-parameter-value": "1.1.1" - }, - { - "vnf-parameter-name": "key_name", - "vnf-parameter-value": "vbrgemu_key" - }, - { - "vnf-parameter-name": "pub_key", - "vnf-parameter-value": "${pub_key}" - }, - { - "vnf-parameter-name": "cloud_env", - "vnf-parameter-value": "openstack" - }, - { - "vnf-parameter-name": "vpp_source_repo_url", - "vnf-parameter-value": "https://gerrit.fd.io/r/vpp" - }, - { - "vnf-parameter-name": "vpp_source_repo_branch", - "vnf-parameter-value": "stable/1704" - }, - { - "vnf-parameter-name": "hc2vpp_source_repo_url", - "vnf-parameter-value": "https://gerrit.fd.io/r/hc2vpp" - }, - { - "vnf-parameter-name": "hc2vpp_source_repo_branch", - "vnf-parameter-value": "stable/1704" - }, - { - "vnf-parameter-name": "vpp_patch_url", - "vnf-parameter-value": "https://git.onap.org/demo/plain/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch" - } - - ], - "VNF-API:vnf-assignments": { - } - } - } -} - + "VNF-API:input": { + "VNF-API:request-information": { + "VNF-API:notification-url": "https://so.onap.org", + "VNF-API:order-number": "robot12", + "VNF-API:order-version": "1.0", + "VNF-API:request-action": "PreloadVNFRequest", + "VNF-API:request-id": "robot12", + "VNF-API:request-sub-action": "SUPP", + "VNF-API:source": "VID" + }, + "VNF-API:sdnc-request-header": { + "VNF-API:svc-action": "reserve", + "VNF-API:svc-notification-url": "https://son.onap.org", + "VNF-API:svc-request-id": "robot12" + }, + "VNF-API:vnf-topology-information": { + "VNF-API:vnf-assignments": {}, + "VNF-API:vnf-parameters": [ + { + "vnf-parameter-name": "vcpe_image_name", + "vnf-parameter-value": "vbrg-base-ubuntu-16-04-new" + }, + { + "vnf-parameter-name": "vcpe_flavor_name", + "vnf-parameter-value": "m1.medium" + }, + { + "vnf-parameter-name": "public_net_id", + "vnf-parameter-value": "${public_net_id}" + }, + { + "vnf-parameter-name": "vbrgemu_bng_private_net_id", + "vnf-parameter-value": "${brg_bng_net}" + }, + { + "vnf-parameter-name": "vbrgemu_bng_private_subnet_id", + "vnf-parameter-value": "${brg_bng_subnet}" + }, + { + "vnf-parameter-name": "onap_private_net_id", + "vnf-parameter-value": "${oam_onap_net}" + }, + { + "vnf-parameter-name": "onap_private_subnet_id", + "vnf-parameter-value": "${oam_onap_subnet}" + }, + { + "vnf-parameter-name": "onap_private_net_cidr", + "vnf-parameter-value": "10.0.0.0/16" + }, + { + "vnf-parameter-name": "compile_state", + "vnf-parameter-value": "done" + }, + { + "vnf-parameter-name": "vbrgemu_bng_private_net_cidr", + "vnf-parameter-value": "10.3.0.0/24" + }, + { + "vnf-parameter-name": "vbrgemu_private_ip_0", + "vnf-parameter-value": "10.3.0.21" + }, + { + "vnf-parameter-name": "sdnc_ip", + "vnf-parameter-value": "10.0.7.1" + }, + { + "vnf-parameter-name": "vbrgemu_name_0", + "vnf-parameter-value": "zdcpe1cpe01brgemu01_${suffix}" + }, + { + "vnf-parameter-name": "vnf_id", + "vnf-parameter-value": "vCPE_Infrastructure_BGREMU_demo_app_${suffix}" + }, + { + "vnf-parameter-name": "vf_module_id", + "vnf-parameter-value": "vCPE_Customer_BRGEMU_${suffix}" + }, + { + "vnf-parameter-name": "repo_url_blob", + "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw" + }, + { + "vnf-parameter-name": "repo_url_artifacts", + "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging" + }, + { + "vnf-parameter-name": "demo_artifacts_version", + "vnf-parameter-value": "1.1.1" + }, + { + "vnf-parameter-name": "install_script_version", + "vnf-parameter-value": "1.1.1" + }, + { + "vnf-parameter-name": "key_name", + "vnf-parameter-value": "vbrgemu_key" + }, + { + "vnf-parameter-name": "pub_key", + "vnf-parameter-value": "${pub_key}" + }, + { + "vnf-parameter-name": "cloud_env", + "vnf-parameter-value": "openstack" + }, + { + "vnf-parameter-name": "vpp_source_repo_url", + "vnf-parameter-value": "https://gerrit.fd.io/r/vpp" + }, + { + "vnf-parameter-name": "vpp_source_repo_branch", + "vnf-parameter-value": "stable/1704" + }, + { + "vnf-parameter-name": "hc2vpp_source_repo_url", + "vnf-parameter-value": "https://gerrit.fd.io/r/hc2vpp" + }, + { + "vnf-parameter-name": "hc2vpp_source_repo_branch", + "vnf-parameter-value": "stable/1704" + }, + { + "vnf-parameter-name": "vpp_patch_url", + "vnf-parameter-value": "https://git.onap.org/demo/plain/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch" + } + ], + "vnf-topology-identifier": { + "generic-vnf-name": "${generic_vnf_name}", + "generic-vnf-type": "${generic_vnf_type}", + "service-type": "${service_type}", + "vnf-name": "${vnf_name}", + "vnf-type": "${vnf_type}" + } + } + } +}
\ No newline at end of file diff --git a/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json b/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json index 8b33482ab..d955a1d9c 100644 --- a/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json +++ b/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json @@ -1,121 +1,118 @@ { - "VNF-API:input": { - "VNF-API:request-information": { - "VNF-API:request-id": "robot12", - "VNF-API:notification-url": "https://so.onap.org", - "VNF-API:order-number": "robot12", - "VNF-API:request-sub-action": "SUPP", - "VNF-API:request-action": "PreloadVNFRequest", - "VNF-API:source": "VID", - "VNF-API:order-version": "1.0" - }, - "VNF-API:sdnc-request-header": { - "VNF-API:svc-action": "reserve", - "VNF-API:svc-notification-url": "https://son.onap.org", - "VNF-API:svc-request-id": "robot12" - }, - "VNF-API:vnf-topology-information": { - "vnf-topology-identifier": { - "service-type": "VGW-SERVICE-TYPE", - "vnf-type": "VGW-VNF-TYPE", - "generic-vnf-name": "GENERIC-VGW-VNF-NAME0", - "generic-vnf-type": "GENERIC-VGW-VNF-TYPE", - "vnf-name": "VGW2BRG-${brg_mac}" - }, - "VNF-API:vnf-parameters": [ - - { - "vnf-parameter-name": "public_net_id", - "vnf-parameter-value": "${public_net_id}" - }, - { - "vnf-parameter-name": "mux_gw_private_net_id", - "vnf-parameter-value": "${mux_gw_net}" - }, - { - "vnf-parameter-name": "mux_gw_private_subnet_id", - "vnf-parameter-value": "${mux_gw_subnet}" - }, - { - "vnf-parameter-name": "mux_gw_private_net_cidr", - "vnf-parameter-value": "10.5.0.0/24" - }, - { - "vnf-parameter-name": "cpe_public_net_id", - "vnf-parameter-value": "${cpe_public_net}" - }, - { - "vnf-parameter-name": "cpe_public_subnet_id", - "vnf-parameter-value": "${cpe_public_subnet}" - }, - { - "vnf-parameter-name": "cpe_public_net_cidr", - "vnf-parameter-value": "10.2.0.0/24" - }, - { - "vnf-parameter-name": "vgw_private_ip_0", - "vnf-parameter-value": "10.5.0.22" - }, - { - "vnf-parameter-name": "vgw_private_ip_1", - "vnf-parameter-value": "10.0.101.30" - }, - { - "vnf-parameter-name": "vgw_name_0", - "vnf-parameter-value": "zdcpe1cpe01gw01_${suffix}" - }, - { - "vnf-parameter-name": "mux_ip_addr", - "vnf-parameter-value": "10.5.0.21" - }, - { - "vnf-parameter-name": "vg_vgmux_tunnel_vni", - "vnf-parameter-value": "100" - }, - { - "vnf-parameter-name": "onap_private_net_id", - "vnf-parameter-value": "${oam_onap_net}" - }, - { - "vnf-parameter-name": "onap_private_subnet_id", - "vnf-parameter-value": "${oam_onap_subnet}" - }, - { - "vnf-parameter-name": "onap_private_net_cidr", - "vnf-parameter-value": "10.0.0.0/16" - }, - { - "vnf-parameter-name": "repo_url_blob", - "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw" - }, - { - "vnf-parameter-name": "repo_url_artifacts", - "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging" - }, - { - "vnf-parameter-name": "demo_artifacts_version", - "vnf-parameter-value": "1.1.1" - }, - { - "vnf-parameter-name": "install_script_version", - "vnf-parameter-value": "1.1.1" - }, - { - "vnf-parameter-name": "key_name", - "vnf-parameter-value": "vgw_key" - }, - { - "vnf-parameter-name": "pub_key", - "vnf-parameter-value": "${pub_key}" - }, - { - "vnf-parameter-name": "cloud_env", - "vnf-parameter-value": "openstack" - } - ], - "VNF-API:vnf-assignments": { - } - } - } -} - + "VNF-API:input": { + "VNF-API:request-information": { + "VNF-API:notification-url": "https://so.onap.org", + "VNF-API:order-number": "robot12", + "VNF-API:order-version": "1.0", + "VNF-API:request-action": "PreloadVNFRequest", + "VNF-API:request-id": "robot12", + "VNF-API:request-sub-action": "SUPP", + "VNF-API:source": "VID" + }, + "VNF-API:sdnc-request-header": { + "VNF-API:svc-action": "reserve", + "VNF-API:svc-notification-url": "https://son.onap.org", + "VNF-API:svc-request-id": "robot12" + }, + "VNF-API:vnf-topology-information": { + "VNF-API:vnf-assignments": {}, + "VNF-API:vnf-parameters": [ + { + "vnf-parameter-name": "public_net_id", + "vnf-parameter-value": "${public_net_id}" + }, + { + "vnf-parameter-name": "mux_gw_private_net_id", + "vnf-parameter-value": "${mux_gw_net}" + }, + { + "vnf-parameter-name": "mux_gw_private_subnet_id", + "vnf-parameter-value": "${mux_gw_subnet}" + }, + { + "vnf-parameter-name": "mux_gw_private_net_cidr", + "vnf-parameter-value": "10.5.0.0/24" + }, + { + "vnf-parameter-name": "cpe_public_net_id", + "vnf-parameter-value": "${cpe_public_net}" + }, + { + "vnf-parameter-name": "cpe_public_subnet_id", + "vnf-parameter-value": "${cpe_public_subnet}" + }, + { + "vnf-parameter-name": "cpe_public_net_cidr", + "vnf-parameter-value": "10.2.0.0/24" + }, + { + "vnf-parameter-name": "vgw_private_ip_0", + "vnf-parameter-value": "10.5.0.45" + }, + { + "vnf-parameter-name": "vgw_private_ip_1", + "vnf-parameter-value": "10.0.101.45" + }, + { + "vnf-parameter-name": "vgw_name_0", + "vnf-parameter-value": "zdcpe1cpe01gw01_${suffix}" + }, + { + "vnf-parameter-name": "mux_ip_addr", + "vnf-parameter-value": "10.5.0.21" + }, + { + "vnf-parameter-name": "vg_vgmux_tunnel_vni", + "vnf-parameter-value": "45" + }, + { + "vnf-parameter-name": "onap_private_net_id", + "vnf-parameter-value": "${oam_onap_net}" + }, + { + "vnf-parameter-name": "onap_private_subnet_id", + "vnf-parameter-value": "${oam_onap_subnet}" + }, + { + "vnf-parameter-name": "onap_private_net_cidr", + "vnf-parameter-value": "10.0.0.0/16" + }, + { + "vnf-parameter-name": "repo_url_blob", + "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw" + }, + { + "vnf-parameter-name": "repo_url_artifacts", + "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging" + }, + { + "vnf-parameter-name": "demo_artifacts_version", + "vnf-parameter-value": "1.1.1" + }, + { + "vnf-parameter-name": "install_script_version", + "vnf-parameter-value": "1.1.1" + }, + { + "vnf-parameter-name": "key_name", + "vnf-parameter-value": "vgw_key" + }, + { + "vnf-parameter-name": "pub_key", + "vnf-parameter-value": "${pub_key}" + }, + { + "vnf-parameter-name": "cloud_env", + "vnf-parameter-value": "openstack" + } + ], + "vnf-topology-identifier": { + "generic-vnf-name": "GENERIC-VGW-VNF-NAME0", + "generic-vnf-type": "GENERIC-VGW-VNF-TYPE", + "service-type": "VGW-SERVICE-TYPE", + "vnf-name": "VGW2BRG-${brg_mac}", + "vnf-type": "VGW-VNF-TYPE" + } + } + } +}
\ No newline at end of file diff --git a/test/vcpe/preload_templates/template_sniro_data.json b/test/vcpe/preload_templates/template_sniro_data.json index 6fa200395..92c9cc719 100644 --- a/test/vcpe/preload_templates/template_sniro_data.json +++ b/test/vcpe/preload_templates/template_sniro_data.json @@ -7,6 +7,7 @@ "resourceModuleName" : "${tunnelxconn_ar_name}", "serviceInstanceId" : "${vgmux_svc_instance_uuid}", "serviceResourceId" : "TUNNEL-RESOURCE-ID-REPLACE", + "isRehome" : "False", "assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }] }, { @@ -15,6 +16,7 @@ "resourceModuleName" : "${vgw_name}", "serviceInstanceId" : "vG-service-instance-id", "serviceResourceId" : "VGW-RESOURCE-ID-REPLACE", + "isRehome" : "False", "assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }] }, { @@ -23,6 +25,7 @@ "resourceModuleName" : "${brg_ar_name}", "serviceInstanceId" : "${vbrg_svc_instance_uuid}", "serviceResourceId" : "BRG-RESOURCE-ID-REPLACE", + "isRehome" : "False", "assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }] } ] diff --git a/test/vcpe/soutils.py b/test/vcpe/soutils.py index cc82068a6..623f12cc3 100755 --- a/test/vcpe/soutils.py +++ b/test/vcpe/soutils.py @@ -18,6 +18,7 @@ class SoUtils: :param vcpecommon: :param api_version: must be 'v4' or 'v5' """ + self.tmp_solution_for_so_bug = False self.logger = logging.getLogger(__name__) self.vcpecommon = vcpecommon if api_version not in self.vcpecommon.so_req_api_url: @@ -49,7 +50,9 @@ class SoUtils: self.logger.error('Invalid request type: {0}. Can only be service/vnf/network/vfmodule'.format(req_type)) return None, None + self.logger.info(url) r = requests.post(url, headers=self.vcpecommon.so_headers, auth=self.vcpecommon.so_userpass, json=req_json) + self.logger.debug(r) response = r.json() self.logger.debug('---------------------------------------------------------------') @@ -58,6 +61,7 @@ class SoUtils: self.logger.debug('---------------------------------------------------------------') req_id = response.get('requestReferences', {}).get('requestId', '') instance_id = response.get('requestReferences', {}).get('instanceId', '') + return req_id, instance_id def check_progress(self, req_id, eta=0, interval=5): @@ -119,7 +123,8 @@ class SoUtils: 'modelInfo': vnf_or_network_model, 'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name, "tenantId": self.vcpecommon.os_tenant_id}, - 'requestParameters': {"userParams": []} + 'requestParameters': {"userParams": []}, + 'platform': {"platformName": "Platform-Demonstration"} } self.add_req_info(req_details, instance_name, self.vcpecommon.product_family_id) self.add_related_instance(req_details, service_instance_id, service_model) @@ -149,14 +154,23 @@ class SoUtils: } } self.add_req_info(req_details, instance_name) + self.add_project_info(req_details) + self.add_owning_entity(req_details) return {'requestDetails': req_details} + def add_project_info(self, req_details): + req_details['project'] = {'projectName': self.vcpecommon.project_name} + + def add_owning_entity(self, req_details): + req_details['owningEntity'] = {'owningEntityId': self.vcpecommon.owning_entity_id, + 'owningEntityName': self.vcpecommon.owning_entity_name} + def generate_custom_service_request(self, instance_name, model, brg_mac): req_details = { 'modelInfo': model, 'subscriberInfo': {'subscriberName': 'Kaneohe', 'globalSubscriberId': self.vcpecommon.global_subscriber_id}, - 'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name, + 'cloudConfiguration': {"lcpCloudRegionId": 'CloudOwner_RegionOne', #self.vcpecommon.os_region_name, "tenantId": self.vcpecommon.os_tenant_id}, 'requestParameters': { "userParams": [ @@ -164,12 +178,23 @@ class SoUtils: 'name': 'BRG_WAN_MAC_Address', 'value': brg_mac } + , + { + "name": "Customer_Location", + "value": self.vcpecommon.customer_location_used_by_oof + }, + { + "name": "Homing_Solution", + "value": self.vcpecommon.homing_solution + } ], "subscriptionServiceType": "vCPE", 'aLaCarte': 'false' } } self.add_req_info(req_details, instance_name, self.vcpecommon.custom_product_family_id) + self.add_project_info(req_details) + self.add_owning_entity(req_details) return {'requestDetails': req_details} def create_custom_service(self, csar_file, brg_mac, name_suffix=None): @@ -186,7 +211,7 @@ class SoUtils: parser.svc_model['modelName'], name_suffix]) instance_name = instance_name.lower() req = self.generate_custom_service_request(instance_name, parser.svc_model, brg_mac) - self.logger.debug(json.dumps(req, indent=2, sort_keys=True)) + self.logger.info(json.dumps(req, indent=2, sort_keys=True)) self.logger.info('Creating custom service {0}.'.format(instance_name)) req_id, svc_instance_id = self.submit_create_req(req, 'service') if not self.check_progress(req_id, 140): diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py index 7de86ae8d..c4737296b 100755 --- a/test/vcpe/vcpe.py +++ b/test/vcpe/vcpe.py @@ -8,6 +8,7 @@ import preload import vcpe_custom_service import csar_parser import config_sdnc_so +import json def config_sniro(vcpecommon, vgmux_svc_instance_uuid, vbrg_svc_instance_uuid): @@ -49,13 +50,15 @@ def create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict, s so = soutils.SoUtils(vcpecommon, 'v4') return so.create_entire_service(csar_file, vnf_template_file, preload_dict, suffix, heatbridge) + def deploy_brg_only(): logging.basicConfig(level=logging.INFO, format='%(message)s') logger = logging.getLogger(__name__) vcpecommon = VcpeCommon() preload_dict = vcpecommon.load_preload_data() - name_suffix = preload_dict['${brg_bng_net}'].split('_')[-1] +# name_suffix = preload_dict['${brg_bng_net}'].split('_')[-1] + name_suffix = datetime.now().strftime('%Y%m%d%H%M') # create multiple services based on the pre-determined order svc_instance_uuid = vcpecommon.load_object(vcpecommon.svc_instance_uuid_file) @@ -63,6 +66,7 @@ def deploy_brg_only(): heatbridge = 'gmux' == keyword csar_file = vcpecommon.find_file(keyword, 'csar', 'csar') vnf_template_file = vcpecommon.find_file(keyword, 'json', 'preload_templates') + vcpecommon.increase_ip_address_or_vni_in_template(vnf_template_file, ['vbrgemu_private_ip_0']) svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict, name_suffix, heatbridge) if not svc_instance_uuid[keyword]: @@ -71,8 +75,8 @@ def deploy_brg_only(): # Setting up SNIRO config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg']) + def deploy_infra(): - logging.basicConfig(level=logging.INFO, format='%(message)s') logger = logging.getLogger(__name__) vcpecommon = VcpeCommon() @@ -127,12 +131,12 @@ def deploy_custom_service(): custom_service = vcpe_custom_service.CustomService(vcpecommon) # clean up - host_dic = {k: vcpecommon.hosts[k] for k in nodes} - if not vcpecommon.delete_vxlan_interfaces(host_dic): - sys.exit() + #host_dic = {k: vcpecommon.hosts[k] for k in nodes} + #if not vcpecommon.delete_vxlan_interfaces(host_dic): + # sys.exit() - custom_service.clean_up_sdnc() - custom_service.del_all_vgw_stacks(vcpecommon.vgw_name_keyword) + #custom_service.clean_up_sdnc() + #custom_service.del_all_vgw_stacks(vcpecommon.vgw_name_keyword) # create new service csar_file = vcpecommon.find_file('rescust', 'csar', 'csar') @@ -171,6 +175,15 @@ def init_so_sdnc(): config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon) +def tmp_sniro(): + logger = logging.getLogger(__name__) + + vcpecommon = VcpeCommon() + + svc_instance_uuid = vcpecommon.load_object(vcpecommon.svc_instance_uuid_file) + # Setting up SNIRO + config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg']) + if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(message)s') diff --git a/test/vcpe/vcpe_custom_service.py b/test/vcpe/vcpe_custom_service.py index d89129eef..af76803aa 100755 --- a/test/vcpe/vcpe_custom_service.py +++ b/test/vcpe/vcpe_custom_service.py @@ -72,6 +72,8 @@ class CustomService: # preload vGW if preload_dict: preloader = preload.Preload(self.vcpecommon) + parameters_to_change = ['vgw_private_ip_0', 'vgw_private_ip_1', 'vg_vgmux_tunnel_vni'] + self.vcpecommon.increase_ip_address_or_vni_in_template(vgw_template_file, parameters_to_change) preloader.preload_vgw(vgw_template_file, brg_mac, preload_dict, name_suffix) # create service diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py index 5b3e009a3..0213183e8 100755 --- a/test/vcpe/vcpecommon.py +++ b/test/vcpe/vcpecommon.py @@ -21,19 +21,19 @@ class VcpeCommon: # set the openstack cloud access credentials here cloud = { '--os-auth-url': 'http://10.12.25.2:5000', - '--os-username': 'YOUR ID', + '--os-username': 'kxi', '--os-user-domain-id': 'default', '--os-project-domain-id': 'default', - '--os-tenant-id': '087050388b204c73a3e418dd2c1fe30b', + '--os-tenant-id': '1e097c6713e74fd7ac8e4295e605ee1e', '--os-region-name': 'RegionOne', - '--os-password': 'YOUR PASSWD', - '--os-project-domain-name': 'Integration-SB-01', + '--os-password': 'n3JhGMGuDzD8', + '--os-project-domain-name': 'Integration-SB-07', '--os-identity-api-version': '3' } common_preload_config = { - 'oam_onap_net': 'oam_onap_c4Uw', - 'oam_onap_subnet': 'oam_onap_c4Uw', + 'oam_onap_net': 'oam_onap_lAky', + 'oam_onap_subnet': 'oam_onap_lAky', 'public_net': 'external', 'public_net_id': '971040b2-7059-49dc-b220-4fab50cb2ad4' } @@ -41,6 +41,7 @@ class VcpeCommon: ############################################################################################# template_variable_symbol = '${' + cpe_vm_prefix = 'zdcpe' ############################################################################################# # preloading network config # key=network role @@ -53,13 +54,17 @@ class VcpeCommon: 'mux_gw': ['10.5.0.10', '10.5.0.1'] } + dcae_ves_collector_name = 'dcae-bootstrap' global_subscriber_id = 'SDN-ETHERNET-INTERNET' + project_name = 'Project-Demonstration' + owning_entity_id = '520cc603-a3c4-4ec2-9ef4-ca70facd79c0' + owning_entity_name = 'OE-Demonstration' def __init__(self, extra_host_names=None): self.logger = logging.getLogger(__name__) self.logger.info('Initializing configuration') - self.host_names = ['so', 'sdnc', 'robot', 'aai-inst1', 'dcaedoks00'] + self.host_names = ['so', 'sdnc', 'robot', 'aai-inst1', self.dcae_ves_collector_name] if extra_host_names: self.host_names.extend(extra_host_names) # get IP addresses @@ -84,6 +89,13 @@ class VcpeCommon: self.common_preload_config['pub_key'] = self.pub_key self.sniro_url = 'http://' + self.hosts['robot'] + ':8080/__admin/mappings' self.sniro_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} + self.homing_solution = 'sniro' # value is either 'sniro' or 'oof' +# self.homing_solution = 'oof' + self.customer_location_used_by_oof = { + "customerLatitude": "32.897480", + "customerLongitude": "-97.040443", + "customerName": "some_company" + } ############################################################################################# # SDNC urls @@ -91,7 +103,7 @@ class VcpeCommon: self.sdnc_db_name = 'sdnctl' self.sdnc_db_user = 'sdnctl' self.sdnc_db_pass = 'gamma' - self.sdnc_db_port = '32768' + self.sdnc_db_port = '32774' self.sdnc_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} self.sdnc_preload_network_url = 'http://' + self.hosts['sdnc'] + \ ':8282/restconf/operations/VNF-API:preload-network-topology-operation' @@ -103,13 +115,13 @@ class VcpeCommon: # SO urls, note: do NOT add a '/' at the end of the url self.so_req_api_url = {'v4': 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/serviceInstances/v4', 'v5': 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/serviceInstances/v5'} - self.so_check_progress_api_url = 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/orchestrationRequests/v2' + self.so_check_progress_api_url = 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/orchestrationRequests/v5' self.so_userpass = 'InfraPortalClient', 'password1$' self.so_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} self.so_db_name = 'mso_catalog' self.so_db_user = 'root' self.so_db_pass = 'password' - self.so_db_port = '32768' + self.so_db_port = '32769' self.vpp_inf_url = 'http://{0}:8183/restconf/config/ietf-interfaces:interfaces' self.vpp_api_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} @@ -127,7 +139,8 @@ class VcpeCommon: def get_brg_mac_from_sdnc(self): """ - :return: BRG MAC address. Currently we only support one BRG instance. + Check table DHCP_MAP in the SDNC DB. Find the newly instantiated BRG MAC address. + Note that there might be multiple BRGs, the most recently instantiated BRG always has the largest IP address. """ cnx = mysql.connector.connect(user=self.sdnc_db_user, password=self.sdnc_db_pass, database=self.sdnc_db_name, host=self.hosts['sdnc'], port=self.sdnc_db_port) @@ -136,36 +149,30 @@ class VcpeCommon: cursor.execute(query) self.logger.debug('DHCP_MAP table in SDNC') - counter = 0 - mac = None + mac_recent = None + host = -1 for mac, ip in cursor: - counter += 1 self.logger.debug(mac + ':' + ip) + this_host = int(ip.split('.')[-1]) + if host < this_host: + host = this_host + mac_recent = mac cnx.close() - if counter != 1: - self.logger.error('Found %s MAC addresses in DHCP_MAP', counter) - sys.exit() - else: - self.logger.debug('Found MAC addresses in DHCP_MAP: %s', mac) - return mac + assert mac_recent + return mac_recent - def insert_into_sdnc_db(self, cmds): - cnx = mysql.connector.connect(user=self.sdnc_db_user, password=self.sdnc_db_pass, database=self.sdnc_db_name, - host=self.hosts['sdnc'], port=self.sdnc_db_port) - cursor = cnx.cursor() - for cmd in cmds: - self.logger.debug(cmd) - cursor.execute(cmd) - self.logger.debug('%s', cursor) - cnx.commit() - cursor.close() - cnx.close() + def execute_cmds_sdnc_db(self, cmds): + self.execute_cmds_db(cmds, self.sdnc_db_user, self.sdnc_db_pass, self.sdnc_db_name, + self.hosts['sdnc'], self.sdnc_db_port) + + def execute_cmds_so_db(self, cmds): + self.execute_cmds_db(cmds, self.so_db_user, self.so_db_pass, self.so_db_name, + self.hosts['so'], self.so_db_port) - def insert_into_so_db(self, cmds): - cnx = mysql.connector.connect(user=self.so_db_user, password=self.so_db_pass, database=self.so_db_name, - host=self.hosts['so'], port=self.so_db_port) + def execute_cmds_db(self, cmds, dbuser, dbpass, dbname, host, port): + cnx = mysql.connector.connect(user=dbuser, password=dbpass, database=dbname, host=host, port=port) cursor = cnx.cursor() for cmd in cmds: self.logger.debug(cmd) @@ -257,7 +264,7 @@ class VcpeCommon: url = 'https://{0}:8443/aai/v11/search/nodes-query?search-node-type={1}&filter={2}:EQUALS:{3}'.format( self.hosts['aai-inst1'], search_node_type, key, node_uuid) - headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'X-FromAppID': 'vCPE-Robot'} + headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'X-FromAppID': 'vCPE-Robot', 'X-TransactionId': 'get_aai_subscr'} requests.packages.urllib3.disable_warnings() r = requests.get(url, headers=headers, auth=self.aai_userpass, verify=False) response = r.json() @@ -298,24 +305,61 @@ class VcpeCommon: openstackcmd = 'nova ' + param + ' list' self.logger.debug(openstackcmd) - ip_dict = {} results = os.popen(openstackcmd).read() - for line in results.split('\n'): - fields = line.split('|') - if len(fields) == 8: - vm_name = fields[2] - ip_info = fields[-2] - for keyword in keywords: - if keyword in vm_name: - ip = self.extract_ip_from_str(net_addr, net_addr_len, ip_info) - if ip: - ip_dict[keyword] = ip + all_vm_ip_dict = self.extract_vm_ip_as_dict(results, net_addr, net_addr_len) + latest_vm_list = self.remove_old_vms(all_vm_ip_dict.keys(), self.cpe_vm_prefix) + latest_vm_ip_dict = {vm: all_vm_ip_dict[vm] for vm in latest_vm_list} + ip_dict = self.select_subset_vm_ip(latest_vm_ip_dict, keywords) + if len(ip_dict) != len(keywords): self.logger.error('Cannot find all desired IP addresses for %s.', keywords) self.logger.error(json.dumps(ip_dict, indent=4, sort_keys=True)) - sys.exit() + self.logger.error('Temporarily continue.. remember to check back vcpecommon.py line: 316') +# sys.exit() return ip_dict + def extract_vm_ip_as_dict(self, novalist_results, net_addr, net_addr_len): + vm_ip_dict = {} + for line in novalist_results.split('\n'): + fields = line.split('|') + if len(fields) == 8: + vm_name = fields[2] + ip_info = fields[-2] + ip = self.extract_ip_from_str(net_addr, net_addr_len, ip_info) + vm_ip_dict[vm_name] = ip + + return vm_ip_dict + + def remove_old_vms(self, vm_list, prefix): + """ + For vms with format name_timestamp, only keep the one with the latest timestamp. + E.g., + zdcpe1cpe01brgemu01_201805222148 (drop this) + zdcpe1cpe01brgemu01_201805222229 (keep this) + zdcpe1cpe01gw01_201805162201 + """ + new_vm_list = [] + same_type_vm_dict = {} + for vm in vm_list: + fields = vm.split('_') + if vm.startswith(prefix) and len(fields) == 2 and len(fields[-1]) == len('201805222148') and fields[-1].isdigit(): + if vm > same_type_vm_dict.get(fields[0], '0'): + same_type_vm_dict[fields[0]] = vm + else: + new_vm_list.append(vm) + + new_vm_list.extend(same_type_vm_dict.values()) + return new_vm_list + + def select_subset_vm_ip(self, all_vm_ip_dict, vm_name_keyword_list): + vm_ip_dict = {} + for keyword in vm_name_keyword_list: + for vm, ip in all_vm_ip_dict.items(): + if keyword in vm: + vm_ip_dict[keyword] = ip + break + return vm_ip_dict + def del_vgmux_ves_mode(self): url = self.vpp_ves_url.format(self.hosts['mux']) + '/mode' r = requests.delete(url, headers=self.vpp_api_headers, auth=self.vpp_api_userpass) @@ -329,8 +373,8 @@ class VcpeCommon: def set_vgmux_ves_collector(self ): url = self.vpp_ves_url.format(self.hosts['mux']) data = {'config': - {'server-addr': self.hosts['dcaedoks00'], - 'server-port': '8080', + {'server-addr': self.hosts[self.dcae_ves_collector_name], + 'server-port': '8081', 'read-interval': '10', 'is-add':'1' } @@ -400,6 +444,26 @@ class VcpeCommon: with open(filepathname, 'rb') as fin: return pickle.load(fin) + @staticmethod + def increase_ip_address_or_vni_in_template(vnf_template_file, vnf_parameter_name_list): + with open(vnf_template_file) as json_input: + json_data = json.load(json_input) + param_list = json_data['VNF-API:input']['VNF-API:vnf-topology-information']['VNF-API:vnf-parameters'] + for param in param_list: + if param['vnf-parameter-name'] in vnf_parameter_name_list: + ipaddr_or_vni = param['vnf-parameter-value'].split('.') + number = int(ipaddr_or_vni[-1]) + if 254 == number: + number = 10 + else: + number = number + 1 + ipaddr_or_vni[-1] = str(number) + param['vnf-parameter-value'] = '.'.join(ipaddr_or_vni) + + assert json_data is not None + with open(vnf_template_file, 'w') as json_output: + json.dump(json_data, json_output, indent=4, sort_keys=True) + def save_preload_data(self, preload_data): self.save_object(preload_data, self.preload_dict_file) |