Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | #Prerequisites for machine to run this |
| 4 | #Put in required parameters in hpa_automation_config.json |
| 5 | #Install python-pip (apt install python-pip) |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 6 | #Install python mysql.connector (pip install --no-cache-dir mysql-connector-python) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 7 | #Install ONAP CLI |
| 8 | #Must have connectivity to the ONAP, a k8s vm already running is recommended |
| 9 | #Create Preload File, the script will modify the parameters required from serivce model, service instance |
| 10 | #and vnf instance |
| 11 | #Create policies for homing |
| 12 | #Put in CSAR file |
| 13 | #modify so-bpmn configmap and change version to v2 |
| 14 | |
| 15 | import json |
| 16 | import os |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 17 | import argparse |
| 18 | import sys |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 19 | import requests |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 20 | import mysql.connector |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 21 | |
| 22 | def get_parameters(file): |
| 23 | parameters = json.load(file) |
| 24 | return parameters |
| 25 | |
| 26 | def get_out_helper(in_string): |
| 27 | out_list = (((in_string.replace('-','')).replace('|', '')).replace('+', '')).split() |
| 28 | return out_list |
| 29 | |
| 30 | def get_out_helper_2(in_string): |
| 31 | out_list = ((in_string.replace('|', '')).replace('+', '')).split() |
| 32 | return out_list |
| 33 | |
| 34 | def set_open_cli_env(parameters): |
| 35 | os.environ["OPEN_CLI_PRODUCT_IN_USE"] = parameters["open_cli_product"] |
| 36 | os.environ["OPEN_CLI_HOME"] = parameters["open_cli_home"] |
| 37 | |
| 38 | def create_complex(parameters): |
| 39 | complex_create_string = "oclip complex-create -j {} -r {} -x {} -y {} -lt {} -l {} -i {} -lo {} \ |
| 40 | -S {} -la {} -g {} -w {} -z {} -k {} -o {} -q {} -m {} -u {} -p {}".format(parameters["street2"], \ |
| 41 | parameters["physical_location"], parameters["complex_name"], \ |
| 42 | parameters["data_center_code"], parameters["latitude"], parameters["region"], \ |
| 43 | parameters["street1"], parameters["longitude"], parameters["state"], \ |
| 44 | parameters["lata"], parameters["city"], parameters["postal-code"], \ |
| 45 | parameters["complex_name"], parameters["country"], parameters["elevation"], \ |
| 46 | parameters["identity_url"], parameters["aai_url"], parameters["aai_username"], \ |
| 47 | parameters["aai_password"]) |
| 48 | |
| 49 | os.system(complex_create_string) |
| 50 | |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 51 | def create_vlm(parameters): |
| 52 | vlm_create_string = "oclip vlm-create -x {} -u {} -p {} -m {}".format(parameters["vendor-name"], \ |
| 53 | parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) |
| 54 | command_out = (os.popen(vlm_create_string)).read() |
| 55 | out_list = get_out_helper(command_out) |
| 56 | vlm_id = out_list[3] |
| 57 | vlm_version = out_list[5] |
| 58 | |
| 59 | entitlement_string = "oclip vlm-entitlement-pool-create -x {} -y {} -e {} -z {} -k {} -g {} -l {} -u {} -p {} -m {}".format( \ |
| 60 | parameters["entitlement-pool-name"], vlm_id, vlm_version, parameters["entitlement-description"], parameters["vendor-name"], \ |
| 61 | parameters["expiry-date"], parameters["start-date"], parameters["sdc_creator"], parameters["sdc_password"], \ |
| 62 | parameters["sdc_onboarding_url"]) |
| 63 | command_out = (os.popen(entitlement_string)).read() |
| 64 | entitlement_id = (get_out_helper(command_out))[3] |
| 65 | |
| 66 | |
| 67 | key_group_string = "oclip vlm-key-group-create -c {} -e {} -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, \ |
| 68 | parameters["key-group-name"], parameters["key-group-type"], parameters["sdc_creator"], parameters["sdc_password"], \ |
| 69 | parameters["sdc_onboarding_url"]) |
| 70 | command_out = (os.popen(key_group_string)).read() |
| 71 | key_group_id = (get_out_helper(command_out))[3] |
| 72 | |
| 73 | feature_group_string = "oclip vlm-feature-group-create -x {} -y {} -e {} -z {} -g {} -b {} -c {} -u {} -p {} -m {}".format( |
| 74 | parameters["feature-grp-name"], vlm_id, vlm_version, parameters["feature-grp-desc"], key_group_id, entitlement_id, \ |
| 75 | parameters["part-no"], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"]) |
| 76 | command_out = (os.popen(feature_group_string)).read() |
| 77 | feature_group_id = (get_out_helper(command_out))[3] |
| 78 | |
| 79 | agreement_string = "oclip vlm-aggreement-create -x {} -y {} -e {} -z {} -g {} -u {} -p {} -m {}".format(parameters["agreement-name"], \ |
| 80 | vlm_id, vlm_version, parameters["agreement-desc"], feature_group_id, parameters["sdc_creator"], parameters["sdc_password"], \ |
| 81 | parameters["sdc_onboarding_url"]) |
| 82 | command_out = (os.popen(agreement_string)).read() |
| 83 | agreement_id = (get_out_helper(command_out))[3] |
| 84 | |
| 85 | submit_string = "oclip vlm-submit -x {} -y {} -u {} -p {} -m {}".format(vlm_id, vlm_version, parameters["sdc_creator"], \ |
| 86 | parameters["sdc_password"], parameters["sdc_onboarding_url"]) |
| 87 | os.system(submit_string) |
| 88 | |
| 89 | output = [feature_group_id, agreement_id, vlm_version, vlm_id ] |
| 90 | return output |
| 91 | |
| 92 | def create_vsp(parameters, in_list): |
| 93 | vnfs = parameters["vnf"] |
yangyan | 50fce38 | 2019-09-20 15:47:40 +0800 | [diff] [blame] | 94 | vsp_ids = {} |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 95 | for name, value in vnfs.iteritems(): |
| 96 | create_string = "oclip vsp-create -j {} -o {} -e {} -x {} -y {} -i {} -c {} -g {} -u {} -p {} -m {}".format( in_list[0], \ |
yangyan | 50fce38 | 2019-09-20 15:47:40 +0800 | [diff] [blame] | 97 | parameters["onboarding-method"], parameters["vendor-name"], value.get("vsp-name"), value.get("vsp-desc"), in_list[1], \ |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 98 | in_list[2], in_list[3], parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"] ) |
| 99 | command_out = (os.popen(create_string)).read() |
| 100 | out_list = get_out_helper(command_out) |
| 101 | vsp_id = out_list[3] |
| 102 | vsp_version = out_list[5] |
| 103 | |
| 104 | os.system("oclip vsp-add-artifact -x {} -y {} -z {} -u {} -p {} -m {}".format(vsp_id, vsp_version, value.get("path"), \ |
| 105 | parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_onboarding_url"])) |
| 106 | |
| 107 | os.system("oclip vsp-validate -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ |
| 108 | parameters["sdc_password"], parameters["sdc_onboarding_url"])) |
| 109 | |
| 110 | os.system("oclip vsp-submit -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ |
| 111 | parameters["sdc_password"], parameters["sdc_onboarding_url"])) |
| 112 | |
| 113 | os.system("oclip vsp-package -x {} -y {} -u {} -p {} -m {}".format(vsp_id, vsp_version, parameters["sdc_creator"], \ |
| 114 | parameters["sdc_password"], parameters["sdc_onboarding_url"])) |
| 115 | |
| 116 | vsp_ids[name] = vsp_id |
| 117 | return vsp_ids |
| 118 | |
| 119 | def create_vf_model(parameters, vsp_dict): |
| 120 | vnfs = parameters["vnfs"] |
| 121 | vf_dict = {} |
| 122 | for name, value in vnfs.iteritems(): |
| 123 | create_string = "oclip vf-model-create -y {} -g {} -x {} -z {} -b {} -u {} -p {} -m {}".format(value.get("vf-description"), \ |
| 124 | value.get("vsp-version"), value.get("vf-name"), parameters["vendor-name"], vsp_dict[name], \ |
| 125 | parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"]) |
| 126 | os.system(create_string) |
| 127 | |
| 128 | output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ |
| 129 | parameters["sdc_creator"], parameters["sdc_password"], value.get("vf-name")))).read() |
| 130 | output = (get_out_helper_2(output)) |
| 131 | |
| 132 | vf_unique_id = output[1] |
| 133 | |
| 134 | os.system("oclip vf-model-certify -b {} -r {} -u {} -p {} -m {}".format(vf_unique_id, value.get("vf-remarks"), \ |
| 135 | parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 136 | |
| 137 | #Check for new parameters after certification |
| 138 | output = (os.popen("oclip vf-model-list -m {} -u {} -p {} | grep {}".format(parameters["sdc_catalog_url"], \ |
| 139 | parameters["sdc_creator"], parameters["sdc_password"], value.get("vf-name")))).read() |
| 140 | output = (get_out_helper_2(output)) |
| 141 | |
| 142 | vf_dict[name] = output[1] |
| 143 | |
| 144 | return vf_dict |
| 145 | |
| 146 | |
| 147 | def create_service_model(parameters, vf_dict): |
| 148 | vnfs = parameters["vnfs"] |
| 149 | |
| 150 | create_string = "oclip service-model-create -z {} -y {} -e {} -x {} -c {} -b {} -u {} -p {} -m {} |grep ID".format(parameters["project-code"], \ |
| 151 | parameters["service-model-desc"], parameters["icon-id"], parameters["service-model-name"], parameters["category-display"], \ |
| 152 | parameters["category"],parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"]) |
| 153 | |
| 154 | service_model_id = (get_out_helper_2((os.popen(create_string)).read()))[1] |
| 155 | |
| 156 | for name, value in vnfs.iteritems(): |
| 157 | os.system("oclip service-model-add-vf -x {} -b {} -y {} -z {} -u {} -p {} -m {}".format(service_model_id, \ |
| 158 | parameters["vf-version"], vf_dict[name], value.get("vf-name"), parameters["sdc_creator"], \ |
| 159 | parameters["sdc_password"], parameters["sdc_catalog_url"] )) |
| 160 | |
| 161 | os.system("oclip service-model-test-request -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-test-remarks"], \ |
| 162 | parameters["sdc_creator"], parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 163 | |
| 164 | os.system("oclip service-model-test-start -b {} -u {} -p {} -m {}".format(service_model_id, parameters["sdc_tester"], \ |
| 165 | parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 166 | |
| 167 | os.system("oclip service-model-test-accept -b {} -r {} -u {} -p {} -m {}".format(service_model_id, parameters["service-accept-remarks"], \ |
| 168 | parameters["sdc_tester"], parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 169 | |
| 170 | #Get uniqueId for the service model |
| 171 | service_model_values = (os.popen("oclip service-model-list -u {} -p {} -m {} |grep {}".format(parameters["sdc_creator"], \ |
| 172 | parameters["sdc_password"], parameters["sdc_catalog_url"], parameters["service-model-name"]))).read() |
| 173 | service_model_values = get_out_helper_2(service_model_values) |
| 174 | service_model_uniqueId = (service_model_values)[1] |
| 175 | |
| 176 | os.system("oclip service-model-approve -b {} -r {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["service-approve-remarks"], \ |
| 177 | parameters["sdc_governor"], parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 178 | |
| 179 | os.system("oclip service-model-distribute -b {} -u {} -p {} -m {}".format(service_model_uniqueId, parameters["sdc_operator"], \ |
| 180 | parameters["sdc_password"], parameters["sdc_catalog_url"])) |
| 181 | |
| 182 | return service_model_values |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 183 | |
| 184 | def register_cloud_helper(cloud_region, values, parameters): |
| 185 | #Create Cloud |
| 186 | cloud_create_string = 'oclip cloud-create -e {} -b {} -I {{\\\\\\"openstack-region-id\\\\\\":\\\\\\"{}\\\\\\"}} \ |
| 187 | -x {} -y {} -j {} -w {} -l {} -url {} -n {} -q {} -r {} -Q {} -i {} -g {} -z {} -k {} -c {} -m {} -u {} -p {}'.format( |
| 188 | values.get("esr-system-info-id"), values.get("user-name"), cloud_region, parameters["cloud-owner"], \ |
| 189 | cloud_region, values.get("password"), values.get("cloud-region-version"), values.get("default-tenant"), \ |
| 190 | values.get("service-url"), parameters["complex_name"], values.get("cloud-type"), parameters["owner-defined-type"], \ |
| 191 | values.get("system-type"), values.get("identity-url"), parameters["cloud-zone"], values.get("ssl-insecure"), \ |
| 192 | values.get("system-status"), values.get("cloud-domain"), parameters["aai_url"], parameters["aai_username"], \ |
| 193 | parameters["aai_password"]) |
| 194 | |
| 195 | |
| 196 | os.system(cloud_create_string) |
| 197 | |
| 198 | #Associate Cloud with complex |
| 199 | complex_associate_string = "oclip complex-associate -x {} -y {} -z {} -m {} -u {} -p {}".format(parameters["complex_name"], \ |
| 200 | cloud_region, parameters["cloud-owner"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) |
| 201 | os.system(complex_associate_string) |
| 202 | |
| 203 | #Register Cloud with Multicloud |
| 204 | multicloud_register_string = "oclip multicloud-register-cloud -y {} -x {} -m {}".format(parameters["cloud-owner"], \ |
| 205 | cloud_region, parameters["multicloud_url"]) |
| 206 | os.system(multicloud_register_string) |
| 207 | |
| 208 | def register_all_clouds(parameters): |
| 209 | cloud_dictionary = parameters["cloud_region_data"] |
| 210 | for cloud_region, cloud_region_values in cloud_dictionary.iteritems(): |
| 211 | register_cloud_helper(cloud_region, cloud_region_values, parameters) |
| 212 | |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 213 | def create_service_type(parameters): |
| 214 | create_string = "oclip service-type-create -x {} -m {} -u {} -p {}".format( parameters["service_name"], \ |
| 215 | parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) |
| 216 | os.system(create_string) |
| 217 | |
| 218 | def create_customer(parameters): |
| 219 | create_string = "oclip customer-create -x {} -y {} -m {} -u {} -p {}".format( parameters["customer_name"], \ |
| 220 | parameters["subscriber_name"], parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) |
| 221 | os.system(create_string) |
| 222 | |
| 223 | def add_customer_subscription(parameters): |
| 224 | subscription_check = 0 |
| 225 | for cloud_region, cloud_region_values in (parameters["cloud_region_data"]).iteritems(): |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 226 | if subscription_check == 0 : |
| 227 | subscription_string = "oclip subscription-create -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ |
| 228 | parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ |
| 229 | cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) |
| 230 | else: |
| 231 | subscription_string = "oclip subscription-cloud-add -x {} -c {} -z {} -e {} -y {} -r {} -m {} -u {} -p {}".format(\ |
| 232 | parameters["customer_name"], cloud_region_values.get("tenant-id"), parameters["cloud-owner"], parameters["service_name"],\ |
| 233 | cloud_region_values.get("default-tenant"), cloud_region, parameters["aai_url"], parameters["aai_username"], parameters["aai_password"] ) |
| 234 | os.system(subscription_string) |
| 235 | subscription_check+=1 |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 236 | |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 237 | def register_vnfm_helper(vnfm_key, values, parameters): |
| 238 | #Create vnfm |
| 239 | vnfm_create_string = 'oclip vnfm-create -b {} -c {} -e {} -v {} -g {} -x {} -i {} -j {} -q {} \ |
| 240 | -m {} -u {} -p {}'.format(vnfm_key, values.get("type"), values.get("vendor"), \ |
| 241 | values.get("version"), values.get("url"), values.get("vim-id"), \ |
| 242 | values.get("user-name"), values.get("user-password"), values.get("vnfm-version"), \ |
| 243 | parameters["aai_url"], parameters["aai_username"], parameters["aai_password"]) |
| 244 | |
| 245 | os.system(vnfm_create_string) |
| 246 | |
| 247 | def register_vnfm(parameters): |
| 248 | vnfm_params = parameters["vnfm_params"] |
| 249 | for vnfm_key, vnfm_values in vnfm_params.iteritems(): |
| 250 | register_vnfm_helper(vnfm_key, vnfm_values, parameters) |
| 251 | |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 252 | def add_policy_models(): |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 253 | mydb = mysql.connector.connect( |
| 254 | host="policydb", |
| 255 | user="policy_user", |
| 256 | passwd="policy_user", |
| 257 | database="onap_sdk", |
| 258 | ) |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 259 | |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 260 | mycursor = mydb.cursor() |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 261 | hpa_sql = "INSERT INTO optimizationmodels (modelname, description, dependency, imported_by, \ |
| 262 | attributes, ref_attributes, sub_attributes, version, annotation, enumValues, \ |
| 263 | dataOrderInfo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" |
| 264 | hpa_val = ('hpaPolicy', 'HPA Tests Model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 265 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,resources=MANY-true,flavorFeatures=flavorFeatures_properties:MANY-true:description-null', \ |
| 266 | '{"directives_properties":{"attributes":"directives_attributes_properties:required-false:MANY-true:description-null",\ |
| 267 | "type":"string:defaultValue-null:required-false:MANY-false:description-null"},\ |
| 268 | "directives_attributes_properties":{"attribute_name":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 269 | "attribute_value":"string:defaultValue-null:required-false:MANY-false:description-null"},\ |
| 270 | "flavorProperties_properties":{"score":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 271 | "hpa-feature-attributes":"hpa-feature-attributes_properties:required-true:MANY-true:description-null",\ |
| 272 | "directives":"directives_properties:required-true:MANY-true:description-null",\ |
| 273 | "hpa-version":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 274 | "hpa-feature":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 275 | "mandatory":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 276 | "architecture":"string:defaultValue-null:required-true:MANY-false:description-null"},\ |
| 277 | "flavorFeatures_properties":{"directives":"directives_properties:required-true:MANY-true:description-null",\ |
| 278 | "flavorProperties":"flavorProperties_properties:required-true:MANY-true:description-null",\ |
| 279 | "id":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 280 | "type":"string:defaultValue-null:required-true:MANY-false:description-null"},\ |
| 281 | "hpa-feature-attributes_properties":{"unit":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 282 | "hpa-attribute-value":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 283 | "hpa-attribute-key":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 284 | "operator":"OPERATOR:defaultValue-null:required-false:MANY-false:description-null"}}', \ |
| 285 | 'test1', 'policyScope=matching-true, policyType=matching-true', \ |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 286 | 'OPERATOR=[<,<equal-sign,>,>equal-sign,equal-sign,!equal-sign,any,all,subset,], POLICYTYPE=[hpa,]', '""') |
| 287 | |
| 288 | mycursor.execute(hpa_sql, hpa_val) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 289 | |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 290 | sql = "INSERT INTO microservicemodels (modelname, description, dependency, imported_by, \ |
| 291 | attributes, ref_attributes, sub_attributes, version, annotation, enumValues, \ |
| 292 | dataOrderInfo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" |
| 293 | val = [ |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 294 | ('distancePolicy', 'distancePolicy', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 295 | 'policyScope=MANY-true,distanceProperties=distanceProperties_properties:MANY-false:description-null,policyType=POLICYTYPE:MANY-false,\ |
| 296 | resources=MANY-true,applicableResources=APPLICABLERESOURCES:MANY-false', \ |
| 297 | '{"distanceProperties_properties":{"locationInfo":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 298 | "distance":"distance_properties:required-true:MANY-false:description-null"},\ |
| 299 | "distance_properties":{"unit":"UNIT:defaultValue-null:required-true:MANY-false:description-null",\ |
| 300 | "value":"string:defaultValue-null:required-true:MANY-false:description-null","operator":"OPERATOR:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 301 | 'test1', 'policyScope=matching-true, policyType=matching-true', \ |
| 302 | 'OPERATOR=[<,<equal-sign,>,>equal-sign,equal-sign,], APPLICABLERESOURCES=[any,all,], POLICYTYPE=[distance_to_location,] ', '""'), |
| 303 | ('optimizationPolicy', 'Optimization policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 304 | 'objectiveParameter=objectiveParameter_properties:MANY-false:description-null,policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,\ |
| 305 | objective=objectiveParameter_properties:MANY-false:description-null', \ |
| 306 | '{"parameterAttributes_properties":{"customerLocationInfo":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 307 | "parameter":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 308 | "resources":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 309 | "weight":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 310 | "operator":"OPERATOR:defaultValue-null:required-true:MANY-false:description-null"},\ |
| 311 | "objectiveParameter_properties":{"parameterAttributes":"parameterAttributes_properties:required-true:MANY-true:description-null",\ |
| 312 | "operator":"OPERATOR:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 313 | 'test1', 'policyScope=matching-true, policyType=matching-true', 'OPERATOR=[*,+,-,/,%,], POLICYTYPE=[placement_optimization,]', '""'), |
| 314 | ('queryPolicy', 'Query policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 315 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,queryProperties=queryProperties_properties:MANY-true:description-null', \ |
| 316 | '{"queryProperties_properties":{"attribute_location":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 317 | "attribute":"string:defaultValue-null:required-true:MANY-false:description-null","value":"string:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 318 | 'test1', 'policyScope=matching-true, policyType=matching-true', 'POLICYTYPE=[request_param_query,]', '""'), |
| 319 | ('vnfPolicy', 'VnfPolicy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 320 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,resources=MANY-true,\ |
| 321 | vnfProperties=vnfProperties_properties:MANY-true:description-null,applicableResources=APPLICABLERESOURCES:MANY-false', \ |
| 322 | '{"vnfProperties_properties":{"serviceType":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 323 | "inventoryProvider":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 324 | "inventoryType":"INVENTORYTYPE:defaultValue-null:required-true:MANY-false:description-null",\ |
| 325 | "customerId":"string:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 326 | 'test1', 'policyScope=matching-true, policyType=matching-true', \ |
| 327 | 'INVENTORYTYPE=[serviceInstanceId,vnfName,cloudRegionId,vimId,], APPLICABLERESOURCES=[any,all,], POLICYTYPE=[vnfPolicy,]', '""'), |
| 328 | ('vim_fit', 'Capacity policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 329 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,capacityProperties=capacityProperties_properties:MANY-false:description-null,\ |
| 330 | resources=MANY-true,applicableResources=APPLICABLERESOURCES:MANY-false', \ |
| 331 | '{"capacityProperties_properties":{"request":"string:defaultValue-null:required-true:MANY-false:description-null",\ |
| 332 | "controller":"string:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 333 | 'test1', 'policyScope=matching-true, policyType=matching-true ', ' APPLICABLERESOURCES=[any,all,], POLICYTYPE=[vim_fit,]', '""'), |
| 334 | ('affinityPolicy', 'Affinity policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 335 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,affinityProperties=affinityProperties_properties:MANY-false:description-null,\ |
| 336 | resources=MANY-true,applicableResources=APPLICABLERESOURCES:MANY-false', \ |
| 337 | '{"affinityProperties_properties":{"qualifier":"QUALIFIER:defaultValue-null:required-true:MANY-false:description-null",\ |
| 338 | "category":"string:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 339 | 'test1', 'policyScope=matching-true, policyType=matching-true ', ' APPLICABLERESOURCES=[any,all,], POLICYTYPE=[zone,], QUALIFIER=[same,different,]', '""'), |
| 340 | ('pciPolicy', 'Pci policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 341 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,resources=MANY-true,pciProperties=pciProperties_properties:MANY-true:description-null', \ |
| 342 | '{"pciProperties_properties":{"pciOptimizationTimeConstraint":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 343 | "pciOptimizationNwConstraint":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 344 | "algoCategory":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 345 | "pciOptmizationAlgoName":"string:defaultValue-null:required-false:MANY-false:description-null",\ |
| 346 | "pciOptimizationPriority":"string:defaultValue-null:required-false:MANY-false:description-null"}}', \ |
| 347 | 'test1', 'olicyScope=matching-true, policyType=matching-true ', ' POLICYTYPE=[pciPolicy,]', '""'), |
| 348 | ('subscriberPolicy', 'Subscriber Policy Model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', \ |
| 349 | 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,properties=properties_properties:MANY-false:description-type of a policy', \ |
| 350 | '{"properties_properties":{"provStatus":"PROVSTATUS:defaultValue-null:required-true:MANY-false:description-null",\ |
| 351 | "subscriberName":"SUBSCRIBERNAME:defaultValue-null:required-true:MANY-false:description-null",\ |
| 352 | "subscriberRole":"SUBSCRIBERROLE:defaultValue-null:required-true:MANY-false:description-null"}}', \ |
| 353 | 'test1', 'policyScope=matching-true, policyType=matching-true, properties=matching-true ', \ |
| 354 | ' SUBSCRIBERNAME=[], SUBSCRIBERROLE=[], POLICYTYPE=[subscriberPolicy,], PROVSTATUS=[]', '""') |
| 355 | ] |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 356 | |
Haibin Huang | 9d72e13 | 2019-05-22 16:20:08 +0800 | [diff] [blame] | 357 | mycursor.executemany(sql, val) |
| 358 | mydb.commit() |
| 359 | print(mycursor.rowcount, "was inserted.") |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 360 | |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 361 | def add_policies(parameters): |
| 362 | #Loop through policy, put in resource_model_name and create policies |
| 363 | for policy in os.listdir(parameters["policy_directory"]): |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 364 | policy_name = "{}.{}".format(parameters["policy_scope"], os.path.splitext(policy)[0]) |
| 365 | policy_file = (os.path.join(parameters["policy_directory"], policy)) |
| 366 | # Create policy |
| 367 | os.system("oclip policy-create-outdated -m {} -u {} -p {} -x {} -S {} -T {} -o {} -b $(cat {})".format(parameters["policy_url"],\ |
| 368 | parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_scope"], \ |
| 369 | parameters["policy_config_type"], parameters["policy_onapName"], policy_file)) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 370 | |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 371 | # Push policy |
| 372 | os.system("oclip policy-push-outdated -m {} -u {} -p {} -x {} -b {} -c {}".format(parameters["policy_url"], \ |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 373 | parameters["policy_username"], parameters["policy_password"], policy_name, parameters["policy_config_type"],\ |
| 374 | parameters["policy_pdp_group"])) |
yangyan | 85c0728 | 2019-09-09 15:27:31 +0800 | [diff] [blame] | 375 | |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 376 | def onboard_vnf(parameters): |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 377 | vnfs = parameters["vnfs"] |
| 378 | vnf_onboard_outputs = {} |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 379 | |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 380 | for key, value in vnfs.items(): |
yangyan | 85c0728 | 2019-09-09 15:27:31 +0800 | [diff] [blame] | 381 | vnf_onboard_string = 'oclip vfc-catalog-onboard-vnf -m {} -c {}'\ |
| 382 | .format(value.get("url"), value.get("csar-id")) |
yangyan | f1d460a | 2019-09-09 10:00:23 +0800 | [diff] [blame] | 383 | vnf_onboard_outputs[key] = (os.popen(vnf_onboard_string)).read() |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 384 | return vnf_onboard_outputs |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 385 | |
| 386 | def onboard_ns(parameters): |
yangyan | 6a5ec68 | 2019-09-09 15:32:43 +0800 | [diff] [blame] | 387 | ns_onboard_string = 'oclip vfc-catalog-onboard-ns -m {} -c {}'.format(parameters["ns"]["url"], |
| 388 | parameters["ns"]["csar-id"]) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 389 | ns_onboard_out = (os.popen(ns_onboard_string)).read() |
| 390 | return ns_onboard_out |
| 391 | |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 392 | def create_ns(parameters, csar_id): |
| 393 | ns = parameters["ns"] |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 394 | ns_create_string = 'oclip vfc-nslcm-create -m {} -c {} -n {} -q {} -S {}'.format(parameters["vfc-url"], \ |
| 395 | csar_id, ns.get("name"), parameters["customer_name"], parameters["service_name"]) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 396 | print(ns_create_string) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 397 | ns_create_out = (os.popen(ns_create_string)).read() |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 398 | print(ns_create_out) |
yangyan | dd95f02 | 2019-09-10 12:11:10 +0800 | [diff] [blame] | 399 | ns_instance_id = (get_out_helper_2(ns_create_out))[4] |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 400 | return ns_instance_id |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 401 | |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 402 | def instantiate_ns(parameters, ns_instance_id): |
| 403 | ns_instantiate_string = 'oclip vfc-nslcm-instantiate -m {} -i {} -c {} -n {}'.format(parameters["vfc-url"], \ |
| 404 | ns_instance_id, parameters["location"], parameters["sdc-controller-id"]) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 405 | print(ns_instantiate_string) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 406 | |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 407 | ns_instantiate_out = (os.popen(ns_instantiate_string)).read() |
| 408 | return ns_instantiate_out |
| 409 | |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 410 | def terminate_ns(parameters, ns_instance_id): |
| 411 | ns_terminate_string = 'oclip vfc-nslcm-terminate -m {} -i {}'.format(parameters["vfc-url"], ns_instance_id) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 412 | print(ns_terminate_string) |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 413 | ns_terminate_out = (os.popen(ns_terminate_string)).read() |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 414 | print(ns_terminate_out) |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 415 | return ns_terminate_out |
| 416 | |
| 417 | def delete_ns(parameters, ns_instance_id): |
| 418 | ns_delete_string = 'oclip vfc-nslcm-delete -m {} -c {}'.format(parameters["vfc-url"], ns_instance_id) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 419 | print(ns_delete_string) |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 420 | ns_delete_out = (os.popen(ns_delete_string)).read() |
| 421 | return ns_delete_out |
| 422 | |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 423 | def create_ns_package(parameters): |
| 424 | ns = parameters["ns"] |
| 425 | create_ns_string = 'oclip vfc-catalog-create-ns -m {} -c {} -e {}'.format(parameters["vfc-url"], \ |
| 426 | ns.get("key"), ns.get("value")) |
| 427 | cmd_out = (os.popen(create_ns_string)).read() |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 428 | out_list = get_out_helper_2(cmd_out) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 429 | return out_list[4] |
| 430 | |
| 431 | def create_vnf_package(parameters): |
| 432 | vnfs = parameters["vnfs"] |
| 433 | outputs = {} |
| 434 | |
| 435 | for vnf_key, vnf_values in vnfs.iteritems(): |
| 436 | create_vnf_string = 'oclip vfc-catalog-create-vnf -m {} -c {} -e {}'.format(parameters["vfc-url"], \ |
| 437 | vnf_values.get("key"), vnf_values.get("value")) |
| 438 | cmd_out = (os.popen(create_vnf_string)).read() |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 439 | out_list = get_out_helper_2(cmd_out) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 440 | outputs[vnf_key] = out_list[4] |
| 441 | |
| 442 | return outputs |
| 443 | |
| 444 | def upload_ns_package(parameters, ns_package_output): |
| 445 | ns = parameters["ns"] |
| 446 | ns_upload_string = '{}/api/nsd/v1/ns_descriptors/{}/nsd_content'.format(parameters["vfc-url"], ns_package_output) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 447 | print(ns_upload_string) |
| 448 | print(ns.get("path")) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 449 | resp = requests.put(ns_upload_string, files={'file': open(ns.get("path"), 'rb')}) |
| 450 | return resp |
| 451 | |
| 452 | def upload_vnf_package(parameters, vnf_package_output): |
| 453 | vnfs = parameters["vnfs"] |
| 454 | for vnf_key, vnf_values in vnfs.iteritems(): |
| 455 | vnf_upload_str = '{}/api/vnfpkgm/v1/vnf_packages/{}/package_content'.format(parameters["vfc-url"], \ |
| 456 | vnf_package_output[vnf_key], vnf_package_output[vnf_key]) |
| 457 | resp = requests.put(vnf_upload_str, files={'file': open(vnf_values.get("path"), 'rb')}) |
| 458 | return resp |
| 459 | |
| 460 | |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 461 | #Run Functions |
| 462 | parser = argparse.ArgumentParser() |
| 463 | parser.add_argument('-f', action='store', dest='config_file_path', help='Store config file path') |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 464 | parser.add_argument('-t', action='store', dest='model', help='Store config file path') |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 465 | |
| 466 | parser.add_argument('--version', action='version', version='%(prog)s 1.0') |
| 467 | |
| 468 | results = parser.parse_args() |
| 469 | |
| 470 | config_file_path = results.config_file_path |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 471 | model = results.model |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 472 | if config_file_path is None: |
| 473 | sys.exit(1) |
| 474 | config_file = open(config_file_path) |
| 475 | parameters = get_parameters(config_file) |
| 476 | |
| 477 | # 1.Set cli command envionment |
| 478 | set_open_cli_env(parameters) |
| 479 | |
| 480 | # 2.Create cloud complex |
| 481 | create_complex(parameters) |
| 482 | |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 483 | # 3.1 Register all clouds |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 484 | register_all_clouds(parameters) |
| 485 | |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 486 | # 3.2 create service and customer |
| 487 | create_service_type(parameters) |
| 488 | create_customer(parameters) |
| 489 | add_customer_subscription(parameters) |
| 490 | |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 491 | # 4.Register vnfm |
| 492 | register_vnfm(parameters) |
| 493 | |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 494 | # 5.create csar file |
| 495 | # 5.1 upload csar file to catalog |
| 496 | # 5.2 FIXME:Because SDC internal API will change without notice, so I will maually design VNF and Service. |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 497 | # SDC output data model is not align with VFC, we use an workaround method |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 498 | # We just do run time automation |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 499 | ns_package_output = "" |
| 500 | |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 501 | if model == "sdc": |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 502 | print("use csar file is distributed by sdc") |
Haibin Huang | 13433a8 | 2019-06-04 16:14:59 +0800 | [diff] [blame] | 503 | # output = create_vlm(parameters) |
| 504 | # vsp_dict = create_vsp(parameters, output) |
| 505 | # vf_dict = create_vf_model(parameters, vsp_dict) |
| 506 | # service_model_list = create_service_model(parameters, vf_dict) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 507 | |
Haibin Huang | 169a51b | 2019-05-22 14:39:08 +0800 | [diff] [blame] | 508 | vnf_onboard_output = onboard_vnf(parameters) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 509 | print(vnf_onboard_output) |
yangyan | dd95f02 | 2019-09-10 12:11:10 +0800 | [diff] [blame] | 510 | ns_out = onboard_ns(parameters) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 511 | print(ns_out) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 512 | else: |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 513 | print("use csar file is uploaded by local") |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 514 | vnf_package_output = create_vnf_package(parameters) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 515 | print(vnf_package_output) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 516 | ns_package_output = create_ns_package(parameters) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 517 | print(ns_package_output) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 518 | upload_vnf_out = upload_vnf_package(parameters, vnf_package_output) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 519 | print(upload_vnf_out) |
yangyan | dd95f02 | 2019-09-10 12:11:10 +0800 | [diff] [blame] | 520 | ns_out = upload_ns_package(parameters, ns_package_output) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 521 | print(ns_out) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 522 | |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 523 | # 6.add_policies function not currently working, using curl commands |
Pratik Raj | afe83ec | 2020-06-06 21:59:32 +0530 | [diff] [blame] | 524 | add_policy_models() |
Haibin Huang | d8d2be9 | 2019-05-23 17:06:06 +0800 | [diff] [blame] | 525 | add_policies(parameters) |
Haibin Huang | 9b51423 | 2019-05-09 14:36:05 +0800 | [diff] [blame] | 526 | |
Haibin Huang | 48dc681 | 2019-05-16 11:51:20 +0000 | [diff] [blame] | 527 | # 7. VFC part |
yangyan | dd95f02 | 2019-09-10 12:11:10 +0800 | [diff] [blame] | 528 | ns_instance_id = create_ns(parameters, ns_out) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 529 | print(ns_instance_id) |
Haibin Huang | ee3b43d | 2019-05-21 10:53:59 +0800 | [diff] [blame] | 530 | instantiate_ns_output = instantiate_ns(parameters, ns_instance_id) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 531 | print(instantiate_ns_output) |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 532 | |
| 533 | #terminate and delete ns; |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 534 | #option args add the end of json file |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 535 | |
| 536 | if sys.argv[3] == "terminate": |
| 537 | terminate_ns_output = terminate_ns(parameters, ns_instance_id) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 538 | print(terminate_ns_output) |
yangyan | 43fdf7b | 2019-09-24 10:51:44 +0800 | [diff] [blame] | 539 | |
| 540 | elif sys.argv[3] == "delete": |
| 541 | delete_ns_output = delete_ns(parameters, ns_instance_id) |
Bartek Grzybowski | 2ee028b | 2020-03-05 14:35:29 +0100 | [diff] [blame] | 542 | print(delete_ns_output) |