def list_flavor_access(self, flavor_id): """Gets flavor access information given the flavor id.""" resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id) body = json.loads(body) self.validate_response(schema_access.add_remove_list_flavor_access, resp, body) return service_client.ResponseBodyList(resp, body['flavor_access'])
def list_group_roles_on_domain(self, domain_id, group_id): """list roles of a user on a domain.""" resp, body = self.get('domains/%s/groups/%s/roles' % (domain_id, group_id)) self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['roles'])
def list_extensions(self): """List all the extensions.""" resp, body = self.get('/extensions') self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['extensions']['values'])
def show_host(self, hostname): """Show detail information for the host.""" resp, body = self.get("os-hosts/%s" % hostname) body = json.loads(body) self.validate_response(schema.get_host_detail, resp, body) return service_client.ResponseBodyList(resp, body['host'])
def list_group_roles_on_project(self, project_id, group_id): """list roles of a user on a project.""" resp, body = self.get('projects/%s/groups/%s/roles' % (project_id, group_id)) self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['roles'])
def list_qos(self): """List all the QoS specifications created.""" url = 'qos-specs' resp, body = self.get(url) body = json.loads(body) self.expected_success(200, resp.status) return service_client.ResponseBodyList(resp, body['qos_specs'])
def show_association_qos(self, qos_id): """Get the association of the specified QoS specification.""" url = "qos-specs/%s/associations" % str(qos_id) resp, body = self.get(url) body = json.loads(body) self.expected_success(200, resp.status) return service_client.ResponseBodyList(resp, body['qos_associations'])
def display_default_nova_az(self): """Returns a list of all available hosts in the default nova az.""" url = 'os-az-setting/display_default_nova_az/action' resp, body = self.get(url) body = json.loads(body) # self.validate_response(schema.list_floating_ips, resp, body) return service_client.ResponseBodyList(resp, body['nova_az_host_list'])
def list_projects(self, params=None): url = "projects" if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['projects'])
def list_security_group_default_rules(self): """List all Security Group default rules.""" resp, body = self.get('os-security-group-default-rules') body = json.loads(body) self.validate_response(schema.list_security_group_default_rules, resp, body) rules = body['security_group_default_rules'] return service_client.ResponseBodyList(resp, rules)
def list_availability_zones(self): """Returns a list of all available azs in the platform.""" url = 'os-az-setting/list_availability_zones/action' resp, body = self.get(url) body = json.loads(body) # self.validate_response(schema.list_floating_ips, resp, body) return service_client.ResponseBodyList(resp, body['availability_zone_list'])
def get_users(self, params=None): """Get the list of users.""" url = 'users' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['users'])
def add_flavor_access(self, flavor_id, tenant_id): """Add flavor access for the specified tenant.""" post_body = {'addTenantAccess': {'tenant': tenant_id}} post_body = json.dumps(post_body) resp, body = self.post('flavors/%s/action' % flavor_id, post_body) body = json.loads(body) self.validate_response(schema_access.add_remove_list_flavor_access, resp, body) return service_client.ResponseBodyList(resp, body['flavor_access'])
def list_volume_transfers(self, params=None): """List all the volume transfers created.""" url = 'os-volume-transfer' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.expected_success(200, resp.status) return service_client.ResponseBodyList(resp, body['transfers'])
def list_security_group_rules(self, security_group_id): """List all rules for a security group.""" resp, body = self.get('os-security-groups') body = json.loads(body) self.validate_response(schema.list_security_groups, resp, body) for sg in body['security_groups']: if sg['id'] == security_group_id: return service_client.ResponseBodyList(resp, sg['rules']) raise exceptions.NotFound('No such Security Group')
def list_baremetal_nodes(self, **params): """List all baremetal nodes.""" url = 'os-baremetal-nodes' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_baremetal_nodes, resp, body) return service_client.ResponseBodyList(resp, body['nodes'])
def list_regions(self, params=None): """List regions.""" url = 'regions' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['regions'])
def show_tenant_usage(self, tenant_id, **params): url = 'os-simple-tenant-usage/%s' % tenant_id if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.get_tenant_usage, resp, body) return service_client.ResponseBodyList(resp, body['tenant_usage'])
def list_services(self, **params): url = 'os-services' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_services, resp, body) return service_client.ResponseBodyList(resp, body['services'])
def list_backups(self, detail=False): """Information for all the tenant's backups.""" url = "backups" if detail: url += "/detail" resp, body = self.get(url) body = json.loads(body) self.expected_success(200, resp.status) return service_client.ResponseBodyList(resp, body['backups'])
def list_agents(self, **params): """List all agent builds.""" url = 'os-agents' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_agents, resp, body) return service_client.ResponseBodyList(resp, body['agents'])
def list_floating_ips(self, **params): """Returns a list of all floating IPs filtered by any parameters.""" url = 'os-floating-ips' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_floating_ips, resp, body) return service_client.ResponseBodyList(resp, body['floating_ips'])
def list_keypairs(self): resp, body = self.get("os-keypairs") body = json.loads(body) # Each returned keypair is embedded within an unnecessary 'keypair' # element which is a deviation from other resources like floating-ips, # servers, etc. A bug? # For now we shall adhere to the spec, but the spec for keypairs # is yet to be found self.validate_response(schema.list_keypairs, resp, body) return service_client.ResponseBodyList(resp, body['keypairs'])
def list_images(self, params=None): url = 'v2/images' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) self.expected_success(200, resp.status) body = json.loads(body) self._validate_schema(body, type='images') return service_client.ResponseBodyList(resp, body['images'])
def list_security_groups(self, **params): """List all security groups for a user.""" url = 'os-security-groups' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_security_groups, resp, body) return service_client.ResponseBodyList(resp, body['security_groups'])
def list_migrations(self, **params): """Lists all migrations.""" url = 'os-migrations' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_migrations, resp, body) return service_client.ResponseBodyList(resp, body['migrations'])
def list_snapshots(self, detail=False, params=None): """List all the snapshot.""" url = 'snapshots' if detail: url += '/detail' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) body = json.loads(body) self.expected_success(200, resp.status) return service_client.ResponseBodyList(resp, body['snapshots'])
def list_hypervisors(self, detail=False): """List hypervisors information.""" url = 'os-hypervisors' _schema = schema.list_search_hypervisors if detail: url += '/detail' _schema = schema.list_hypervisors_detail resp, body = self.get(url) body = json.loads(body) self.validate_response(_schema, resp, body) return service_client.ResponseBodyList(resp, body['hypervisors'])
def list_availability_zones(self, detail=False): url = 'os-availability-zone' schema_list = schema.list_availability_zone_list if detail: url += '/detail' schema_list = schema.list_availability_zone_list_detail resp, body = self.get(url) body = json.loads(body) self.validate_response(schema_list, resp, body) return service_client.ResponseBodyList(resp, body['availabilityZoneInfo'])
def get_trusts(self, trustor_user_id=None, trustee_user_id=None): """GET trusts.""" if trustor_user_id: resp, body = self.get("OS-TRUST/trusts?trustor_user_id=%s" % trustor_user_id) elif trustee_user_id: resp, body = self.get("OS-TRUST/trusts?trustee_user_id=%s" % trustee_user_id) else: resp, body = self.get("OS-TRUST/trusts") self.expected_success(200, resp.status) body = json.loads(body) return service_client.ResponseBodyList(resp, body['trusts'])