aboutsummaryrefslogtreecommitdiffstats
path: root/test/hpa_automation/tosca/hpa_automation.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/hpa_automation/tosca/hpa_automation.py')
-rwxr-xr-xtest/hpa_automation/tosca/hpa_automation.py151
1 files changed, 145 insertions, 6 deletions
diff --git a/test/hpa_automation/tosca/hpa_automation.py b/test/hpa_automation/tosca/hpa_automation.py
index b83d3eb75..26ee834f6 100755
--- a/test/hpa_automation/tosca/hpa_automation.py
+++ b/test/hpa_automation/tosca/hpa_automation.py
@@ -48,6 +48,138 @@ def create_complex(parameters):
os.system(complex_create_string)
+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):
+ vnfs = parameters["vnf"]
+ vsp_dict = {}
+ for name, value in vnfs.iteritems():
+ 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" ], value.get("vsp-name"), value.get("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, value.get("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"]))
+
+ vsp_ids[name] = vsp_id
+ return vsp_ids
+
+def create_vf_model(parameters, vsp_dict):
+ vnfs = parameters["vnfs"]
+ vf_dict = {}
+ for name, value in vnfs.iteritems():
+ create_string = "oclip vf-model-create -y {} -g {} -x {} -z {} -b {} -u {} -p {} -m {}".format(value.get("vf-description"), \
+ value.get("vsp-version"), value.get("vf-name"), parameters["vendor-name"], vsp_dict[name], \
+ 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"], value.get("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, value.get("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"], value.get("vf-name")))).read()
+ output = (get_out_helper_2(output))
+
+ vf_dict[name] = output[1]
+
+ return vf_dict
+
+
+def create_service_model(parameters, vf_dict):
+ vnfs = parameters["vnfs"]
+
+ 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]
+
+ for name, value in vnfs.iteritems():
+ os.system("oclip service-model-add-vf -x {} -b {} -y {} -z {} -u {} -p {} -m {}".format(service_model_id, \
+ parameters["vf-version"], vf_dict[name], value.get("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
def register_cloud_helper(cloud_region, values, parameters):
#Create Cloud
@@ -203,13 +335,14 @@ def upload_vnf_package(parameters, vnf_package_output):
#Run Functions
parser = argparse.ArgumentParser()
parser.add_argument('-f', action='store', dest='config_file_path', help='Store config file path')
-parser.add_argument('-t', action='store', dest='type', help='Store config file path')
+parser.add_argument('-t', action='store', dest='model', 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
+model = results.model
if config_file_path is None:
sys.exit(1)
config_file = open(config_file_path)
@@ -234,12 +367,17 @@ register_vnfm(parameters)
# We just do run time automation
ns_package_output = ""
-if type == "sdc":
+if model == "sdc":
print "use csar file is distributed by sdc"
- # vnf_onboard_output = onboard_vnf(parameters)
- # print vnf_onboard_output
- # ns_onboard_out = onboard_ns(parameters)
- # print ns_onboard_out
+ output = create_vlm(parameters)
+ vsp_dict = create_vsp(parameters, output)
+ vf_dict = create_vf_model(parameters, vsp_dict)
+ service_model_list = create_service_model(parameters, vf_dict)
+ #
+ vnf_onboard_output = onboard_vnf(parameters)
+ print vnf_onboard_output
+ ns_onboard_out = onboard_ns(parameters)
+ print ns_onboard_out
else:
print "use csar file is uploaded by local"
vnf_package_output = create_vnf_package(parameters)
@@ -256,6 +394,7 @@ else:
# 7. VFC part
ns_instance_id = create_ns(parameters, ns_package_output)
+ns_instance_id = "d0ecc83f-339f-4621-b565-07eb9090a379"
print ns_instance_id
instantiate_ns_output = instantiate_ns(parameters, ns_instance_id)
print instantiate_ns_output