def test_30_get_vm_info(self): self.server.request('GET', "/infrastructures/" + self.inf_id, headers={'AUTHORIZATION': self.auth_data}) resp = self.server.getresponse() output = str(resp.read()) self.assertEqual(resp.status, 200, msg="ERROR getting the infrastructure info:" + output) vm_ids = output.split("\n") vm_uri = uriparse(vm_ids[0]) self.server.request('GET', vm_uri[2], headers={ 'AUTHORIZATION': self.auth_data, 'Accept': 'application/json' }) resp = self.server.getresponse() ct = resp.getheader('Content-type') output = str(resp.read()) self.assertEqual(resp.status, 200, msg="ERROR getting VM info:" + output) self.assertEqual( ct, "application/json", msg="ERROR getting VM info: Incorrect Content-type: %s" % ct) res = json.loads(output) radl = res["radl"] parse_radl_json(radl)
def test_empty_contextualize(self): radl = """ system test ( cpu.count>=1 ) deploy test 1 contextualize () """ r = parse_radl(radl) r.check() self.assertEqual(r.contextualize.items, {}) radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) r.check() self.assertEqual(r.contextualize.items, {}) radl = """ system test ( cpu.count>=1 ) deploy test 1 """ r = parse_radl(radl) r.check() self.assertEqual(r.contextualize.items, None) radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) r.check() self.assertEqual(r.contextualize.items, None)
def deserialize_info(str_data): newinf = InfrastructureInfo() dic = json.loads(str_data) vm_list = dic['vm_list'] vm_master_id = dic['vm_master'] dic['vm_master'] = None dic['vm_list'] = [] if dic['auth']: dic['auth'] = Authentication.deserialize(dic['auth']) if dic['radl']: dic['radl'] = parse_radl_json(dic['radl']) if 'extra_info' in dic and dic['extra_info'] and "TOSCA" in dic['extra_info']: dic['extra_info']['TOSCA'] = Tosca.deserialize(dic['extra_info']['TOSCA']) newinf.__dict__.update(dic) newinf.cloud_connector = None # Set the ConfManager object and the lock to the data loaded newinf.cm = None newinf.conf_threads = [] for vm_data in vm_list: vm = DB150to151.deserialize_vm(vm_data) vm.inf = newinf if vm.im_id == vm_master_id: newinf.vm_master = vm newinf.vm_list.append(vm) return newinf
def RESTAlterVM(infid=None, vmid=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) vm_info = InfrastructureManager.AlterVM(infid, vmid, radl_data, auth) return format_output(vm_info, field_name="radl") except DeletedInfrastructureException as ex: return return_error(404, "Error modifying resources: " + str(ex)) except IncorrectInfrastructureException as ex: return return_error(404, "Error modifying resources: " + str(ex)) except UnauthorizedUserException as ex: return return_error(403, "Error modifying resources: " + str(ex)) except DeletedVMException as ex: return return_error(404, "Error modifying resources: " + str(ex)) except IncorrectVMException as ex: return return_error(404, "Error modifying resources: " + str(ex)) except Exception as ex: logger.exception("Error modifying resources") return return_error(400, "Error modifying resources: " + str(ex))
def RESTReconfigureInfrastructure(id=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: vm_list = None if "vm_list" in bottle.request.params.keys(): str_vm_list = bottle.request.params.get("vm_list") try: vm_list = [int(vm_id) for vm_id in str_vm_list.split(",")] except: return return_error(400, "Incorrect vm_list format.") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if radl_data: if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) else: radl_data = "" bottle.response.content_type = "text/plain" return InfrastructureManager.Reconfigure(id, radl_data, auth, vm_list) except DeletedInfrastructureException, ex: return return_error(404, "Error reconfiguring infrastructure: " + str(ex))
def RESTCreateInfrastructure(): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) inf_id = InfrastructureManager.CreateInfrastructure(radl_data, auth) bottle.response.content_type = "text/uri-list" protocol = "http://" if Config.REST_SSL: protocol = "https://" res = protocol + \ bottle.request.environ['HTTP_HOST'] + \ "/infrastructures/" + str(inf_id) return format_output(res, "text/uri-list", "uri") except UnauthorizedUserException, ex: return return_error(401, "Error Getting Inf. info: " + str(ex))
def RESTReconfigureInfrastructure(id=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: vm_list = None if "vm_list" in bottle.request.params.keys(): str_vm_list = bottle.request.params.get("vm_list") try: vm_list = [int(vm_id) for vm_id in str_vm_list.split(",")] except: return return_error(400, "Incorrect vm_list format.") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if radl_data: if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error( 415, "Unsupported Media Type %s" % content_type) else: radl_data = "" bottle.response.content_type = "text/plain" return InfrastructureManager.Reconfigure(id, radl_data, auth, vm_list) except DeletedInfrastructureException, ex: return return_error(404, "Error reconfiguring infrastructure: " + str(ex))
def RESTCreateInfrastructure(): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) inf_id = InfrastructureManager.CreateInfrastructure(radl_data, auth) bottle.response.content_type = "text/uri-list" protocol = "http://" if Config.REST_SSL: protocol = "https://" res = protocol + \ bottle.request.environ['HTTP_HOST'] + \ "/infrastructures/" + str(inf_id) return format_output(res, "text/uri-list", "uri") except InvaliddUserException, ex: return return_error(401, "Error Getting Inf. info: " + str(ex))
def deserialize_vm(str_data): dic = json.loads(str_data) if dic['cloud']: dic['cloud'] = IM.CloudInfo.CloudInfo.deserialize(dic['cloud']) if dic['info']: dic['info'] = parse_radl_json(dic['info']) if dic['requested_radl']: dic['requested_radl'] = parse_radl_json(dic['requested_radl']) newvm = VirtualMachine(None, None, None, None, None, None, dic['im_id']) newvm.__dict__.update(dic) # If we load a VM that is not configured, set it to False # because the configuration process will be lost if newvm.configured is None: newvm.configured = False return newvm
def test_30_get_vm_info(self): resp = self.create_request("GET", "/infrastructures/" + self.inf_id) self.assertEqual(resp.status_code, 200, msg="ERROR getting the infrastructure info:" + resp.text) vm_ids = resp.text.split("\n") vm_uri = uriparse(vm_ids[0]) resp = self.create_request("GET", vm_uri[2], headers={'Accept': 'application/json'}) ct = resp.headers['Content-type'] self.assertEqual(resp.status_code, 200, msg="ERROR getting VM info:" + resp.text) self.assertEqual(ct, "application/json", msg="ERROR getting VM info: Incorrect Content-type: %s" % ct) res = json.loads(resp.text) radl = res["radl"] parse_radl_json(radl)
def test_references(self): r = parse_radl(TESTS_PATH + "/test_radl_ref.radl") self.radl_check(r, [2, 2, 0, 2, 2]) radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) self.radl_check(r, [2, 2, 0, 2, 2])
def test_get_vm_info(self): """ Test GetVMInfo and GetVMProperty and GetVMContMsg and GetInfrastructureRADL and GetInfrastructureContMsg and GetInfrastructureState. """ radl = RADL() radl.add( system("s0", [ Feature("disk.0.image.url", "=", "mock0://linux.for.ev.er"), Feature("disk.0.os.credentials.username", "=", "user"), Feature("disk.0.os.credentials.password", "=", "pass") ])) radl.add(deploy("s0", 1)) auth0 = self.getAuth([0], [], [("Dummy", 0)]) infId = IM.CreateInfrastructure(str(radl), auth0) radl_info = IM.GetVMInfo(infId, "0", auth0) parsed_radl_info = parse_radl(str(radl_info)) self.assertEqual(parsed_radl_info.systems[0].getValue("state"), "running") radl_info = IM.GetVMInfo(infId, "0", auth0, True) parsed_radl_info = parse_radl_json(radl_info) self.assertEqual(parsed_radl_info.systems[0].getValue("state"), "running") state = IM.GetVMProperty(infId, "0", "state", auth0) self.assertEqual(state, "running") contmsg = IM.GetVMContMsg(infId, "0", auth0) self.assertEqual(contmsg, "") InfrastructureList.infrastructure_list[infId].cont_out = "Header" InfrastructureList.infrastructure_list[infId].vm_list[ 0].cloud_connector = MagicMock() InfrastructureList.infrastructure_list[infId].vm_list[ 0].cloud_connector.error_messages = "TESTMSG" contmsg = IM.GetInfrastructureContMsg(infId, auth0) header_contmsg = IM.GetInfrastructureContMsg(infId, auth0, True) InfrastructureList.infrastructure_list[infId].vm_list[ 0].cloud_connector = None self.assertIn("TESTMSG", contmsg) self.assertNotIn("TESTMSG", header_contmsg) self.assertIn("Header", header_contmsg) state = IM.GetInfrastructureState(infId, auth0) self.assertEqual(state["state"], "running") self.assertEqual(state["vm_states"]["0"], "running") radl_info = IM.GetInfrastructureRADL(infId, auth0) parsed_radl_info = parse_radl(str(radl_info)) self.assertEqual( parsed_radl_info.systems[0].getValue( "disk.0.os.credentials.username"), "user") IM.DestroyInfrastructure(infId, auth0)
def RESTCreateInfrastructure(): try: auth = get_auth_header() except Exception: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read().decode("utf-8") tosca_data = None async_call = False if "async" in bottle.request.params.keys(): str_ctxt = bottle.request.params.get("async").lower() if str_ctxt in ['yes', 'true', '1']: async_call = True elif str_ctxt in ['no', 'false', '0']: async_call = False else: return return_error(400, "Incorrect value in async parameter") if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/yaml" in content_type: tosca_data = Tosca(radl_data) _, radl_data = tosca_data.to_radl() elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) inf_id = InfrastructureManager.CreateInfrastructure( radl_data, auth, async_call) # Store the TOSCA document if tosca_data: sel_inf = InfrastructureManager.get_infrastructure(inf_id, auth) sel_inf.extra_info['TOSCA'] = tosca_data bottle.response.headers['InfID'] = inf_id bottle.response.content_type = "text/uri-list" res = get_full_url('/infrastructures/%s' % inf_id) return format_output(res, "text/uri-list", "uri") except InvaliddUserException as ex: return return_error(401, "Error Getting Inf. info: %s" % get_ex_error(ex)) except DisabledFunctionException as ex: return return_error(403, "Error Destroying Inf: %s" % get_ex_error(ex)) except Exception as ex: logger.exception("Error Creating Inf.") return return_error(400, "Error Creating Inf.: %s" % get_ex_error(ex))
def test_ansible_host(self): radl = """ ansible ansible_master (host = 'host' and credentials.username = '******' and credentials.password = '******') network net () system main ( ansible_host = 'ansible_master' and net_interface.0.connection = 'net' ) """ r = parse_radl(radl) self.radl_check(r) radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) self.radl_check(r) radl = """ ansible ansible_master (host = 'host' and credentials.username = '******' and credentials.password = '******') network net () system main ( ansible_host = 'ansible_master1' and net_interface.0.connection = 'net' ) """ r = parse_radl(radl) with self.assertRaises(RADLParseException): self.radl_check(r) radl = """ ansible ansible_master (credentials.username = '******' and credentials.password = '******') network net () system main ( net_interface.0.connection = 'net' ) """ r = parse_radl(radl) with self.assertRaises(RADLParseException): self.radl_check(r) radl = """ ansible ansible_master (host = 'host' and credentials.username = '******') network net () system main ( net_interface.0.connection = 'net' ) """ r = parse_radl(radl) with self.assertRaises(RADLParseException): self.radl_check(r)
def test_30_get_vm_info(self): self.server.request('GET', "/infrastructures/" + self.inf_id, headers={'AUTHORIZATION': self.auth_data}) resp = self.server.getresponse() output = str(resp.read()) self.assertEqual(resp.status, 200, msg="ERROR getting the infrastructure info:" + output) vm_ids = output.split("\n") vm_uri = uriparse(vm_ids[0]) self.server.request('GET', vm_uri[2], headers={ 'AUTHORIZATION': self.auth_data, 'Accept': 'application/json'}) resp = self.server.getresponse() ct = resp.getheader('Content-type') output = str(resp.read()) self.assertEqual(resp.status, 200, msg="ERROR getting VM info:" + output) self.assertEqual(ct, "application/json", msg="ERROR getting VM info: Incorrect Content-type: %s" % ct) res = json.loads(output) radl = res["radl"] parse_radl_json(radl)
def RESTAddResource(id=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: context = True if "context" in bottle.request.params.keys(): str_ctxt = bottle.request.params.get("context").lower() if str_ctxt in ['yes', 'true', '1']: context = True elif str_ctxt in ['no', 'false', '0']: context = False else: return return_error(400, "Incorrect value in context parameter") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read().decode("utf-8") if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) vm_ids = InfrastructureManager.AddResource(id, radl_data, auth, context) protocol = "http://" if Config.REST_SSL: protocol = "https://" res = [] for vm_id in vm_ids: res.append(protocol + bottle.request.environ['HTTP_HOST'] + "/infrastructures/" + str(id) + "/vms/" + str(vm_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except DeletedInfrastructureException as ex: return return_error(404, "Error Adding resources: " + str(ex)) except IncorrectInfrastructureException as ex: return return_error(404, "Error Adding resources: " + str(ex)) except UnauthorizedUserException as ex: return return_error(403, "Error Adding resources: " + str(ex)) except Exception as ex: logger.exception("Error Adding resources") return return_error(400, "Error Adding resources: " + str(ex))
def test_basic0(self): r = parse_radl(TESTS_PATH + "/test_radl_1.radl") self.radl_check(r, [2, 2, 0, 0, 0]) s = r.get_system_by_name("main") self.assertEqual(s.getValue("cpu.arch"), "x86_64") self.assertEqual(s.getValue("net_interface.0.connection"), "publica") radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) self.radl_check(r, [2, 2, 0, 0, 0]) s = r.get_system_by_name("main") self.assertEqual(s.getValue("cpu.arch"), "x86_64") self.assertEqual(s.getValue("net_interface.0.connection"), "publica")
def test_basic(self): r = parse_radl(TESTS_PATH + "/test_radl_0.radl") self.radl_check(r, [1, 1, 1, 1, 0]) s = r.get_system_by_name("cursoaws") self.assertIsInstance(s, system) self.assertEqual(len(s.features), 17) self.assertEqual(s.getValue("disk.0.os.name"), "linux") radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) s = r.get_system_by_name("cursoaws") self.assertIsInstance(s, system) self.assertEqual(len(s.features), 17) self.assertEqual(s.getValue("disk.0.os.name"), "linux")
def test_concrete(self): r = parse_radl(TESTS_PATH + "/test_radl_conc.radl") self.radl_check(r) s = r.get_system_by_name("main") self.assertIsInstance(s, system) concrete_s, score = s.concrete() self.assertIsInstance(concrete_s, system) self.assertEqual(score, 201) radl_json = dump_radl_json(r) r = parse_radl_json(radl_json) self.radl_check(r) s = r.get_system_by_name("main") self.assertIsInstance(s, system) concrete_s, score = s.concrete() self.assertIsInstance(concrete_s, system) self.assertEqual(score, 201)
def RESTAddResource(id=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: context = True if "context" in bottle.request.params.keys(): str_ctxt = bottle.request.params.get("context").lower() if str_ctxt in ['yes', 'true', '1']: context = True elif str_ctxt in ['no', 'false', '0']: context = False else: return return_error(400, "Incorrect value in context parameter") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) vm_ids = InfrastructureManager.AddResource( id, radl_data, auth, context) protocol = "http://" if Config.REST_SSL: protocol = "https://" res = [] for vm_id in vm_ids: res.append(protocol + bottle.request.environ[ 'HTTP_HOST'] + "/infrastructures/" + str(id) + "/vms/" + str(vm_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except DeletedInfrastructureException, ex: return return_error(404, "Error Adding resources: " + str(ex))
def RESTCreateInfrastructure(): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() tosca_data = None if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/yaml" in content_type: tosca_data = Tosca(radl_data) _, radl_data = tosca_data.to_radl() elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) inf_id = InfrastructureManager.CreateInfrastructure(radl_data, auth) # Store the TOSCA document if tosca_data: sel_inf = InfrastructureManager.get_infrastructure(inf_id, auth) sel_inf.extra_info['TOSCA'] = tosca_data bottle.response.content_type = "text/uri-list" protocol = "http://" if Config.REST_SSL: protocol = "https://" res = protocol + \ bottle.request.environ['HTTP_HOST'] + \ "/infrastructures/" + str(inf_id) return format_output(res, "text/uri-list", "uri") except InvaliddUserException, ex: return return_error(401, "Error Getting Inf. info: " + str(ex))
def RESTAlterVM(infid=None, vmid=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) vm_info = InfrastructureManager.AlterVM(infid, vmid, radl_data, auth) return format_output(vm_info, field_name="radl") except DeletedInfrastructureException, ex: return return_error(404, "Error modifying resources: " + str(ex))
def RESTAddResource(infid=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: context = True if "context" in bottle.request.params.keys(): str_ctxt = bottle.request.params.get("context").lower() if str_ctxt in ['yes', 'true', '1']: context = True elif str_ctxt in ['no', 'false', '0']: context = False else: return return_error(400, "Incorrect value in context parameter") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read().decode("utf-8") tosca_data = None remove_list = [] if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/yaml" in content_type: tosca_data = Tosca(radl_data) auth = InfrastructureManager.check_auth_data(auth) sel_inf = InfrastructureManager.get_infrastructure(infid, auth) # merge the current TOSCA with the new one if isinstance(sel_inf.extra_info['TOSCA'], Tosca): tosca_data = sel_inf.extra_info['TOSCA'].merge(tosca_data) remove_list, radl_data = tosca_data.to_radl(sel_inf) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) if remove_list: InfrastructureManager.RemoveResource(infid, remove_list, auth, context) vm_ids = InfrastructureManager.AddResource(infid, radl_data, auth, context) # Replace the TOSCA document if tosca_data: sel_inf = InfrastructureManager.get_infrastructure(infid, auth) sel_inf.extra_info['TOSCA'] = tosca_data res = [] for vm_id in vm_ids: res.append( get_full_url("/infrastructures/" + str(infid) + "/vms/" + str(vm_id))) return format_output(res, "text/uri-list", "uri-list", "uri") except DeletedInfrastructureException as ex: return return_error(404, "Error Adding resources: %s" % ex.args[0]) except IncorrectInfrastructureException as ex: return return_error(404, "Error Adding resources: %s" % ex.args[0]) except UnauthorizedUserException as ex: return return_error(403, "Error Adding resources: %s" % ex.args[0]) except Exception as ex: logger.exception("Error Adding resources") return return_error(400, "Error Adding resources: %s" % ex.args[0])
def RESTAddResource(id=None): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: context = True if "context" in bottle.request.params.keys(): str_ctxt = bottle.request.params.get("context").lower() if str_ctxt in ['yes', 'true', '1']: context = True elif str_ctxt in ['no', 'false', '0']: context = False else: return return_error(400, "Incorrect value in context parameter") content_type = get_media_type('Content-Type') radl_data = bottle.request.body.read() tosca_data = None remove_list = [] if content_type: if "application/json" in content_type: radl_data = parse_radl_json(radl_data) elif "text/yaml" in content_type: tosca_data = Tosca(radl_data) auth = InfrastructureManager.check_auth_data(auth) sel_inf = InfrastructureManager.get_infrastructure(id, auth) # merge the current TOSCA with the new one if isinstance(sel_inf.extra_info['TOSCA'], Tosca): tosca_data = sel_inf.extra_info['TOSCA'].merge(tosca_data) remove_list, radl_data = tosca_data.to_radl(sel_inf) elif "text/plain" in content_type or "*/*" in content_type or "text/*" in content_type: content_type = "text/plain" else: return return_error(415, "Unsupported Media Type %s" % content_type) if remove_list: InfrastructureManager.RemoveResource( id, remove_list, auth, context) vm_ids = InfrastructureManager.AddResource( id, radl_data, auth, context) # Replace the TOSCA document if tosca_data: sel_inf = InfrastructureManager.get_infrastructure(id, auth) sel_inf.extra_info['TOSCA'] = tosca_data protocol = "http://" if Config.REST_SSL: protocol = "https://" res = [] for vm_id in vm_ids: res.append(protocol + bottle.request.environ[ 'HTTP_HOST'] + "/infrastructures/" + str(id) + "/vms/" + str(vm_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except DeletedInfrastructureException, ex: return return_error(404, "Error Adding resources: " + str(ex))