aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKang Xi <kang.xi@huawei.com>2018-05-30 09:27:34 -0400
committerKang Xi <kang.xi@huawei.com>2018-05-30 09:30:21 -0400
commit6c76239eea08066bdaf352326e92b161904cf1a1 (patch)
treea325334384db34774434d32e71428b4b3d5c8c11
parent8053f360cab41003739bb3023b63027aa4cb60be (diff)
Support multiple customer instantiation
Issue-ID: INT-509 Change-Id: I64a934b516f2290812f39c0df2a0d35027a5d553 Signed-off-by: Kang Xi <kang.xi@huawei.com>
-rw-r--r--test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json281
-rw-r--r--test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json237
-rw-r--r--test/vcpe/preload_templates/template_sniro_data.json3
-rwxr-xr-xtest/vcpe/vcpe.py27
-rwxr-xr-xtest/vcpe/vcpe_custom_service.py2
-rwxr-xr-xtest/vcpe/vcpecommon.py124
6 files changed, 367 insertions, 307 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/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 cac5219ea..0213183e8 100755
--- a/test/vcpe/vcpecommon.py
+++ b/test/vcpe/vcpecommon.py
@@ -41,6 +41,7 @@ class VcpeCommon:
#############################################################################################
template_variable_symbol = '${'
+ cpe_vm_prefix = 'zdcpe'
#############################################################################################
# preloading network config
# key=network role
@@ -120,7 +121,7 @@ class VcpeCommon:
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'}
@@ -138,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)
@@ -147,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 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_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 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)
@@ -309,18 +305,12 @@ 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))
@@ -328,6 +318,48 @@ class VcpeCommon:
# 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)
@@ -412,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)