def RESTGetInfrastructureList(): try: auth = get_auth_header() except Exception: return return_error(401, "No authentication data provided") try: flt = None if "filter" in bottle.request.params.keys(): flt = bottle.request.params.get("filter") inf_ids = InfrastructureManager.GetInfrastructureList(auth, flt) res = [] for inf_id in inf_ids: res.append(get_full_url('/infrastructures/%s' % inf_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except InvaliddUserException as ex: return return_error(401, "Error Getting Inf. List: %s" % get_ex_error(ex)) except Exception as ex: logger.exception("Error Getting Inf. List") return return_error(400, "Error Getting Inf. List: %s" % get_ex_error(ex))
def test_get_infrastructure_list(self): """Get infrastructure List.""" auth0 = self.getAuth([0]) infId = IM.CreateInfrastructure("", auth0) inf_ids = IM.GetInfrastructureList(auth0) self.assertEqual(inf_ids, [infId]) IM.DestroyInfrastructure(infId, auth0)
def RESTGetInfrastructureList(): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: inf_ids = InfrastructureManager.GetInfrastructureList(auth) res = [] for inf_id in inf_ids: res.append(get_full_url('/infrastructures/%s' % inf_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except InvaliddUserException as ex: return return_error(401, "Error Getting Inf. List: %s" % ex.args[0]) except Exception as ex: logger.exception("Error Getting Inf. List") return return_error(400, "Error Getting Inf. List: %s" % ex.args[0])
def RESTGetInfrastructureList(): try: auth = get_auth_header() except: return return_error(401, "No authentication data provided") try: inf_ids = InfrastructureManager.GetInfrastructureList(auth) res = [] protocol = "http://" if Config.REST_SSL: protocol = "https://" for inf_id in inf_ids: res.append( protocol + bottle.request.environ['HTTP_HOST'] + "/infrastructures/" + str(inf_id)) return format_output(res, "text/uri-list", "uri-list", "uri") except InvaliddUserException, ex: return return_error(401, "Error Getting Inf. List: " + str(ex))