class Extension(resource.Resource): resource_key = 'extension' resources_key = 'extensions' base_path = '/extensions' service = compute_service.ComputeService() id_attribute = "alias" # capabilities allow_retrieve = True allow_list = True # Properties #: A short name by which this extension is also known. alias = resource.prop('alias') #: Text describing this extension's purpose. description = resource.prop('description') #: Links pertaining to this extension. This is a list of dictionaries, #: each including keys ``href`` and ``rel``. links = resource.prop('links') #: The name of the extension. name = resource.prop('name') #: A URL pointing to the namespace for this extension. namespace = resource.prop('namespace') #: Timestamp when this extension was last updated. #: *Type: datetime object parsed from ISO 8601 formatted string* updated_at = resource.prop('updated', type=format.ISO8601)
class Pool(resource.Resource): resource_key = 'pool' resources_key = 'pools' base_path = '/lbaas/pools' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The administrative state of the pool, which is up ``True`` or down #: ``False``. *Type: bool* admin_state_up = resource.prop('admin_state_up', type=bool) #: Description for the pool. description = resource.prop('description') #: The ID of the associated health monitor. health_monitor_id = resource.prop('healthmonitor_id') #: The load-balancer algorithm, which is round-robin, least-connections, #: and so on. This value, which must be supported, is dependent on the #: load-balancer provider. Round-robin must be supported. lb_algorithm = resource.prop('lb_algorithm') #: List of associated listeners. #: *Type: list of dicts which contain the listener IDs* listener_ids = resource.prop('listeners', type=list) #: List of members that belong to the pool. #: *Type: list of dicts which contain the member IDs* member_ids = resource.prop('members', type=list) #: Pool name. Does not have to be unique. name = resource.prop('name') #: The ID of the project this pool is associated with. project_id = resource.prop('tenant_id') #: The protocol of the pool, which is TCP, HTTP, or HTTPS. protocol = resource.prop('protocol') #: Session persistence algorithm that should be used (if any). #: *Type: dict with keys ``type`` and ``cookie_name``* session_persistence = resource.prop('session_persistence')
class Extension(resource.Resource): resource_key = 'extension' resources_key = 'extensions' base_path = '/extensions' service = identity_service.IdentityService() # capabilities allow_list = True # Properties #: A unique identifier, which will be used for accessing the extension #: through a dedicated url ``/extensions/*alias*``. The extension #: alias uniquely identifies an extension and is prefixed by a vendor #: identifier. *Type: string* alias = resource.prop('alias') #: A description of the extension. *Type: string* description = resource.prop('description') #: Links to the documentation in various format. *Type: string* links = resource.prop('links') #: The name of the extension. *Type: string* name = resource.prop('name') #: The second unique identifier of the extension after the alias. #: It is usually a URL which will be used. Example: #: "http://docs.openstack.org/identity/api/ext/s3tokens/v1.0" #: *Type: string* namespace = resource.prop('namespace') #: The last time the extension has been modified (update date). #: *Type: date* updated = resource.prop('updated') @classmethod def list(cls, session, **params): resp = session.get(cls.base_path, service=cls.service, params=params) for data in resp.body[cls.resources_key]['values']: yield cls.existing(**data)
class ServerInterface(resource.Resource): id_attribute = 'mac_addr' resource_key = 'interfaceAttachment' resources_key = 'interfaceAttachments' base_path = '/servers/%(server_id)s/os-interface' service = compute_service.ComputeService() # capabilities allow_create = True allow_retrieve = True allow_update = False allow_delete = True allow_list = True # Properties #: Fixed IP addresses with subnet IDs. fixed_ips = resource.prop('fixed_ips') #: The MAC address. mac_addr = resource.prop('mac_addr') #: The network ID. net_id = resource.prop('net_id') #: The ID of the port for which you want to create an interface. port_id = resource.prop('port_id') #: The port state. port_state = resource.prop('port_state') #: The UUID for the server. server_id = resource.prop('server_id')
class Policy(resource.Resource): resource_key = 'policy' resources_key = 'policies' base_path = '/policies' service = cluster_service.ClusterService() # Capabilities allow_list = True allow_retrieve = True allow_create = True allow_delete = True allow_update = True patch_update = True # Properties #: The name of the policy. name = resource.prop('name') #: The type name of the policy. type = resource.prop('type') #: The timestamp when the policy is created. created_at = resource.prop('created_at') #: The timestamp when the policy was last updated. updated_at = resource.prop('updated_at') #: The specification of the policy. spec = resource.prop('spec', type=dict) #: A dictionary containing runtime data of the policy. data = resource.prop('data', type=dict)
class User(resource.Resource): id_attribute = 'name' resource_key = 'user' resources_key = 'users' base_path = '/instances/%(instance_id)s/users' service = database_service.DatabaseService() # capabilities allow_create = True allow_delete = True allow_list = True # path args instance_id = resource.prop('instance_id') # Properties databases = resource.prop('databases') name = resource.prop('name') _password = resource.prop('password') @property def password(self): try: val = self._password except AttributeError: val = None return val @password.setter def password(self, val): self._password = val @classmethod def create_by_id(cls, session, attrs, r_id=None, path_args=None): url = cls.base_path % path_args # Create expects an array of users body = {'users': [attrs]} resp = session.post(url, service=cls.service, json=body).body return resp
class Database(resource.Resource): id_attribute = 'name' resource_key = 'database' resources_key = 'databases' base_path = '/instances/%(instance_id)s/databases' service = database_service.DatabaseService() # capabilities allow_create = True allow_delete = True allow_list = True # Properties #: Set of symbols and encodings. The default character set is ``utf8``. character_set = resource.prop('character_set') #: Set of rules for comparing characters in a character set. #: The default value for collate is ``utf8_general_ci``. collate = resource.prop('collate') #: The ID of the instance instance_id = resource.prop('instance_id') #: The name of the database name = resource.prop('name')
class Member(resource.Resource): id_attribute = 'member_id' resources_key = 'members' base_path = '/images/%(image_id)s/members' service = image_service.ImageService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The date and time when the member was created. created_at = resource.prop('created_at') #: Image ID stored through the image API. Typically a UUID. image_id = resource.prop('image_id') #: The status of the image. status = resource.prop('status') #: The date and time when the member was updated. updated_at = resource.prop('updated_at')
class Hypervisor(resource.Resource): name_attribute = 'hypervisor_hostname' resource_key = 'hypervisor' resources_key = 'hypervisors' base_path = '/os-hypervisors' service = compute_service.ComputeService() # capabilities allow_retrieve = True allow_list = True # Properties #: status of hypervisor status = resource.prop('status') #: state of hypervisor state = resource.prop('state') #: name of hypervisor hypervisor_hostname = resource.prop('hypervisor_hostname')
class HealthMonitor(resource.Resource): resource_key = 'healthmonitor' resources_key = 'healthmonitors' base_path = '/lbaas/healthmonitors' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The administrative state of the health monitor, which is up #: ``True`` or down ``False``. *Type: bool* admin_state_up = resource.prop('admin_state_up', type=bool) #: The time, in seconds, between sending probes to members. delay = resource.prop('delay') #: Expected HTTP codes for a passing HTTP(S) monitor. expected_codes = resource.prop('expected_codes') #: The HTTP method that the monitor uses for requests. http_method = resource.prop('http_method') #: Maximum consecutive health probe tries. max_retries = resource.prop('max_retries') #: List of pools associated with this health monitor #: *Type: list of dicts which contain the pool IDs* pool_ids = resource.prop('pools', type=list) #: The ID of the project this health monitor is associated with. project_id = resource.prop('tenant_id') #: The maximum number of seconds for a monitor to wait for a connection #: to be established before it times out. This value must be less than #: the delay value. timeout = resource.prop('timeout') #: The type of probe sent by the load balancer to verify the member #: state, which is PING, TCP, HTTP, or HTTPS. type = resource.prop('type') #: Path portion of URI that will be probed if type is HTTP(S). url_path = resource.prop('url_path')
class FloatingIP(resource.Resource): name_attribute = "floating_ip_address" resource_name = "floating ip" resource_key = 'floatingip' resources_key = 'floatingips' base_path = '/floatingips' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The floating IP description. description = resource.prop('description') #: The fixed IP address associated with the floating IP. If you #: intend to associate the floating IP with a fixed IP at creation #: time, then you must indicate the identifier of the internal port. #: If an internal port has multiple associated IP addresses, the #: service chooses the first IP unless you explicitly specify the #: parameter fixed_ip_address to select a specific IP. fixed_ip_address = resource.prop('fixed_ip_address') #: The floating IP address. floating_ip_address = resource.prop('floating_ip_address') #: The ID of the network associated with the floating IP. floating_network_id = resource.prop('floating_network_id') #: The port ID. port_id = resource.prop('port_id') #: The ID of the project this floating IP is associated with. project_id = resource.prop('tenant_id') #: The ID of an associated router. router_id = resource.prop('router_id') #: The floating IP status. Value is ``ACTIVE`` or ``DOWN``. status = resource.prop('status') @classmethod def find_available(cls, session): params = { 'port_id': '', 'fields': cls.id_attribute, } info = cls.list(session, params=params) try: return next(info) except StopIteration: return None
class Limits(resource.Resource): base_path = "/limits" resource_key = "limits" service = compute_service.ComputeService() allow_retrieve = True absolute = resource.prop("absolute", type=AbsoluteLimits) rate = resource.prop("rate", type=list) def get(self, session, args=None, include_headers=False): """Get the Limits resource. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param dict args: An optional dict that will be translated into query strings for retrieving the object when specified. :returns: A Limits instance :rtype: :class:`~openstack.compute.v2.limits.Limits` """ body = self.get_data_by_id(session, self.id, include_headers=include_headers) # Split the rates away from absolute limits. We can create # the `absolute` property and AbsoluteLimits resource directly # from the body. We have to iterate through the list inside `rate` # in order to create the RateLimits instances for the `rate` property. rate_body = body.pop("rate") self._attrs.update(body) rates = [] for rate in rate_body: rates.append(RateLimits(rate)) self._attrs.update({"rate": rates}) self._loaded = True return self
class SubnetPool(resource.Resource): resource_key = 'subnetpool' resources_key = 'subnetpools' base_path = '/subnetpools' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The minimum prefix length that can be allocated from the #: subnet pool. *Type: int* minimum_prefix_length = resource.prop('min_prefixlen', type=int) #: The length of the prefix to allocate when the cidr or prefixlen #: attributes are omitted when creating a subnet. *Type: int* default_prefix_length = resource.prop('default_prefixlen', type=int) #: The maximum prefix length that can be allocated from the #: subnet pool. *Type: int* maximum_prefix_length = resource.prop('max_prefixlen', type=int) #: The subnet pool name. name = resource.prop('name') #: A per-project quota on the prefix space that can be allocated #: from the subnet pool for project subnets. For IPv4 subnet pools, #: default_quota is measured in units of /32. For IPv6 subnet pools, #: default_quota is measured units of /64. All projects that use the #: subnet pool have the same prefix quota applied. *Type: int* default_quota = resource.prop('default_quota', type=int) #: The ID of the project that owns the subnet pool. project_id = resource.prop('tenant_id') #: A list of subnet prefixes that are assigned to the subnet pool. #: The adjacent prefixes are merged and treated as a single prefix. #: *Type: list* prefixes = resource.prop('prefixes', type=list) #: Read-only. The IP address family of the list of prefixes. #: *Type: int* ip_version = resource.prop('ip_version', type=int) #: Indicates whether this subnet pool is shared across all projects. #: *Type: bool* is_shared = resource.prop('shared', type=bool)
class Endpoint(resource.Resource): resource_key = 'endpoint' resources_key = 'endpoints' base_path = '/endpoints' service = identity_service.IdentityService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True patch_update = True # Properties #: Setting this value to ``False`` prevents the endpoint from appearing #: in the service catalog. *Type: bool* enabled = resource.prop('enabled', type=bool) #: Describes the visibility of the endpoint according to one of the #: following values: #: #: - `public`: intended for consumption by end users, generally on a #: publicly available network interface #: #: - `internal`: not intended for consumption by end users, generally on an #: unmetered internal network interface #: #: - `admin`: intended only for consumption by those needing administrative #: access to the service, generally on a secure network interface #: *Type: string* interface = resource.prop('interface') #: Represents the containing region of the service endpoint. *New in v3.2* #: *Type: string* region_id = resource.prop('region_id') #: References the service to which the endpoint belongs. *Type: string* service_id = resource.prop('service_id') #: Fully qualified URL of the service endpoint. *Type: string* url = resource.prop('url')
class User(resource.Resource): resource_key = 'user' resources_key = 'users' base_path = '/users' service = identity_service.AdminService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The email of this user. *Type: string* email = resource.prop('email') #: Setting this value to ``False`` prevents the user from authenticating or #: receiving authorization. Additionally, all pre-existing tokens held by #: the user are immediately invalidated. Re-enabling a user does not #: re-enable pre-existing tokens. *Type: bool* is_enabled = resource.prop('enabled', type=bool) #: The name of this user. *Type: string* name = resource.prop('name')
class Fake(resource.Resource): resource_key = "resource" resources_key = "resources" base_path = "/fake" service = fake_service.FakeService() id_attribute = "name" allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True allow_head = True #: The transaction date and time. timestamp = resource.prop("x-timestamp") #: The name of this resource. name = resource.prop("name") #: The value of the resource. Also available in headers. value = resource.prop("value", alias="x-resource-value") #: Is this resource cool? If so, set it to True. #: This is a multi-line comment about cool stuff. cool = resource.prop("cool", type=bool)
class Version(resource.Resource): resource_key = 'version' resources_key = 'versions' base_path = '/' service = identity_service.IdentityService( version=identity_service.IdentityService.UNVERSIONED) # capabilities allow_list = True # Properties media_types = resource.prop('media-types') status = resource.prop('status') updated = resource.prop('updated') @classmethod def list(cls, session, **params): resp = session.get(cls.base_path, endpoint_filter=cls.service, params=params) resp = resp.json() for data in resp[cls.resources_key]['values']: yield cls.existing(**data)
class MeteringLabel(resource.Resource): resource_key = 'metering_label' resources_key = 'metering_labels' base_path = '/metering/metering-labels' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: Description of the metering label. description = resource.prop('description') #: Name of the metering label. name = resource.prop('name') #: The ID of the project this metering label is associated with. project_id = resource.prop('tenant_id') #: Indicates whether this label is shared across all tenants. #: *Type: bool* is_shared = resource.prop('shared', type=bool)
class Tenant(resource.Resource): resource_key = 'tenant' resources_key = 'tenants' base_path = '/tenants' service = identity_service.AdminService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The description of the tenant. *Type: string* description = resource.prop('description') #: Setting this attribute to ``False`` prevents users from authorizing #: against this tenant. Additionally, all pre-existing tokens authorized #: for the tenant are immediately invalidated. Re-enabling a tenant #: does not re-enable pre-existing tokens. *Type: bool* enabled = resource.prop('enabled', type=bool) #: Unique tenant name. *Type: string* name = resource.prop('name')
class Subnet(resource.Resource): resource_key = 'subnet' resources_key = 'subnets' base_path = '/v2.0/subnets' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties allocation_pools = resource.prop('allocation_pools') cidr = resource.prop('cidr') dns_nameservers = resource.prop('dns_nameservers') enable_dhcp = resource.prop('enable_dhcp', type=bool) gateway_ip = resource.prop('gateway_ip') host_routes = resource.prop('host_routes') ip_version = resource.prop('ip_version') name = resource.prop('name') network_id = resource.prop('network_id') project_id = resource.prop('tenant_id')
class HealthMonitor(resource.Resource): resource_key = 'healthmonitor' resources_key = 'healthmonitors' base_path = '/v2.0/healthmonitors' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties admin_state_up = resource.prop('admin_state_up', type=bool) delay = resource.prop('delay') expected_codes = resource.prop('expected_codes') http_method = resource.prop('http_method') max_retries = resource.prop('max_retries') project_id = resource.prop('tenant_id') status = resource.prop('status') timeout = resource.prop('timeout') type = resource.prop('type') url_path = resource.prop('url_path')
class Group(resource.Resource): resource_key = 'group' resources_key = 'groups' base_path = '/groups' service = identity_service.IdentityService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True patch_update = True # Properties #: The description of this group. *Type: string* description = resource.prop('description') #: References the domain which owns the group; if a domain is not #: specified by the client, the Identity service implementation will #: default it to the domain to which the client's token is scoped. #: *Type: string* domain_id = resource.prop('domain_id') #: Unique group name, within the owning domain. *Type: string* name = resource.prop('name')
class Flavor(resource.Resource): resource_key = 'flavor' resources_key = 'flavors' base_path = '/flavors' service = compute_service.ComputeService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: Links pertaining to this flavor. This is a list of dictionaries, #: each including keys ``href`` and ``rel``. links = resource.prop('links') #: The name of this flavor. name = resource.prop('name') #: Size of the disk this flavor offers. *Type: int* disk = resource.prop('disk', type=int) #: ``True`` if this is a publicly visible flavor. ``False`` if this is #: a private image. *Type: bool* is_public = resource.prop('os-flavor-access:is_public', type=bool) #: The amount of RAM (in MB) this flavor offers. *Type: int* ram = resource.prop('ram', type=int) #: The number of virtual CPUs this flavor offers. *Type: int* vcpus = resource.prop('vcpus', type=int) #: Size of the swap partitions. swap = resource.prop('swap') #: Size of the ephemeral data disk attached to this server. *Type: int* ephemeral = resource.prop('OS-FLV-EXT-DATA:ephemeral', type=int) #: ``True`` if this flavor is disabled, ``False`` if not. *Type: bool* is_disabled = resource.prop('OS-FLV-DISABLED:disabled', type=bool) #: The bandwidth scaling factor this flavor receives on the network. rxtx_factor = resource.prop('rxtx_factor', type=float)
class Flavor(resource.Resource): resource_key = 'flavor' resources_key = 'flavors' base_path = '/flavors' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # properties #: description for the flavor description = resource.prop('description') #: Sets enabled flag is_enabled = resource.prop('enabled', type=bool) #: The name of the flavor name = resource.prop('name') #: The owner project ID project_id = resource.prop('tenant_id') #: Service type to which the flavor applies service_type = resource.prop('service_type')
class ServerIP(resource.Resource): id_attribute = 'addr' resource_key = 'server_ip' resources_key = 'server_ips' base_path = '/servers/%(server_id)s/ips' service = compute_service.ComputeService() # capabilities allow_list = True # Properties #: The IP address. The format of the address depends on :attr:`version` addr = resource.prop('addr') #: The network label, such as public or private. network_label = resource.prop('network_label') #: The ID for the server. server_id = resource.prop('server_id') # Version of the IP protocol. Currently either 4 or 6. version = resource.prop('version') @classmethod def list(cls, session, path_args=None, **params): url = cls._get_url(path_args) resp = session.get(url, endpoint_filter=cls.service, params=params) resp = resp.json() ray = [] for network_label, addresses in six.iteritems(resp['addresses']): for address in addresses: record = { 'server_id': path_args['server_id'], 'network_label': network_label, 'version': address['version'], 'addr': address['addr'], } ray.append(cls.existing(**record)) return ray
class ServiceProfile(resource.Resource): resource_key = 'service_profile' resources_key = 'service_profiles' base_path = '/service_profiles' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: Description of the service flavor profile. description = resource.prop('description') #: Provider Driver for the service flavor profile driver = resource.prop('driver') #: Sets enabled flag is_enabled = resource.prop('enabled', type=bool) #: Metainformation of the service flavor profile metainfo = resource.prop('metainfo') #: The owner project ID project_id = resource.prop('tenant_id')
class Pool(resource.Resource): resource_key = 'pool' resources_key = 'pools' base_path = '/v2.0/pools' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties admin_state_up = resource.prop('admin_state_up', type=bool) description = resource.prop('description') healthmonitor_id = resource.prop('healthmonitor_id') lb_algorithm = resource.prop('lb_algorithm') members = resource.prop('members') name = resource.prop('name') project_id = resource.prop('tenant_id') protocol = resource.prop('protocol') session_persistence = resource.prop('session_persistence') status = resource.prop('status')
class Image(resource.Resource, metadata.MetadataMixin): resource_key = 'image' resources_key = 'images' base_path = '/images' service = compute_service.ComputeService() # capabilities allow_retrieve = True allow_delete = True allow_list = True # Properties #: Links pertaining to this image. This is a list of dictionaries, #: each including keys ``href`` and ``rel``, and optionally ``type``. links = resource.prop('links') #: The name of this image. name = resource.prop('name') #: Timestamp when the image was created. #: *Type: datetime object parsed from ISO 8601 formatted string* created_at = resource.prop('created', type=format.ISO8601) #: Metadata pertaining to this image. *Type: dict* metadata = resource.prop('metadata', type=dict) #: The mimimum disk size. *Type: int* min_disk = resource.prop('minDisk', type=int) #: The minimum RAM size. *Type: int* min_ram = resource.prop('minRam', type=int) #: If this image is still building, its progress is represented here. #: Once an image is created, progres will be 100. *Type: int* progress = resource.prop('progress', type=int) #: The status of this image. status = resource.prop('status') #: Timestamp when the image was updated. #: *Type: datetime object parsed from ISO 8601 formatted string* updated_at = resource.prop('updated', type=format.ISO8601) #: Size of the image in bytes. *Type: int* size = resource.prop('OS-EXT-IMG-SIZE:size', type=int)
class AddressScope(resource.Resource): resource_key = 'address_scope' resources_key = 'address_scopes' base_path = '/address-scopes' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: The address scope name. name = resource.prop('name') #: The ID of the project that owns the address scope. project_id = resource.prop('tenant_id') #: The IP address family of the address scope. #: *Type: int* ip_version = resource.prop('ip_version', type=int) #: Indicates whether this address scope is shared across all projects. #: *Type: bool* is_shared = resource.prop('shared', type=bool)
class RBACPolicy(resource.Resource): resource_key = 'rbac_policy' resources_key = 'rbac_policies' base_path = '/rbac-policies' service = network_service.NetworkService() # capabilities allow_create = True allow_retrieve = True allow_update = True allow_delete = True allow_list = True # Properties #: ID of the object that this RBAC policy affects. object_id = resource.prop('object_id') #: The ID of the project this RBAC will be enforced. target_project_id = resource.prop('target_tenant') #: The owner project ID. project_id = resource.prop('tenant_id') #: Type of the object that this RBAC policy affects. object_type = resource.prop('object_type') #: Action for the RBAC policy. action = resource.prop('action')