def get_order(id): url = "http://%(ecm_host_name)s/ecm_service/orders/%(id)s" % \ {"ecm_host_name": host, "id": id} response = rest_client_util.perform_get(url) is_success, response = utils.process_response(response) meta = {'response': response} if is_success: return True, False, meta return False, False, meta
def deploy_vapp(data): vapp = {} vapp["name"] = data.get("name") vapp["type"] = data.get("type") vapp["flavor"] = data.get("flavor") vapp["description"] = data.get("description") product_info = {} product_info["vendor"] = data.get("vendor") product_info["version"] = data.get("version") vapp["productInfo"] = product_info config_data = [] parameters = data.get("parameters") if parameters: for name, value in parameters.items(): parameter = {} parameter["name"] = name parameter["value"] = value config_data.append(parameter) vapp["configData"] = config_data config_files = [] vapp["configFiles"] = config_files hot_package = {} hot_package["vapp"] = vapp request_body = {} request_body["tenantName"] = "ECM" request_body["vdc"] = {} request_body["vdc"]["id"] = data.get("vdc") request_body["vimZoneName"] = data.get("vim_zone") request_body["hotPackage"] = hot_package hot_package_id = data.get("vnfd_id") url = "http://%(ecm_host_name)s/ecm_service/hotpackages/%(hot_package_id)s/deploy" % \ {"ecm_host_name": host, "hot_package_id": hot_package_id} response = rest_client_util.perform_post(url, json.dumps(request_body)) is_success, response = utils.process_response(response) if is_success: order_id = response["data"]["order"]["id"] timeout_start = time.time() timeout = data.get("timeout", 3600) response, timed_out = utils.wait_for_completion( order_id, timeout_start, timeout) if timed_out: return False, False, response vapp_id = utils.get_vapp_id(response) is_success, response = get_vapp(vapp_id) return True, True, response return False, False, response
def create_service(data): service = {} service["name"] = data.get("name") service["type"] = data.get("type") service["description"] = data.get("description") service["vendor"] = data.get("vendor") service["version"] = data.get("version") service["vdc"] = data.get("vdc") if data.get("vapps") is not None: vapps = [] for item in data.get("vapps"): vapps.append(item) service["vapps"] = vapps if data.get("cps") is not None: cps = [] for item in data.get("cps"): cps.append(item) service["cps"] = cps if data.get("additional_params") is not None: service["addionalParams"] = data.get("additional_params") if data.get("custom_input_params") is not None: service["customInputParams"] = data.get("custom_input_params") request_body = {} request_body["tenantName"] = "ECM" request_body["service"] = service url = "http://%(ecm_host_name)s/ecm_service/services" % { "ecm_host_name": host } response = rest_client_util.perform_post(url, json.dumps(request_body)) is_success, response = utils.process_response(response) if is_success: order_id = response["data"]["order"]["id"] timeout_start = time.time() timeout = data.get("timeout", 3600) response, is_error = utils.wait_for_completion(order_id, timeout_start, timeout) if is_error: return False, False, response service_id = utils.get_service_id(response) is_success, response = get_service(service_id) return True, True, response return False, False, response
def delete_service(data): url = "http://%(ecm_host_name)s/ecm_service/services/%(id)s" % \ {"ecm_host_name": host, "id": data.get("id")} response = rest_client_util.perform_delete(url) is_success, response = utils.process_response(response) if is_success: order_id = response["data"]["order"]["id"] timeout_start = time.time() timeout = data.get("timeout", 3600) response, timed_out = utils.wait_for_completion( order_id, timeout_start, timeout) if timed_out: return False, False, response return True, True, response return False, False, response
def create_cp(data): cp = {} cp["name"] = data.get("name") cp["type"] = data.get("type") cp["description"] = data.get("description") cp["address"] = data.get("address") cp["addressType"] = data.get("address_type") if data.get("vapp_id") is not None: vapp = {} vapp["id"] = data.get("vapp_id") cp["vapp"] = vapp if data.get("service_id") is not None: service = {} service["id"] = data.get("service_id") cp["service"] = service request_body = {} request_body["tenantName"] = "ECM" request_body["cp"] = cp url = "http://%(ecm_host_name)s/ecm_service/cps" % {"ecm_host_name": host} response = rest_client_util.perform_post(url, json.dumps(request_body)) is_success, response = utils.process_response(response) if is_success: order_id = response["data"]["order"]["id"] timeout_start = time.time() timeout = data.get("timeout", 3600) response, is_error = utils.wait_for_completion(order_id, timeout_start, timeout) if is_error: return False, False, response id = utils.get_cp_id(response) is_success, response = get_cp(id) return True, True, response return False, False, response
def get_service(id): url = "http://%(ecm_host_name)s/ecm_service/services/%(id)s" % \ {"ecm_host_name": host, "id": id} response = rest_client_util.perform_get(url) return utils.process_response(response)