From 9b51423f989c895744e983e3a76718fb3112415b Mon Sep 17 00:00:00 2001 From: Haibin Huang Date: Thu, 9 May 2019 14:36:05 +0800 Subject: Add E2E automation test vcpe Change-Id: I73ab75ee9321c8b360745a963f28b0a869a279ea Issue-ID: INT-795 Signed-off-by: Haibin Huang --- test/hpa_automation/heat/hpa_automation.py | 483 +++++++++++++++++++++ .../hpa_automation/heat/hpa_automation_config.json | 178 ++++++++ test/hpa_automation/hpa_automation.py | 483 --------------------- test/hpa_automation/hpa_automation_config.json | 178 -------- test/hpa_automation/tosca/hpa_automation.py | 183 ++++++++ test/hpa_automation/tosca/vcpe_config.json | 139 ++++++ 6 files changed, 983 insertions(+), 661 deletions(-) create mode 100755 test/hpa_automation/heat/hpa_automation.py create mode 100755 test/hpa_automation/heat/hpa_automation_config.json delete mode 100644 test/hpa_automation/hpa_automation.py delete mode 100644 test/hpa_automation/hpa_automation_config.json create mode 100755 test/hpa_automation/tosca/hpa_automation.py create mode 100755 test/hpa_automation/tosca/vcpe_config.json (limited to 'test') diff --git a/test/hpa_automation/heat/hpa_automation.py b/test/hpa_automation/heat/hpa_automation.py new file mode 100755 index 000000000..1bbf3a40d --- /dev/null +++ b/test/hpa_automation/heat/hpa_automation.py @@ -0,0 +1,483 @@ +#!/usr/bin/python + +#Prerequisites for machine to run this +#Put in required parameters in hpa_automation_config.json +#Install python-pip (apt install python-pip) +#Install python mysql.connector (pip install mysql-connector-python) +#Install ONAP CLI +#Must have connectivity to the ONAP, a k8s vm already running is recommended +#Create Preload File, the script will modify the parameters required from serivce model, service instance +#and vnf instance +#Create policies for homing +#Put in CSAR file +#modify so-bpmn configmap and change version to v2 + +import json +import os +import mysql.connector as mariadb +import time + + +def get_parameters(file): + parameters = json.load(file) + return parameters + +def set_open_cli_env(parameters): + os.environ["OPEN_CLI_PRODUCT_IN_USE"] = parameters["open_cli_product"] + os.environ["OPEN_CLI_HOME"] = parameters["open_cli_home"] + +def create_complex(parameters): + complex_create_string = "oclip complex-create -j {} -r {} -x {} -y {} -lt {} -l {} -i {} -lo {} \ + -S {} -la {} -g {} -w {} -z {} -k {} -o {} -q {} -m {} -u {} -p {}".format(parameters["street2"], \ + parameters["physical_location"], parameters["complex_name"], \ + parameters["data_center_code"], parameters["latitude"], parameters["region"], \ + parameters["street1"], parameters["longitude"], parameters["state"], \ + parameters["lata"], parameters["city"], parameters["postal-code"], \ + parameters["complex_name"], parameters["country"], parameters["elevation"], \ + parameters["identity_url"], parameters["aai_url"], parameters["aai_username"], \ + parameters["aai_password"]) + + os.system(complex_create_string) + + +def register_cloud_helper(cloud_region, values, parameters): + #Create Cloud + cloud_create_string = 'oclip cloud-create -e {} -b {} -I {{\\\\\\"openstack-region-id\\\\\\":\\\\\\"{}\\\\\\"}} \ + -x {} -y {} -j {} -w {} -l {} -url {} -n {} -q {} -r {} -Q {} -i {} -g {} -z {} -k {} -c {} -m {} -u {} -p {}'.format( + values.get("esr-system-info-id"), values.get("user-name"), cloud_region, parameters["cloud-owner"], \ + cloud_region, values.get("password"), values.get("cloud-region-version"), values.get("default-tenant"), \ + values.get("service-url"), parameters["complex_name"], values.get("cloud-type"), parameters["owner-defined-type"], \ + values.get("system-type"), values.get("identity-url"), parameters["cloud-zone"], values.get("ssl-insecure"), \ + values.get("system-status"), values.get("cloud-domain"), parameters["aai_url"], parameters["aai_username"], \ + parameters["aai_password"]) + + + os.system(cloud_create_string) + + #Associate Cloud with complex + complex_associate_string = "oclip complex-associate -x {} -y {} -z {} -m {} -u {} -p {}".format(parameters["complex_name"], \ + cloud_region, parameters["cloud-owner"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) + os.system(complex_associate_string) + + #Register Cloud with Multicloud + multicloud_register_string = "oclip multicloud-register-cloud -y {} -x {} -m {}".format(parameters["cloud-owner"], \ + cloud_region, parameters["multicloud_url"]) + os.system(multicloud_register_string) + +def register_all_clouds(parameters): + cloud_dictionary = parameters["cloud_region_data"] + for cloud_region, cloud_region_values in cloud_dictionary.iteritems(): + register_cloud_helper(cloud_region, cloud_region_values, parameters) + +def create_service_type(parameters): + create_string = "oclip service-type-create -x {} -m {} -u {} -p {}".format( parameters["service_name"], \ + parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) + os.system(create_string) + +def create_customer(parameters): + create_string = "oclip customer-create -x {} -y {} -m {} -u {} -p {}".format( parameters["customer_name"], \ + parameters["subscriber_name"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) + os.system(create_string) + +def add_customer_subscription(parameters): + subscription_check = 0 + for cloud_region, cloud_region_values in (parameters["cloud_region_data"]).iteritems(): + if subscription_check == 0 : + subscription_string = "oclip subscription-create -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ + parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ + cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) + else: + subscription_string = "oclip subscription-cloud-add -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ + parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ + cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) + os.system(subscription_string) + subscription_check+=1 + +def get_out_helper(in_string): + out_list = (((in_string.replace('-','')).replace('|', '')).replace('+', '')).split() + return out_list + +def get_out_helper_2(in_string): + out_list = ((in_string.replace('|', '')).replace('+', '')).split() + return out_list + +#ONBOARDING SECTION +def create_vlm(parameters): + vlm_create_string = "oclip vlm-create -x {} -u {} -p {} -m {}".format(parameters["vendor-name"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) + command_out = (os.popen(vlm_create_string)).read() + out_list = get_out_helper(command_out) + vlm_id = out_list[3] + vlm_version = out_list[5] + + entitlement_string = "oclip vlm-entitlement-pool-create -x {} -y {} -e {} -z {} -k {} -g {} -l {} -u {} -p {} -m {}".format( \ + parameters["entitlement-pool-name"], vlm_id, vlm_version, parameters["entitlement-description"], parameters["vendor-name"], \ + parameters["expiry-date"], parameters["start-date"], parameters["sdc_creator"], parameters["sdc_password"], \ + parameters["sdc_onboarding_url"]) + command_out = (os.popen(entitlement_string)).read() + entitlement_id = (get_out_helper(command_out))[3] + + + key_group_string = "oclip vlm-key-group-create -c {} -e {} -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, \ + parameters["key-group-name"], parameters["key-group-type"], parameters["sdc_creator"], parameters["sdc_password"], \ + parameters["sdc_onboarding_url"]) + command_out = (os.popen(key_group_string)).read() + key_group_id = (get_out_helper(command_out))[3] + + feature_group_string = "oclip vlm-feature-group-create -x {} -y {} -e {} -z {} -g {} -b {} -c {} -u {} -p {} -m {}".format( + parameters["feature-grp-name"], vlm_id, vlm_version, parameters["feature-grp-desc"], key_group_id, entitlement_id, \ + parameters["part-no"], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) + command_out = (os.popen(feature_group_string)).read() + feature_group_id = (get_out_helper(command_out))[3] + + agreement_string = "oclip vlm-aggreement-create -x {} -y {} -e {} -z {} -g {} -u {} -p {} -m {}".format(parameters["agreement-name"], \ + vlm_id, vlm_version, parameters["agreement-desc"], feature_group_id, parameters["sdc_creator"], parameters["sdc_password"], \ + parameters["sdc_onboarding_url"]) + command_out = (os.popen(agreement_string)).read() + agreement_id = (get_out_helper(command_out))[3] + + submit_string = "oclip vlm-submit -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_onboarding_url"]) + os.system(submit_string) + + output = [feature_group_id, agreement_id, vlm_version, vlm_id ] + return output + +def create_vsp(parameters, in_list): + create_string = "oclip vsp-create -j {} -o {} -e {} -x {} -y {} -i {} -c {} -g {} -u {} -p {} -m {}".format( in_list[0], \ + parameters["onboarding-method"], parameters["vendor-name" ], parameters["vsp-name"], parameters["vsp-desc"], in_list[1], \ + in_list[2], in_list[3], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"] ) + command_out = (os.popen(create_string)).read() + out_list = get_out_helper(command_out) + vsp_id = out_list[3] + vsp_version = out_list[5] + + os.system("oclip vsp-add-artifact -x {} -y {} -z {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["csar-file-path"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"])) + + os.system("oclip vsp-validate -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_onboarding_url"])) + + os.system("oclip vsp-submit -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_onboarding_url"])) + + os.system("oclip vsp-package -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_onboarding_url"])) + + return vsp_id + + +def create_vf_model(parameters, vsp_id): + create_string = "oclip vf-model-create -y {} -g {} -x {} -z {} -b {} -u {} -p {} -m {}".format(parameters["vf-description"], \ + parameters["vsp-version"], parameters["vf-name"], parameters["vendor-name"], vsp_id, parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_catalog_url"]) + os.system(create_string) + + output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["vf-name"]))).read() + output = (get_out_helper_2(output)) + + vf_unique_id = output[1] + + os.system("oclip vf-model-certify -b {} -r {} -u {} -p {} -m {}".format(vf_unique_id, parameters["vf-remarks"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) + + #Check for new parameters after certification + output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["vf-name"]))).read() + output = (get_out_helper_2(output)) + + vf_id = output[0] + vf_unique_id = output[1] + vf_model_invariant_uuid = output[2] + vf_model_version = output[4] + + out_dict = {} + out_dict["vf_id"] = vf_id + out_dict["vf_unique_id"] = vf_unique_id + out_dict["vf_model_invariant_uuid"] = vf_model_invariant_uuid + out_dict["vf_model_version"] = vf_model_version + + return out_dict + + +def create_service_model(parameters, vf_unique_id): + create_string = "oclip service-model-create -z {} -y {} -e {} -x {} -c {} -b {} -u {} -p {} -m {} |grep ID".format(parameters["project-code"], \ + parameters["service-model-desc"], parameters["icon-id"], parameters["service-model-name"], parameters["category-display"], \ + parameters["category"],parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"]) + + service_model_id = (get_out_helper_2((os.popen(create_string)).read()))[1] + + os.system("oclip service-model-add-vf -x {} -b {} -y {} -z {} -u {} -p {} -m {}".format(service_model_id, parameters["vf-version"], \ + vf_unique_id, parameters["vf-name"], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"] )) + + os.system("oclip service-model-test-request -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-test-remarks"], \ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) + + os.system("oclip service-model-test-start -b {} -u {} -p {} -m {}".format(service_model_id, parameters["sdc_tester"], \ + parameters["sdc_password"], parameters["sdc_catalog_url"])) + + os.system("oclip service-model-test-accept -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-accept-remarks"], \ + parameters["sdc_tester"], parameters["sdc_password"], parameters["sdc_catalog_url"])) + + #Get uniqueId for the service model + service_model_values = (os.popen("oclip service-model-list -u {} -p {} -m {} |grep {}".format(parameters["sdc_creator"], \ + parameters["sdc_password"], parameters["sdc_catalog_url"], parameters["service-model-name"]))).read() + service_model_values = get_out_helper_2(service_model_values) + service_model_uniqueId = (service_model_values)[1] + + os.system("oclip service-model-approve -b {} -r {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["service-approve-remarks"], \ + parameters["sdc_governor"], parameters["sdc_password"], parameters["sdc_catalog_url"])) + + os.system("oclip service-model-distribute -b {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["sdc_operator"], \ + parameters["sdc_password"], parameters["sdc_catalog_url"])) + + return service_model_values + + +#VNF Deployment Section + + +def add_policies(parameters): + resource_string = (os.popen("oclip get-resource-module-name -u {} -p {} -m {} |grep {}".format(\ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"], \ + parameters["service-model-name"] ))).read() + resource_module_name = (get_out_helper_2(resource_string))[1] + + #Put in the right resource module name in all policies located in parameters["policy_directory"] + os.system("find {}/ -type f -exec sed -i 's/{}/{}/g' {{}} \;".format( + parameters["policy_directory"], parameters["temp_resource_module_name"], resource_module_name)) + + #Upload policy models + for model in os.listdir(parameters["policy_models_directory"]): + os.system("oclip policy-type-create -x {} -u {} -p {} -m {}".format(model, parameters["policy_username"], \ + parameters["policy_password"], parameters["policy_url"])) + time.sleep(0.5) + + #print("Put in the resourceModuleName {} in your policy files in {}. ".format(resource_module_name, \ + #(parameters["policy_directory"]))) + #raw_input("Press Enter to continue...") + + + #Loop through policy, put in resource_model_name and create policies + for policy in os.listdir(parameters["policy_directory"]): + policy_name = "{}.{}".format(parameters["policy_scope"], os.path.splitext(policy)[0]) + policy_file = (os.path.join(parameters["policy_directory"], policy)) + #Create policy + os.system("oclip policy-create-outdated -m {} -u {} -p {} -x {} -S {} -T {} -o {} -b $(cat {})".format(parameters["policy_url"],\ + parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_scope"], \ + parameters["policy_config_type"], parameters["policy_onapName"], policy_file)) + + #Push policy + os.system("oclip policy-push-outdated -m {} -u {} -p {} -x {} -b {} -c {}".format(parameters["policy_url"], \ + parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_config_type"],\ + parameters["policy_pdp_group"])) + + +def create_service_instance(parameters, sevice_model_list): + #Get Required parameters + service_uuid = service_model_list[0] + service_invariant_uuid = service_model_list[2] + service_version = service_model_list[4] + + owning_entity_values = (os.popen("oclip owning-entity-list -u {} -p {} -m {} |grep {}".format(parameters["aai_username"], \ + parameters["aai_password"], parameters["aai_url"], parameters["owning-entity-name"]))).read() + owning_entity_id = (get_out_helper_2(owning_entity_values))[1] + + #Create service instance + instance_output = (os.popen("oclip service-create -w {} -la {} -lo {} -o {} -A {} -i {} -y {} -x {} -q {} -O {} -k {}-{} -P {} \ + -H {} -n {} -e {} -j {} -S {} -g {} -z {} -c {} -u {} -p {} -m {} |grep service-id".format(parameters["service_name"], \ + parameters["customer-latitude"], parameters["customer-longitude"], parameters["orchestrator"], parameters["a-la-carte"], \ + parameters["service-model-name"], parameters["company-name"], parameters["projectName"], parameters["requestor-id"], \ + parameters["owning-entity-name"], parameters["instance-name"], parameters["service_name"], parameters["test-api"], parameters["homing-solution"], \ + service_uuid, service_invariant_uuid, service_version, parameters["subscriber_name"], service_uuid, owning_entity_id, \ + parameters["customer_name"], parameters["so_username"], parameters["so_password"], parameters["so_url"] ))).read() + + service_instance_id = (get_out_helper_2(instance_output))[1] + output_dict = {} + + output_dict["service_instance_id"] = service_instance_id + output_dict["service_uuid"] = service_uuid + output_dict["service_invariant_uuid"] = service_invariant_uuid + output_dict["service_version"] = service_version + + + return output_dict + +def query_db(parameters, service_model_uuid, vf_model_uuid): + + out_dictionary = {} + #Query DB Certain parameters required + mariadb_connection = mariadb.connect(user='{}'.format(parameters["so_mariadb_user"]), host='{}'.format(parameters["so_mariadb_host"]), + password='{}'.format(parameters["so_mariadb_password"]), database='{}'.format(parameters["so_mariadb_db"])) + values = mariadb_connection.cursor() + + #Get vf model customization values + values.execute('SELECT MODEL_INSTANCE_NAME, MODEL_CUSTOMIZATION_UUID FROM vnf_resource_customization WHERE \ + SERVICE_MODEL_UUID = "{}"'.format(service_model_uuid)) + vf_customization_values = values.fetchall() + + out_dictionary["vf_model_customization_name"] = vf_customization_values[0][0] + out_dictionary["vf_model_customization_id"] = vf_customization_values[0][1] + + values.execute('SELECT MODEL_INVARIANT_UUID, MODEL_UUID, MODEL_NAME, MODEL_VERSION FROM vf_module WHERE \ + VNF_RESOURCE_MODEL_UUID = "{}"'.format(vf_model_uuid)) + + vf_module_values = values.fetchall() + out_dictionary["vf_module_model_invariant_id"] = vf_module_values[0][0] + out_dictionary["vf_module_model_id"] = vf_module_values[0][1] + out_dictionary["vf_module_model_name"] = vf_module_values[0][2] + out_dictionary["vf_module_model_version"] = vf_module_values[0][3] + + values.execute('SELECT MODEL_CUSTOMIZATION_UUID FROM vf_module_customization WHERE \ + VF_MODULE_MODEL_UUID = "{}"'.format(out_dictionary["vf_module_model_id"])) + vf_module_customization = values.fetchall() + + out_dictionary["vf_module_customization_id"] = vf_module_customization[0][0] + values.close() + mariadb_connection.close() + + return out_dictionary + + + +def create_vnf(parameters, service_dict, db_dict, vf_model_dict): + + vf_model_uuid = vf_model_dict["vf_id"] + vf_model_invariant_uuid = vf_model_dict["vf_model_invariant_uuid"] + vf_model_version = vf_model_dict["vf_model_version"] + + + + vf_model_customization_name = db_dict["vf_model_customization_name"] + vf_model_customization_id = db_dict["vf_model_customization_id"] + + #Put in any cloud region, OOF will select the right one + cloud_region = next(iter(parameters["cloud_region_data"])) + tenant_id = ((parameters["cloud_region_data"])[cloud_region])["tenant-id"] + + service_invariant_uuid = service_dict["service_invariant_uuid"] + service_uuid = service_dict["service_uuid"] + service_instance_id = service_dict["service_instance_id"] + service_version = service_dict["service_version"] + + #Create vnf + vnf_create_out = (os.popen("oclip vnf-create -j {} -q {} -k {} -l {} -y {} -z {} -r {} -c {} -o {} -e {} -g {} -b {} -n {} -i {} -vn '{}'\ + -w {} -pn {} -lob {} -u {} -p {} -m {} |grep vf-id".format(service_invariant_uuid, parameters["service-model-name"], \ + service_uuid, cloud_region, service_instance_id, tenant_id, parameters["requestor-id"], vf_model_uuid, \ + parameters["generic-vnf-name"], parameters["vf-name"], vf_model_version, vf_model_invariant_uuid, service_version, \ + vf_model_customization_id, vf_model_customization_name, parameters["service_name"], parameters["platform-name"], \ + parameters["lob-name"], parameters["so_username"], parameters["so_password"], parameters["so_url"]))).read() + + vnf_instance_id = (get_out_helper_2(vnf_create_out))[1] + + vf_model_dict["vnf_instance_id"] = vnf_instance_id + + return vf_model_dict + +def sdnc_preload(parameters, db_dict, service_dict): + + + preload_file = parameters["sdnc_preload_file"] + + #Replace values gotten from the service instance, vnf, vf in preload file, other values such as ip addresses + #should be directly changed in the preload file + #Items to search and replace in file + replace_dict = { + '"generic-vnf-name"' : ' "generic-vnf-name": "{}",\n'.format(parameters["generic-vnf-name"]), + '"generic-vnf-type"' : ' "generic-vnf-type": "{}",\n'.format(db_dict["vf_model_customization_name"]), + '"service-type"' : ' "service-type": "{}",\n'.format(service_dict["service_instance_id"]), + '"vnf-name"' : ' "vnf-name": "{}",\n'.format(parameters["vf-module-name"]), + '"vnf-type"' : ' "vnf-type": "{}"\n'.format(db_dict["vf_module_model_name"]), + '"vf_module_id"' : ' "vnf-parameter-value": "{}"\n'.format(db_dict["vf_module_model_name"]) + } + + with open(preload_file, 'r') as file: + preload_data = file.readlines() + + for key, val in replace_dict.iteritems(): + for line in range(len(preload_data)): + + if key in preload_data[line] and key == '"vf_module_id"': + preload_data[line + 1] = val + break + + elif key in preload_data[line] and key != '"vf_module_id"': + preload_data[line] = val + break + with open(preload_file, 'w') as file: + file.writelines(preload_data) + + os.system("oclip vf-preload -u {} -p {} -y {} -m {}".format(parameters["sdnc_user"], parameters["sdnc_password"], \ + preload_file, parameters["sdnc_url"])) + + + +def create_vf_module(parameters, service_dict, vnf_dict, db_dict): + + #vf module parameters + vf_module_model_name = db_dict["vf_module_model_name"] + vf_module_model_invariant_id = db_dict["vf_module_model_invariant_id"] + vf_module_model_version = db_dict["vf_module_model_version"] + vf_module_model_version_id = db_dict["vf_module_model_id"] + vf_module_customization_id = db_dict["vf_module_customization_id"] + + #service parameters + service_invariant_uuid = service_dict["service_invariant_uuid"] + service_uuid = service_dict["service_uuid"] + service_instance_id = service_dict["service_instance_id"] + service_version = service_dict["service_version"] + + #vnf parameters + vnf_instance_id = vnf_dict["vnf_instance_id"] + vf_model_id = vnf_dict["vf_id"] + vf_model_invariant_uuid = vnf_dict["vf_model_invariant_uuid"] + vf_model_version = vnf_dict["vf_model_version"] + vf_model_customization_name = db_dict["vf_model_customization_name"] + vf_model_customization_id = db_dict["vf_model_customization_id"] + + #Put in any cloud region, OOF will select the right one + cloud_region = next(iter(parameters["cloud_region_data"])) + tenant_id = ((parameters["cloud_region_data"])[cloud_region])["tenant-id"] + + + os.system("oclip vf-module-create -w {} -mn '{}' -x {} -l {} -sv {} -vc {} -vm {} -mv {} -i {} -vf {} -vi {} -r {} \ + -mc {} -api {} -mi {} -vid {} -y {} -R {} -si {} -up {} -sd {} -z {} -vn {} -vv {} -co {} -u {} -p {} -m {}".format(tenant_id, \ + vf_model_customization_name, service_instance_id, cloud_region, service_version, vf_module_customization_id, vf_module_model_version,\ + vf_model_version, parameters["vf-module-name"], parameters["vf-name"], vf_module_model_invariant_id, parameters["supress-rollback"], \ + vf_model_customization_id, parameters["test-api"], vf_model_invariant_uuid, vf_model_id, vnf_instance_id, parameters["requestor-id"], \ + service_uuid, parameters["use-preload"], service_invariant_uuid, parameters["service-model-name"], vf_module_model_name, \ + vf_module_model_version_id, parameters["cloud-owner"], parameters["so_username"], parameters["so_password"], parameters["so_url"])) + + + + + + +#Run Functions + +config_file_path = "/root/automation_stuff/hpa_automation_config.json" +config_file = open(config_file_path) +parameters = get_parameters(config_file) +set_open_cli_env(parameters) +create_complex(parameters) +register_all_clouds(parameters) +create_service_type(parameters) +create_customer(parameters) +add_customer_subscription(parameters) +output = create_vlm(parameters) +vsp_id = create_vsp(parameters, output) +vf_model_dict = create_vf_model(parameters, vsp_id) +vf_id = vf_model_dict["vf_id"] +vf_unique_id = vf_model_dict["vf_unique_id"] +service_model_list = create_service_model(parameters, vf_unique_id) + +#add_policies function not currently working, using curl commands +#add_policies(parameters) + +service_dict = create_service_instance(parameters, service_model_list) +service_model_uuid = service_dict["service_uuid"] +db_dict = query_db(parameters, service_model_uuid, vf_id) +vnf_dict = create_vnf(parameters, service_dict, db_dict, vf_model_dict) +sdnc_preload(parameters, db_dict, service_dict) +create_vf_module(parameters, service_dict, vnf_dict, db_dict) diff --git a/test/hpa_automation/heat/hpa_automation_config.json b/test/hpa_automation/heat/hpa_automation_config.json new file mode 100755 index 000000000..ff21bfe89 --- /dev/null +++ b/test/hpa_automation/heat/hpa_automation_config.json @@ -0,0 +1,178 @@ +{ + +"open_cli_product" : "onap-dublin", +"open_cli_home" : "/root/cli/deployment/zip/target/deployunzip", +"aai_url" : "https://10.12.6.235:30233", +"aai_username" : "AAI", +"aai_password" : "AAI", +"sdc_onboarding_url" : "http://10.43.246.144:8081", +"sdc_catalog_url" : "http://10.12.6.235:30205", +"sdc_password" : "demo123456!", +"sdc_creator" : "cs0008", +"sdc_tester" : "jm0007", +"sdc_governor" : "gv0001", +"sdc_operator" : "op0001", +"csar-file-path" : "/root/automation_stuff/hpa_zip_files/vfw_hpa.zip", +"sdnc_url" : "http://10.12.6.235:30202", +"sdnc_user" : "admin", +"sdnc_password" : "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U", +"sdnc_preload_file" : "/root/automation_stuff/vfw_hpa_preload.txt", +"so_url" : "http://10.12.6.235:30277", +"so_username" : "InfraPortalClient", +"so_password" : "password1$", +"so_mariadb_host" : "10.42.6.13", +"so_mariadb_user" : "root", +"so_mariadb_password" : "secretpassword", +"so_mariadb_db" : "catalogdb", +"multicloud_url" : "http://10.12.6.235:30280", +"policy_url" : "https://10.12.6.235:30240", +"policy_username" : "testpdp", +"policy_password" : "alpha123", +"policy_models_directory" : "/root/automation_stuff/optf-osdf/osdf/models/policy/placement/tosca_upload/", +"policy_directory" : "/root/automation_stuff/vfw_policies", +"policy_scope" : "OSDF_CASABLANCA", +"policy_onapName" : "SampleDemo", +"policy_config_type": "MicroService", +"policy_pdp_group" : "default", +"//" : "Put in a temp resource module name, should be the same in policy files, script will replace it in policies", +"temp_resource_module_name" : "resource_name", + +"//" : "#Parameters required to create cloud complex", +"complex_name" : "clli1", +"street1" : "street1", +"street2" : "street2", +"physical_location" : "phy_type", +"data_center_code" : "code1", +"latitude" : "32.89948", +"longitude" : "97.045443", +"lata" : "example-lata-val-28399", +"elevation" : "example-elevation-val-28399", +"region" : "northwest", +"state" : "oregon", +"city" : "hillsboro", +"postal-code" : "00000", +"country" : "USA", +"identity_url" : "example-identity-url-val-56898", + +"//" : "#Dictionary containing cloud regions and their Parameters", + + + "cloud_region_data":{ + "ONAP-POD-01-Rail-05":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62784e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + }, + + "ONAP-POD-01-Rail-06":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + }, + + "ONAP-POD-01-Rail-07":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"4c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + } + }, + + +"//" : "#Parameters to register cloud region", +"cloud-owner" : "CloudOwner", +"owner-defined-type" : "t1", +"cloud-zone" : "CloudZone", + +"service_name" : "vFW", +"customer_name" : "hpa_cust", +"subscriber_name" : "hpa_cust", + +"//" : "Onboarding parameters", +"vendor-name" : "hpa-vendor", +"entitlement-pool-name" : "hpa-pool", +"entitlement-description" : "hpa-pool", +"start-date" : "04/23/2019", +"expiry-date" : "12/31/2040", +"key-group-name" : "hpa-key", +"key-group-type" : "Universal", +"feature-grp-name" : "hpa-feature", +"feature-grp-desc" : "hpa-feature", +"part-no" : "hpa-part", +"agreement-name" : "hpa-agreement", +"agreement-desc" : "hpa-agreement", + +"onboarding-method" : "NetworkPackage", +"vsp-name" : "hpa-vsp", +"vsp-desc" : "hpa-vsp-desc", +"vsp-version" : "1.0", + +"vf-name" : "hpa-vf", +"vf-description" : "hpa-vf", +"vf-remarks" :"remarkss", +"vf-version" : "1.0", + +"//" : "Be sure to include single quotes in parameters that have spaces", +"project-code" : "000000", +"service-model-name" : "vfw-hpa", +"service-model-desc" : "'hpa service model'", +"icon-id" : "network_l_1-3", +"category-display" : "'Network L1-3'", +"category" : "'network l1-3'", + +"service-test-remarks" : "test", +"service-accept-remarks" : "accepted", +"service-approve-remarks" : "approved", + + +"//" : "service instance parameters", +"instance-name" : "hpa-instance", +"requestor-id" : "demo", +"customer-latitude":"32.897480", +"customer-longitude":"97.040443", +"company-name":"some_company", +"homing-solution" : "oof", +"orchestrator" : "multicloud", +"owning-entity-name":"OE-Demonstration", +"projectName" : "Project-Demonstration", +"a-la-carte" : true, +"test-api" : "VNF_API", + +"//" : "vnf parameters", +"platform-name" : "Platform-Demonstration", +"lob-name" : "LOB-Demonstration", +"generic-vnf-name" : "vfw-hpa-vnf", + +"vf-module-name" : "vfw-sriov-cli", +"supress-rollback" : "false", +"use-preload" : "true" +} diff --git a/test/hpa_automation/hpa_automation.py b/test/hpa_automation/hpa_automation.py deleted file mode 100644 index 1bbf3a40d..000000000 --- a/test/hpa_automation/hpa_automation.py +++ /dev/null @@ -1,483 +0,0 @@ -#!/usr/bin/python - -#Prerequisites for machine to run this -#Put in required parameters in hpa_automation_config.json -#Install python-pip (apt install python-pip) -#Install python mysql.connector (pip install mysql-connector-python) -#Install ONAP CLI -#Must have connectivity to the ONAP, a k8s vm already running is recommended -#Create Preload File, the script will modify the parameters required from serivce model, service instance -#and vnf instance -#Create policies for homing -#Put in CSAR file -#modify so-bpmn configmap and change version to v2 - -import json -import os -import mysql.connector as mariadb -import time - - -def get_parameters(file): - parameters = json.load(file) - return parameters - -def set_open_cli_env(parameters): - os.environ["OPEN_CLI_PRODUCT_IN_USE"] = parameters["open_cli_product"] - os.environ["OPEN_CLI_HOME"] = parameters["open_cli_home"] - -def create_complex(parameters): - complex_create_string = "oclip complex-create -j {} -r {} -x {} -y {} -lt {} -l {} -i {} -lo {} \ - -S {} -la {} -g {} -w {} -z {} -k {} -o {} -q {} -m {} -u {} -p {}".format(parameters["street2"], \ - parameters["physical_location"], parameters["complex_name"], \ - parameters["data_center_code"], parameters["latitude"], parameters["region"], \ - parameters["street1"], parameters["longitude"], parameters["state"], \ - parameters["lata"], parameters["city"], parameters["postal-code"], \ - parameters["complex_name"], parameters["country"], parameters["elevation"], \ - parameters["identity_url"], parameters["aai_url"], parameters["aai_username"], \ - parameters["aai_password"]) - - os.system(complex_create_string) - - -def register_cloud_helper(cloud_region, values, parameters): - #Create Cloud - cloud_create_string = 'oclip cloud-create -e {} -b {} -I {{\\\\\\"openstack-region-id\\\\\\":\\\\\\"{}\\\\\\"}} \ - -x {} -y {} -j {} -w {} -l {} -url {} -n {} -q {} -r {} -Q {} -i {} -g {} -z {} -k {} -c {} -m {} -u {} -p {}'.format( - values.get("esr-system-info-id"), values.get("user-name"), cloud_region, parameters["cloud-owner"], \ - cloud_region, values.get("password"), values.get("cloud-region-version"), values.get("default-tenant"), \ - values.get("service-url"), parameters["complex_name"], values.get("cloud-type"), parameters["owner-defined-type"], \ - values.get("system-type"), values.get("identity-url"), parameters["cloud-zone"], values.get("ssl-insecure"), \ - values.get("system-status"), values.get("cloud-domain"), parameters["aai_url"], parameters["aai_username"], \ - parameters["aai_password"]) - - - os.system(cloud_create_string) - - #Associate Cloud with complex - complex_associate_string = "oclip complex-associate -x {} -y {} -z {} -m {} -u {} -p {}".format(parameters["complex_name"], \ - cloud_region, parameters["cloud-owner"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) - os.system(complex_associate_string) - - #Register Cloud with Multicloud - multicloud_register_string = "oclip multicloud-register-cloud -y {} -x {} -m {}".format(parameters["cloud-owner"], \ - cloud_region, parameters["multicloud_url"]) - os.system(multicloud_register_string) - -def register_all_clouds(parameters): - cloud_dictionary = parameters["cloud_region_data"] - for cloud_region, cloud_region_values in cloud_dictionary.iteritems(): - register_cloud_helper(cloud_region, cloud_region_values, parameters) - -def create_service_type(parameters): - create_string = "oclip service-type-create -x {} -m {} -u {} -p {}".format( parameters["service_name"], \ - parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) - os.system(create_string) - -def create_customer(parameters): - create_string = "oclip customer-create -x {} -y {} -m {} -u {} -p {}".format( parameters["customer_name"], \ - parameters["subscriber_name"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) - os.system(create_string) - -def add_customer_subscription(parameters): - subscription_check = 0 - for cloud_region, cloud_region_values in (parameters["cloud_region_data"]).iteritems(): - if subscription_check == 0 : - subscription_string = "oclip subscription-create -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ - parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ - cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) - else: - subscription_string = "oclip subscription-cloud-add -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ - parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ - cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) - os.system(subscription_string) - subscription_check+=1 - -def get_out_helper(in_string): - out_list = (((in_string.replace('-','')).replace('|', '')).replace('+', '')).split() - return out_list - -def get_out_helper_2(in_string): - out_list = ((in_string.replace('|', '')).replace('+', '')).split() - return out_list - -#ONBOARDING SECTION -def create_vlm(parameters): - vlm_create_string = "oclip vlm-create -x {} -u {} -p {} -m {}".format(parameters["vendor-name"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) - command_out = (os.popen(vlm_create_string)).read() - out_list = get_out_helper(command_out) - vlm_id = out_list[3] - vlm_version = out_list[5] - - entitlement_string = "oclip vlm-entitlement-pool-create -x {} -y {} -e {} -z {} -k {} -g {} -l {} -u {} -p {} -m {}".format( \ - parameters["entitlement-pool-name"], vlm_id, vlm_version, parameters["entitlement-description"], parameters["vendor-name"], \ - parameters["expiry-date"], parameters["start-date"], parameters["sdc_creator"], parameters["sdc_password"], \ - parameters["sdc_onboarding_url"]) - command_out = (os.popen(entitlement_string)).read() - entitlement_id = (get_out_helper(command_out))[3] - - - key_group_string = "oclip vlm-key-group-create -c {} -e {} -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, \ - parameters["key-group-name"], parameters["key-group-type"], parameters["sdc_creator"], parameters["sdc_password"], \ - parameters["sdc_onboarding_url"]) - command_out = (os.popen(key_group_string)).read() - key_group_id = (get_out_helper(command_out))[3] - - feature_group_string = "oclip vlm-feature-group-create -x {} -y {} -e {} -z {} -g {} -b {} -c {} -u {} -p {} -m {}".format( - parameters["feature-grp-name"], vlm_id, vlm_version, parameters["feature-grp-desc"], key_group_id, entitlement_id, \ - parameters["part-no"], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) - command_out = (os.popen(feature_group_string)).read() - feature_group_id = (get_out_helper(command_out))[3] - - agreement_string = "oclip vlm-aggreement-create -x {} -y {} -e {} -z {} -g {} -u {} -p {} -m {}".format(parameters["agreement-name"], \ - vlm_id, vlm_version, parameters["agreement-desc"], feature_group_id, parameters["sdc_creator"], parameters["sdc_password"], \ - parameters["sdc_onboarding_url"]) - command_out = (os.popen(agreement_string)).read() - agreement_id = (get_out_helper(command_out))[3] - - submit_string = "oclip vlm-submit -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_onboarding_url"]) - os.system(submit_string) - - output = [feature_group_id, agreement_id, vlm_version, vlm_id ] - return output - -def create_vsp(parameters, in_list): - create_string = "oclip vsp-create -j {} -o {} -e {} -x {} -y {} -i {} -c {} -g {} -u {} -p {} -m {}".format( in_list[0], \ - parameters["onboarding-method"], parameters["vendor-name" ], parameters["vsp-name"], parameters["vsp-desc"], in_list[1], \ - in_list[2], in_list[3], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"] ) - command_out = (os.popen(create_string)).read() - out_list = get_out_helper(command_out) - vsp_id = out_list[3] - vsp_version = out_list[5] - - os.system("oclip vsp-add-artifact -x {} -y {} -z {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["csar-file-path"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"])) - - os.system("oclip vsp-validate -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_onboarding_url"])) - - os.system("oclip vsp-submit -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_onboarding_url"])) - - os.system("oclip vsp-package -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_onboarding_url"])) - - return vsp_id - - -def create_vf_model(parameters, vsp_id): - create_string = "oclip vf-model-create -y {} -g {} -x {} -z {} -b {} -u {} -p {} -m {}".format(parameters["vf-description"], \ - parameters["vsp-version"], parameters["vf-name"], parameters["vendor-name"], vsp_id, parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_catalog_url"]) - os.system(create_string) - - output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["vf-name"]))).read() - output = (get_out_helper_2(output)) - - vf_unique_id = output[1] - - os.system("oclip vf-model-certify -b {} -r {} -u {} -p {} -m {}".format(vf_unique_id, parameters["vf-remarks"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) - - #Check for new parameters after certification - output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["vf-name"]))).read() - output = (get_out_helper_2(output)) - - vf_id = output[0] - vf_unique_id = output[1] - vf_model_invariant_uuid = output[2] - vf_model_version = output[4] - - out_dict = {} - out_dict["vf_id"] = vf_id - out_dict["vf_unique_id"] = vf_unique_id - out_dict["vf_model_invariant_uuid"] = vf_model_invariant_uuid - out_dict["vf_model_version"] = vf_model_version - - return out_dict - - -def create_service_model(parameters, vf_unique_id): - create_string = "oclip service-model-create -z {} -y {} -e {} -x {} -c {} -b {} -u {} -p {} -m {} |grep ID".format(parameters["project-code"], \ - parameters["service-model-desc"], parameters["icon-id"], parameters["service-model-name"], parameters["category-display"], \ - parameters["category"],parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"]) - - service_model_id = (get_out_helper_2((os.popen(create_string)).read()))[1] - - os.system("oclip service-model-add-vf -x {} -b {} -y {} -z {} -u {} -p {} -m {}".format(service_model_id, parameters["vf-version"], \ - vf_unique_id, parameters["vf-name"], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"] )) - - os.system("oclip service-model-test-request -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-test-remarks"], \ - parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) - - os.system("oclip service-model-test-start -b {} -u {} -p {} -m {}".format(service_model_id, parameters["sdc_tester"], \ - parameters["sdc_password"], parameters["sdc_catalog_url"])) - - os.system("oclip service-model-test-accept -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-accept-remarks"], \ - parameters["sdc_tester"], parameters["sdc_password"], parameters["sdc_catalog_url"])) - - #Get uniqueId for the service model - service_model_values = (os.popen("oclip service-model-list -u {} -p {} -m {} |grep {}".format(parameters["sdc_creator"], \ - parameters["sdc_password"], parameters["sdc_catalog_url"], parameters["service-model-name"]))).read() - service_model_values = get_out_helper_2(service_model_values) - service_model_uniqueId = (service_model_values)[1] - - os.system("oclip service-model-approve -b {} -r {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["service-approve-remarks"], \ - parameters["sdc_governor"], parameters["sdc_password"], parameters["sdc_catalog_url"])) - - os.system("oclip service-model-distribute -b {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["sdc_operator"], \ - parameters["sdc_password"], parameters["sdc_catalog_url"])) - - return service_model_values - - -#VNF Deployment Section - - -def add_policies(parameters): - resource_string = (os.popen("oclip get-resource-module-name -u {} -p {} -m {} |grep {}".format(\ - parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"], \ - parameters["service-model-name"] ))).read() - resource_module_name = (get_out_helper_2(resource_string))[1] - - #Put in the right resource module name in all policies located in parameters["policy_directory"] - os.system("find {}/ -type f -exec sed -i 's/{}/{}/g' {{}} \;".format( - parameters["policy_directory"], parameters["temp_resource_module_name"], resource_module_name)) - - #Upload policy models - for model in os.listdir(parameters["policy_models_directory"]): - os.system("oclip policy-type-create -x {} -u {} -p {} -m {}".format(model, parameters["policy_username"], \ - parameters["policy_password"], parameters["policy_url"])) - time.sleep(0.5) - - #print("Put in the resourceModuleName {} in your policy files in {}. ".format(resource_module_name, \ - #(parameters["policy_directory"]))) - #raw_input("Press Enter to continue...") - - - #Loop through policy, put in resource_model_name and create policies - for policy in os.listdir(parameters["policy_directory"]): - policy_name = "{}.{}".format(parameters["policy_scope"], os.path.splitext(policy)[0]) - policy_file = (os.path.join(parameters["policy_directory"], policy)) - #Create policy - os.system("oclip policy-create-outdated -m {} -u {} -p {} -x {} -S {} -T {} -o {} -b $(cat {})".format(parameters["policy_url"],\ - parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_scope"], \ - parameters["policy_config_type"], parameters["policy_onapName"], policy_file)) - - #Push policy - os.system("oclip policy-push-outdated -m {} -u {} -p {} -x {} -b {} -c {}".format(parameters["policy_url"], \ - parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_config_type"],\ - parameters["policy_pdp_group"])) - - -def create_service_instance(parameters, sevice_model_list): - #Get Required parameters - service_uuid = service_model_list[0] - service_invariant_uuid = service_model_list[2] - service_version = service_model_list[4] - - owning_entity_values = (os.popen("oclip owning-entity-list -u {} -p {} -m {} |grep {}".format(parameters["aai_username"], \ - parameters["aai_password"], parameters["aai_url"], parameters["owning-entity-name"]))).read() - owning_entity_id = (get_out_helper_2(owning_entity_values))[1] - - #Create service instance - instance_output = (os.popen("oclip service-create -w {} -la {} -lo {} -o {} -A {} -i {} -y {} -x {} -q {} -O {} -k {}-{} -P {} \ - -H {} -n {} -e {} -j {} -S {} -g {} -z {} -c {} -u {} -p {} -m {} |grep service-id".format(parameters["service_name"], \ - parameters["customer-latitude"], parameters["customer-longitude"], parameters["orchestrator"], parameters["a-la-carte"], \ - parameters["service-model-name"], parameters["company-name"], parameters["projectName"], parameters["requestor-id"], \ - parameters["owning-entity-name"], parameters["instance-name"], parameters["service_name"], parameters["test-api"], parameters["homing-solution"], \ - service_uuid, service_invariant_uuid, service_version, parameters["subscriber_name"], service_uuid, owning_entity_id, \ - parameters["customer_name"], parameters["so_username"], parameters["so_password"], parameters["so_url"] ))).read() - - service_instance_id = (get_out_helper_2(instance_output))[1] - output_dict = {} - - output_dict["service_instance_id"] = service_instance_id - output_dict["service_uuid"] = service_uuid - output_dict["service_invariant_uuid"] = service_invariant_uuid - output_dict["service_version"] = service_version - - - return output_dict - -def query_db(parameters, service_model_uuid, vf_model_uuid): - - out_dictionary = {} - #Query DB Certain parameters required - mariadb_connection = mariadb.connect(user='{}'.format(parameters["so_mariadb_user"]), host='{}'.format(parameters["so_mariadb_host"]), - password='{}'.format(parameters["so_mariadb_password"]), database='{}'.format(parameters["so_mariadb_db"])) - values = mariadb_connection.cursor() - - #Get vf model customization values - values.execute('SELECT MODEL_INSTANCE_NAME, MODEL_CUSTOMIZATION_UUID FROM vnf_resource_customization WHERE \ - SERVICE_MODEL_UUID = "{}"'.format(service_model_uuid)) - vf_customization_values = values.fetchall() - - out_dictionary["vf_model_customization_name"] = vf_customization_values[0][0] - out_dictionary["vf_model_customization_id"] = vf_customization_values[0][1] - - values.execute('SELECT MODEL_INVARIANT_UUID, MODEL_UUID, MODEL_NAME, MODEL_VERSION FROM vf_module WHERE \ - VNF_RESOURCE_MODEL_UUID = "{}"'.format(vf_model_uuid)) - - vf_module_values = values.fetchall() - out_dictionary["vf_module_model_invariant_id"] = vf_module_values[0][0] - out_dictionary["vf_module_model_id"] = vf_module_values[0][1] - out_dictionary["vf_module_model_name"] = vf_module_values[0][2] - out_dictionary["vf_module_model_version"] = vf_module_values[0][3] - - values.execute('SELECT MODEL_CUSTOMIZATION_UUID FROM vf_module_customization WHERE \ - VF_MODULE_MODEL_UUID = "{}"'.format(out_dictionary["vf_module_model_id"])) - vf_module_customization = values.fetchall() - - out_dictionary["vf_module_customization_id"] = vf_module_customization[0][0] - values.close() - mariadb_connection.close() - - return out_dictionary - - - -def create_vnf(parameters, service_dict, db_dict, vf_model_dict): - - vf_model_uuid = vf_model_dict["vf_id"] - vf_model_invariant_uuid = vf_model_dict["vf_model_invariant_uuid"] - vf_model_version = vf_model_dict["vf_model_version"] - - - - vf_model_customization_name = db_dict["vf_model_customization_name"] - vf_model_customization_id = db_dict["vf_model_customization_id"] - - #Put in any cloud region, OOF will select the right one - cloud_region = next(iter(parameters["cloud_region_data"])) - tenant_id = ((parameters["cloud_region_data"])[cloud_region])["tenant-id"] - - service_invariant_uuid = service_dict["service_invariant_uuid"] - service_uuid = service_dict["service_uuid"] - service_instance_id = service_dict["service_instance_id"] - service_version = service_dict["service_version"] - - #Create vnf - vnf_create_out = (os.popen("oclip vnf-create -j {} -q {} -k {} -l {} -y {} -z {} -r {} -c {} -o {} -e {} -g {} -b {} -n {} -i {} -vn '{}'\ - -w {} -pn {} -lob {} -u {} -p {} -m {} |grep vf-id".format(service_invariant_uuid, parameters["service-model-name"], \ - service_uuid, cloud_region, service_instance_id, tenant_id, parameters["requestor-id"], vf_model_uuid, \ - parameters["generic-vnf-name"], parameters["vf-name"], vf_model_version, vf_model_invariant_uuid, service_version, \ - vf_model_customization_id, vf_model_customization_name, parameters["service_name"], parameters["platform-name"], \ - parameters["lob-name"], parameters["so_username"], parameters["so_password"], parameters["so_url"]))).read() - - vnf_instance_id = (get_out_helper_2(vnf_create_out))[1] - - vf_model_dict["vnf_instance_id"] = vnf_instance_id - - return vf_model_dict - -def sdnc_preload(parameters, db_dict, service_dict): - - - preload_file = parameters["sdnc_preload_file"] - - #Replace values gotten from the service instance, vnf, vf in preload file, other values such as ip addresses - #should be directly changed in the preload file - #Items to search and replace in file - replace_dict = { - '"generic-vnf-name"' : ' "generic-vnf-name": "{}",\n'.format(parameters["generic-vnf-name"]), - '"generic-vnf-type"' : ' "generic-vnf-type": "{}",\n'.format(db_dict["vf_model_customization_name"]), - '"service-type"' : ' "service-type": "{}",\n'.format(service_dict["service_instance_id"]), - '"vnf-name"' : ' "vnf-name": "{}",\n'.format(parameters["vf-module-name"]), - '"vnf-type"' : ' "vnf-type": "{}"\n'.format(db_dict["vf_module_model_name"]), - '"vf_module_id"' : ' "vnf-parameter-value": "{}"\n'.format(db_dict["vf_module_model_name"]) - } - - with open(preload_file, 'r') as file: - preload_data = file.readlines() - - for key, val in replace_dict.iteritems(): - for line in range(len(preload_data)): - - if key in preload_data[line] and key == '"vf_module_id"': - preload_data[line + 1] = val - break - - elif key in preload_data[line] and key != '"vf_module_id"': - preload_data[line] = val - break - with open(preload_file, 'w') as file: - file.writelines(preload_data) - - os.system("oclip vf-preload -u {} -p {} -y {} -m {}".format(parameters["sdnc_user"], parameters["sdnc_password"], \ - preload_file, parameters["sdnc_url"])) - - - -def create_vf_module(parameters, service_dict, vnf_dict, db_dict): - - #vf module parameters - vf_module_model_name = db_dict["vf_module_model_name"] - vf_module_model_invariant_id = db_dict["vf_module_model_invariant_id"] - vf_module_model_version = db_dict["vf_module_model_version"] - vf_module_model_version_id = db_dict["vf_module_model_id"] - vf_module_customization_id = db_dict["vf_module_customization_id"] - - #service parameters - service_invariant_uuid = service_dict["service_invariant_uuid"] - service_uuid = service_dict["service_uuid"] - service_instance_id = service_dict["service_instance_id"] - service_version = service_dict["service_version"] - - #vnf parameters - vnf_instance_id = vnf_dict["vnf_instance_id"] - vf_model_id = vnf_dict["vf_id"] - vf_model_invariant_uuid = vnf_dict["vf_model_invariant_uuid"] - vf_model_version = vnf_dict["vf_model_version"] - vf_model_customization_name = db_dict["vf_model_customization_name"] - vf_model_customization_id = db_dict["vf_model_customization_id"] - - #Put in any cloud region, OOF will select the right one - cloud_region = next(iter(parameters["cloud_region_data"])) - tenant_id = ((parameters["cloud_region_data"])[cloud_region])["tenant-id"] - - - os.system("oclip vf-module-create -w {} -mn '{}' -x {} -l {} -sv {} -vc {} -vm {} -mv {} -i {} -vf {} -vi {} -r {} \ - -mc {} -api {} -mi {} -vid {} -y {} -R {} -si {} -up {} -sd {} -z {} -vn {} -vv {} -co {} -u {} -p {} -m {}".format(tenant_id, \ - vf_model_customization_name, service_instance_id, cloud_region, service_version, vf_module_customization_id, vf_module_model_version,\ - vf_model_version, parameters["vf-module-name"], parameters["vf-name"], vf_module_model_invariant_id, parameters["supress-rollback"], \ - vf_model_customization_id, parameters["test-api"], vf_model_invariant_uuid, vf_model_id, vnf_instance_id, parameters["requestor-id"], \ - service_uuid, parameters["use-preload"], service_invariant_uuid, parameters["service-model-name"], vf_module_model_name, \ - vf_module_model_version_id, parameters["cloud-owner"], parameters["so_username"], parameters["so_password"], parameters["so_url"])) - - - - - - -#Run Functions - -config_file_path = "/root/automation_stuff/hpa_automation_config.json" -config_file = open(config_file_path) -parameters = get_parameters(config_file) -set_open_cli_env(parameters) -create_complex(parameters) -register_all_clouds(parameters) -create_service_type(parameters) -create_customer(parameters) -add_customer_subscription(parameters) -output = create_vlm(parameters) -vsp_id = create_vsp(parameters, output) -vf_model_dict = create_vf_model(parameters, vsp_id) -vf_id = vf_model_dict["vf_id"] -vf_unique_id = vf_model_dict["vf_unique_id"] -service_model_list = create_service_model(parameters, vf_unique_id) - -#add_policies function not currently working, using curl commands -#add_policies(parameters) - -service_dict = create_service_instance(parameters, service_model_list) -service_model_uuid = service_dict["service_uuid"] -db_dict = query_db(parameters, service_model_uuid, vf_id) -vnf_dict = create_vnf(parameters, service_dict, db_dict, vf_model_dict) -sdnc_preload(parameters, db_dict, service_dict) -create_vf_module(parameters, service_dict, vnf_dict, db_dict) diff --git a/test/hpa_automation/hpa_automation_config.json b/test/hpa_automation/hpa_automation_config.json deleted file mode 100644 index ff21bfe89..000000000 --- a/test/hpa_automation/hpa_automation_config.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - -"open_cli_product" : "onap-dublin", -"open_cli_home" : "/root/cli/deployment/zip/target/deployunzip", -"aai_url" : "https://10.12.6.235:30233", -"aai_username" : "AAI", -"aai_password" : "AAI", -"sdc_onboarding_url" : "http://10.43.246.144:8081", -"sdc_catalog_url" : "http://10.12.6.235:30205", -"sdc_password" : "demo123456!", -"sdc_creator" : "cs0008", -"sdc_tester" : "jm0007", -"sdc_governor" : "gv0001", -"sdc_operator" : "op0001", -"csar-file-path" : "/root/automation_stuff/hpa_zip_files/vfw_hpa.zip", -"sdnc_url" : "http://10.12.6.235:30202", -"sdnc_user" : "admin", -"sdnc_password" : "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U", -"sdnc_preload_file" : "/root/automation_stuff/vfw_hpa_preload.txt", -"so_url" : "http://10.12.6.235:30277", -"so_username" : "InfraPortalClient", -"so_password" : "password1$", -"so_mariadb_host" : "10.42.6.13", -"so_mariadb_user" : "root", -"so_mariadb_password" : "secretpassword", -"so_mariadb_db" : "catalogdb", -"multicloud_url" : "http://10.12.6.235:30280", -"policy_url" : "https://10.12.6.235:30240", -"policy_username" : "testpdp", -"policy_password" : "alpha123", -"policy_models_directory" : "/root/automation_stuff/optf-osdf/osdf/models/policy/placement/tosca_upload/", -"policy_directory" : "/root/automation_stuff/vfw_policies", -"policy_scope" : "OSDF_CASABLANCA", -"policy_onapName" : "SampleDemo", -"policy_config_type": "MicroService", -"policy_pdp_group" : "default", -"//" : "Put in a temp resource module name, should be the same in policy files, script will replace it in policies", -"temp_resource_module_name" : "resource_name", - -"//" : "#Parameters required to create cloud complex", -"complex_name" : "clli1", -"street1" : "street1", -"street2" : "street2", -"physical_location" : "phy_type", -"data_center_code" : "code1", -"latitude" : "32.89948", -"longitude" : "97.045443", -"lata" : "example-lata-val-28399", -"elevation" : "example-elevation-val-28399", -"region" : "northwest", -"state" : "oregon", -"city" : "hillsboro", -"postal-code" : "00000", -"country" : "USA", -"identity_url" : "example-identity-url-val-56898", - -"//" : "#Dictionary containing cloud regions and their Parameters", - - - "cloud_region_data":{ - "ONAP-POD-01-Rail-05":{ - "cloud-region-version" : "titanium_cloud", - "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62784e9bc7", - "service-url": "http://10.12.11.1:5000/v3", - "user-name":"${cloud-username}", - "password":"${cloud-password}", - "system-type": "VIM", - "ssl-insecure":true, - "cloud-domain":"Default", - "default-tenant":"Integration-HPA", - "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", - "cloud-type" : "openstack", - "identity-url": "WillBeUpdatedByMultiCloud", - "system-status":"active" - }, - - "ONAP-POD-01-Rail-06":{ - "cloud-region-version" : "titanium_cloud", - "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", - "service-url": "http://10.12.11.1:5000/v3", - "user-name":"${cloud-username}", - "password":"${cloud-password}", - "system-type": "VIM", - "ssl-insecure":true, - "cloud-domain":"Default", - "default-tenant":"Integration-HPA", - "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", - "cloud-type" : "openstack", - "identity-url": "WillBeUpdatedByMultiCloud", - "system-status":"active" - }, - - "ONAP-POD-01-Rail-07":{ - "cloud-region-version" : "titanium_cloud", - "esr-system-info-id":"4c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", - "service-url": "http://10.12.11.1:5000/v3", - "user-name":"${cloud-username}", - "password":"${cloud-password}", - "system-type": "VIM", - "ssl-insecure":true, - "cloud-domain":"Default", - "default-tenant":"Integration-HPA", - "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", - "cloud-type" : "openstack", - "identity-url": "WillBeUpdatedByMultiCloud", - "system-status":"active" - } - }, - - -"//" : "#Parameters to register cloud region", -"cloud-owner" : "CloudOwner", -"owner-defined-type" : "t1", -"cloud-zone" : "CloudZone", - -"service_name" : "vFW", -"customer_name" : "hpa_cust", -"subscriber_name" : "hpa_cust", - -"//" : "Onboarding parameters", -"vendor-name" : "hpa-vendor", -"entitlement-pool-name" : "hpa-pool", -"entitlement-description" : "hpa-pool", -"start-date" : "04/23/2019", -"expiry-date" : "12/31/2040", -"key-group-name" : "hpa-key", -"key-group-type" : "Universal", -"feature-grp-name" : "hpa-feature", -"feature-grp-desc" : "hpa-feature", -"part-no" : "hpa-part", -"agreement-name" : "hpa-agreement", -"agreement-desc" : "hpa-agreement", - -"onboarding-method" : "NetworkPackage", -"vsp-name" : "hpa-vsp", -"vsp-desc" : "hpa-vsp-desc", -"vsp-version" : "1.0", - -"vf-name" : "hpa-vf", -"vf-description" : "hpa-vf", -"vf-remarks" :"remarkss", -"vf-version" : "1.0", - -"//" : "Be sure to include single quotes in parameters that have spaces", -"project-code" : "000000", -"service-model-name" : "vfw-hpa", -"service-model-desc" : "'hpa service model'", -"icon-id" : "network_l_1-3", -"category-display" : "'Network L1-3'", -"category" : "'network l1-3'", - -"service-test-remarks" : "test", -"service-accept-remarks" : "accepted", -"service-approve-remarks" : "approved", - - -"//" : "service instance parameters", -"instance-name" : "hpa-instance", -"requestor-id" : "demo", -"customer-latitude":"32.897480", -"customer-longitude":"97.040443", -"company-name":"some_company", -"homing-solution" : "oof", -"orchestrator" : "multicloud", -"owning-entity-name":"OE-Demonstration", -"projectName" : "Project-Demonstration", -"a-la-carte" : true, -"test-api" : "VNF_API", - -"//" : "vnf parameters", -"platform-name" : "Platform-Demonstration", -"lob-name" : "LOB-Demonstration", -"generic-vnf-name" : "vfw-hpa-vnf", - -"vf-module-name" : "vfw-sriov-cli", -"supress-rollback" : "false", -"use-preload" : "true" -} diff --git a/test/hpa_automation/tosca/hpa_automation.py b/test/hpa_automation/tosca/hpa_automation.py new file mode 100755 index 000000000..ff53303bc --- /dev/null +++ b/test/hpa_automation/tosca/hpa_automation.py @@ -0,0 +1,183 @@ +#!/usr/bin/python + +#Prerequisites for machine to run this +#Put in required parameters in hpa_automation_config.json +#Install python-pip (apt install python-pip) +#Install python mysql.connector (pip install mysql-connector-python) +#Install ONAP CLI +#Must have connectivity to the ONAP, a k8s vm already running is recommended +#Create Preload File, the script will modify the parameters required from serivce model, service instance +#and vnf instance +#Create policies for homing +#Put in CSAR file +#modify so-bpmn configmap and change version to v2 + +import json +import os +import time +import argparse +import sys + +def get_parameters(file): + parameters = json.load(file) + return parameters + +def get_out_helper(in_string): + out_list = (((in_string.replace('-','')).replace('|', '')).replace('+', '')).split() + return out_list + +def get_out_helper_2(in_string): + out_list = ((in_string.replace('|', '')).replace('+', '')).split() + return out_list + +def set_open_cli_env(parameters): + os.environ["OPEN_CLI_PRODUCT_IN_USE"] = parameters["open_cli_product"] + os.environ["OPEN_CLI_HOME"] = parameters["open_cli_home"] + +def create_complex(parameters): + complex_create_string = "oclip complex-create -j {} -r {} -x {} -y {} -lt {} -l {} -i {} -lo {} \ + -S {} -la {} -g {} -w {} -z {} -k {} -o {} -q {} -m {} -u {} -p {}".format(parameters["street2"], \ + parameters["physical_location"], parameters["complex_name"], \ + parameters["data_center_code"], parameters["latitude"], parameters["region"], \ + parameters["street1"], parameters["longitude"], parameters["state"], \ + parameters["lata"], parameters["city"], parameters["postal-code"], \ + parameters["complex_name"], parameters["country"], parameters["elevation"], \ + parameters["identity_url"], parameters["aai_url"], parameters["aai_username"], \ + parameters["aai_password"]) + + os.system(complex_create_string) + + +def register_cloud_helper(cloud_region, values, parameters): + #Create Cloud + cloud_create_string = 'oclip cloud-create -e {} -b {} -I {{\\\\\\"openstack-region-id\\\\\\":\\\\\\"{}\\\\\\"}} \ + -x {} -y {} -j {} -w {} -l {} -url {} -n {} -q {} -r {} -Q {} -i {} -g {} -z {} -k {} -c {} -m {} -u {} -p {}'.format( + values.get("esr-system-info-id"), values.get("user-name"), cloud_region, parameters["cloud-owner"], \ + cloud_region, values.get("password"), values.get("cloud-region-version"), values.get("default-tenant"), \ + values.get("service-url"), parameters["complex_name"], values.get("cloud-type"), parameters["owner-defined-type"], \ + values.get("system-type"), values.get("identity-url"), parameters["cloud-zone"], values.get("ssl-insecure"), \ + values.get("system-status"), values.get("cloud-domain"), parameters["aai_url"], parameters["aai_username"], \ + parameters["aai_password"]) + + + os.system(cloud_create_string) + + #Associate Cloud with complex + complex_associate_string = "oclip complex-associate -x {} -y {} -z {} -m {} -u {} -p {}".format(parameters["complex_name"], \ + cloud_region, parameters["cloud-owner"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) + os.system(complex_associate_string) + + #Register Cloud with Multicloud + multicloud_register_string = "oclip multicloud-register-cloud -y {} -x {} -m {}".format(parameters["cloud-owner"], \ + cloud_region, parameters["multicloud_url"]) + os.system(multicloud_register_string) + +def register_all_clouds(parameters): + cloud_dictionary = parameters["cloud_region_data"] + for cloud_region, cloud_region_values in cloud_dictionary.iteritems(): + register_cloud_helper(cloud_region, cloud_region_values, parameters) + +#VNF Deployment Section +def add_policies(parameters): + resource_string = (os.popen("oclip get-resource-module-name -u {} -p {} -m {} |grep {}".format(\ + parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"], \ + parameters["service-model-name"] ))).read() + resource_module_name = (get_out_helper_2(resource_string))[1] + + #Put in the right resource module name in all policies located in parameters["policy_directory"] + os.system("find {}/ -type f -exec sed -i 's/{}/{}/g' {{}} \;".format( + parameters["policy_directory"], parameters["temp_resource_module_name"], resource_module_name)) + + #Upload policy models + for model in os.listdir(parameters["policy_models_directory"]): + os.system("oclip policy-type-create -x {} -u {} -p {} -m {}".format(model, parameters["policy_username"], \ + parameters["policy_password"], parameters["policy_url"])) + time.sleep(0.5) + + #print("Put in the resourceModuleName {} in your policy files in {}. ".format(resource_module_name, \ + #(parameters["policy_directory"]))) + #raw_input("Press Enter to continue...") + + + #Loop through policy, put in resource_model_name and create policies + for policy in os.listdir(parameters["policy_directory"]): + policy_name = "{}.{}".format(parameters["policy_scope"], os.path.splitext(policy)[0]) + policy_file = (os.path.join(parameters["policy_directory"], policy)) + #Create policy + os.system("oclip policy-create-outdated -m {} -u {} -p {} -x {} -S {} -T {} -o {} -b $(cat {})".format(parameters["policy_url"],\ + parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_scope"], \ + parameters["policy_config_type"], parameters["policy_onapName"], policy_file)) + + #Push policy + os.system("oclip policy-push-outdated -m {} -u {} -p {} -x {} -b {} -c {}".format(parameters["policy_url"], \ + parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_config_type"],\ + parameters["policy_pdp_group"])) + +def onboard_vnf(parameters): + ns_csars = parameters["vnd-csars"] + vnf_onboard_outs = {} + + for key, value in ns_csars.items(): + vnf_onboard_string = 'oclip vfc-catalog-onboard-vnf -c {}'.format(value) + vnf_onboard_outs["key"] = (os.popen(ns_onboard_string)).read() + return vnf_onboard_outs + +def onboard_ns(parameters): + ns_onboard_string = 'oclip vfc-catalog-onboard-ns -c {}'.format(parameters["ns-csar-id"]) + ns_onboard_out = (os.popen(ns_onboard_string)).read() + return ns_onboard_out + +def create_ns(parameters): + ns_create_string = 'oclip vfc-nslcm-create -c {} -n {}'.format(parameters["ns-csar-id"], \ + parameters["ns-csar-name"]) + ns_create_out = (os.popen(ns_create_string)).read() + ns_instance_id = (get_out_helper_2(ns_create_out))[1] + ns_model_dict["vnf_instance_id"] = ns_instance_id + return ns_model_dict + +def instantiate_ns(parameters, ns_model_dict): + ns_instance_id = ns_model_dict["ns_instance_id"] + ns_instantiate_string = 'oclip vfc-nslcm-instantiate -i {} -c {} -n {}'.format(ns_instance_id, \ + parameters["location-constraints"], parameters["sdc-controller-id"]) + ns_instantiate_out = (os.popen(ns_instantiate_string)).read() + return ns_instantiate_out + +#Run Functions +parser = argparse.ArgumentParser() +parser.add_argument('-f', action='store', dest='config_file_path', help='Store config file path') + +parser.add_argument('--version', action='version', version='%(prog)s 1.0') + +results = parser.parse_args() + +config_file_path = results.config_file_path +if config_file_path is None: + sys.exit(1) +config_file = open(config_file_path) +parameters = get_parameters(config_file) + +# 1.Set cli command envionment +set_open_cli_env(parameters) + +# 2.Create cloud complex +create_complex(parameters) + +# 3.FIXME:Because SDC internal API will change without notice, so I will maually design VNF and Service. +# SDC output data model is not align with VFC, we use an workaround method +# We just do run time automation + +# 4.Register all clouds +register_all_clouds(parameters) + +# 5.add_policies function not currently working, using curl commands +# add_policies(parameters) + +# 6. VFC part +vnf_onboard_output = onboard_vnf(parameters) +print vnf_onboard_output +ns_onboard_out = onboard_ns(parameters) +print ns_onboard_out +ns_model_dict = create_ns(parameters) +print ns_model_dict +instantiate_ns_output = instantiate_ns(parameters, ns_model_dict) +print instantiate_ns_output diff --git a/test/hpa_automation/tosca/vcpe_config.json b/test/hpa_automation/tosca/vcpe_config.json new file mode 100755 index 000000000..bfdbb0d6b --- /dev/null +++ b/test/hpa_automation/tosca/vcpe_config.json @@ -0,0 +1,139 @@ +{ + "open_cli_product" : "onap-dublin", + "open_cli_home" : "/root/cli/deployment/zip/target/deployunzip", + "aai_url" : "https://10.12.6.235:30233", + "aai_username" : "AAI", + "aai_password" : "AAI", + "sdc_catalog_url" : "http://10.12.6.235:30205", + "sdc_password" : "demo123456!", + "sdc_creator" : "cs0008", + + "multicloud_url" : "http://10.12.6.235:30280", + "policy_url" : "https://10.12.6.235:30240", + "policy_username" : "testpdp", + "policy_password" : "alpha123", + "policy_models_directory" : "/root/tosca/optf-osdf/osdf/models/policy/placement/tosca_upload/", + "policy_directory" : "/root/tosca/vcpe_policies", + "policy_scope" : "OSDF_DUBLIN", + "policy_onapName" : "SampleDemo", + "policy_config_type": "MicroService", + "policy_pdp_group" : "default", + "//" : "Put in a temp resource module name, should be the same in policy files, script will replace it in policies", + "temp_resource_module_name" : "resource_name", + + "//" : "#Parameters required to create cloud complex", + "complex_name" : "clli1", + "street1" : "street1", + "street2" : "street2", + "physical_location" : "phy_type", + "data_center_code" : "code1", + "latitude" : "32.89948", + "longitude" : "97.045443", + "lata" : "example-lata-val-28399", + "elevation" : "example-elevation-val-28399", + "region" : "northwest", + "state" : "oregon", + "city" : "hillsboro", + "postal-code" : "00000", + "country" : "USA", + "identity_url" : "example-identity-url-val-56898", + "service-model-name" : "vfw-hpa", + "//" : "#Dictionary containing cloud regions and their Parameters", + + "cloud_region_data":{ + "ONAP-POD-01-Rail-05":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62784e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + }, + "ONAP-POD-01-Rail-06":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"5c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + }, + "ONAP-POD-01-Rail-07":{ + "cloud-region-version" : "titanium_cloud", + "esr-system-info-id":"4c85ce1f-aa78-4ebf-8d6f-4b62773e9bc7", + "service-url": "http://10.12.11.1:5000/v3", + "user-name":"${cloud-username}", + "password":"${cloud-password}", + "system-type": "VIM", + "ssl-insecure":true, + "cloud-domain":"Default", + "default-tenant":"Integration-HPA", + "tenant-id" : "709ba629fe194f8699b12f9d6ffd86a0", + "cloud-type" : "openstack", + "identity-url": "WillBeUpdatedByMultiCloud", + "system-status":"active" + } + }, + + "//" : "#Parameters to register cloud region", + "cloud-owner" : "CloudOwner", + "owner-defined-type" : "t1", + "cloud-zone" : "CloudZone", + + "//" : "#Parameters to vfc", + "vnd-csars":{ + "vnf-vgw-csar-id": "You need change it", + "vnf-vgmux-csar-id": "You need change it", + "vnf-infra-csar-id": "You need change it", + "vnf-vbng-csar-id": "You need change it", + "vnf-vbrgemu-csar-id": "You need change it" + }, + "ns-csar-id": "You need change it", + "ns-csar-name": "vcpe", + "location-constraints":[ + { + "vnfProfileId": "3fca3543-07f5-492f-812c-ed462e4f94f4", + "locationConstraints": { + "vimId": "INTEL_ONAP-POD-01-Rail-07" + } + }, + { + "vnfProfileId": "0408f076-e6c0-4c82-9940-272fddbb82de", + "locationConstraints": { + "vimId": "INTEL_ONAP-POD-01-Rail-07" + } + }, + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1100", + "locationConstraints": { + "vimId": "INTEL_ONAP-POD-01-Rail-07" + } + }, + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1101", + "locationConstraints": { + "vimId": "INTEL_ONAP-POD-01-Rail-07" + } + }, + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1102", + "locationConstraints": { + "vimId": "INTEL_ONAP-POD-01-Rail-07" + } + } + ], + "sdc-controller-id": "2" +} -- cgit 1.2.3-korg