Пример #1
0
class IAMRole(resource2.Resource):
    resource_key = None
    resources_key = 'iam_roles'
    base_path = '/iam/roles'

    # Capabilities
    allow_create = True
    allow_delete = True
    allow_list = True
    allow_get = True

    # Properties
    #: The IAM Role's ID.
    iam_role_id = resource2.Body('iam_role_id', alternate_id=True)
    #: The IAM Role's name.
    iam_role_name = resource2.Body('iam_role_name')
    #: Description of the IAM Role.
    description = resource2.Body('description')
    #: Whitelist rules of API exectution.
    resources = resource2.Body('resources')
    #: The contact ID that the IAM Role belongs.
    contract_id = resource2.Body('contract_id')

    def list(self, session, contract_id):
        """List IAM Role list in the designated contract."""

        url = self.base_path + '?contract_id=%s' % contract_id
        resp = session.get(url, endpoint_filter=self.service)
        self._translate_response(resp, has_body=True)
        return self
Пример #2
0
class License(resource2.Resource):
    resources_key = "licenses"
    resource_key = "license"
    base_path = '/licenses'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True
    allow_create = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters("license_type")

    # Properties
    #: id of Guest Image license.
    id = resource2.Body('id')
    #: license key.
    key = resource2.Body('key')
    #: date the license assigned from.
    assigned_from = resource2.Body('assigned_from')
    #: expiration date for the license.
    expires_at = resource2.Body('expires_at')
    #: license_type of the license
    license_type = resource2.Body('license_type')

    def create(self, session, l_type):
        url = self.base_path
        resp = session.post(url,
                            endpoint_filter=self.service,
                            json={"license_type": l_type})
        self._translate_response(resp, has_body=True)
        return self
Пример #3
0
class Stock(resource2.Resource):
    resource_key = 'stock'
    base_path = '/stock'
    service = baremetal_service.BaremetalService()

    # Capabilities
    allow_get = True

    # Properties
    #: Flavor UUID of Baremetal server stock search condition.
    flavor_id = resource2.Body('flavor_id', alternate_id=True)
    #: Availability Zone name of Baremetal server stock search condition.
    availability_zone = resource2.Body('availability_zone')
    #: Baremetal server stock is available or not.
    stock = resource2.Body('stock')

    def get(self, session, flavor_id, availability_zone=None):
        uri = self.base_path + "?flavor_id=%s" % flavor_id
        if availability_zone:
            uri += "&availability_zone=%s" % availability_zone
        resp = session.get(uri,
                           endpoint_filter=self.service,
                           headers={"Accept": "application/json"})
        self._translate_response(resp, has_body=True)
        return self
Пример #4
0
class ColocationSpace(base.NetworkBaseResource):
    resource_key = 'colocation_space'
    resources_key = 'colocation_spaces'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/colocation_spaces'

    # capabilities
    allow_get = True
    allow_list = True

    # query mappings
    _query_mapping = resource2.QueryParameters(
        'description',
        'id',
        'name',
        "sort_key",
        "sort_dir",
    )

    # properties
    #: Colocation Space description.
    description = resource2.Body('description')
    #: Colocation Space unique id.
    id = resource2.Body('id')
    #: Colocation Space name.
    name = resource2.Body('name')
Пример #5
0
class ServerInterface(resource2.Resource):
    resource_key = 'interfaceAttachment'
    resources_key = 'interfaceAttachments'
    base_path = '/servers/%(server_id)s/os-interface'
    service = compute_service.ComputeService()

    # capabilities
    allow_create = True
    allow_get = False
    allow_update = False
    allow_delete = True
    allow_list = True

    #: Fixed IP addresses with subnet IDs.
    fixed_ips = resource2.Body('fixed_ips')
    #: The MAC address.
    mac_addr = resource2.Body('mac_addr')
    #: The network ID.
    net_id = resource2.Body('net_id')
    #: The ID of the port for which you want to create an interface.
    port_id = resource2.Body('port_id', alternate_id=True)
    #: The port state.
    port_state = resource2.Body('port_state')
    #: The ID for the server.
    server_id = resource2.URI('server_id')
Пример #6
0
class PhysicalPort(resource2.Resource):
    resource_key = 'physical_port'
    resources_key = 'physical_ports'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/physical_ports'

    # capabilities
    allow_get = True
    allow_list = True

    # properties
    #: Physical port description.
    description = resource2.Body('description')
    #: Physical port unique id.
    id = resource2.Body('id')
    #: Physical port name.
    name = resource2.Body('name')
    #: The type of traffic that port will be used.
    plane = resource2.Body('plane')
    #: Ranges of allowed VLAN tags.
    segmentation_ranges = resource2.Body('segmentation_ranges')
    #: The ID of service that owns the physical port.
    service_id = resource2.Body('service_id')
    #: The type of physical port service owner.
    service_owner = resource2.Body('service_owner')
    #: The Physical Port status.
    status = resource2.Body('status')
    #: Port tags.
    tags = resource2.Body('tags')
    #: The owner name of physical port.
    tenant_id = resource2.Body('tenant_id')
Пример #7
0
class ReservedAddress(resource2.Resource):
    resource_key = 'reserve_address'
    resources_key = 'reserve_addresses'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/reserve_addresses'

    _query_mapping = resource2.QueryParameters(
        "subnets",
        "id",
        "destination",
        "sort_key",
        "sort_dir",
    )

    # capabilities
    allow_create = False
    allow_get = True
    allow_update = False
    allow_delete = False
    allow_list = True

    # Properties
    #: id of the reserved address
    id = resource2.Body("id")
    #: subnets cidr of the reserved address
    subnets = resource2.Body("subnets")
    #: tenant id that reserved address belong to
    tenant_id = resource2.Body("tenant_id")
Пример #8
0
class Database(resource2.Resource):
    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

    allow_update = False
    allow_get = False

    # Properties
    #: Name of Database.
    name = resource2.Body('name', alternate_id=True)
    #: Character set of Database.
    character_set = resource2.Body('character_set')
    #: Collate of Database.
    collate = resource2.Body('collate')
    #: ID of instance associated with this database
    instance_id = resource2.URI('instance_id')

    def create(self, session, instance_id, **attrs):
        base = self.base_path % {"instance_id": instance_id}
        body = {"databases": [attrs]}
        resp = session.post(base, endpoint_filter=self.service, json=body,
                            headers={"Accept": "application/json"})
        self._translate_response(resp, has_body=False)
        return self
Пример #9
0
class User(resource2.Resource):
    resource_key = "user"
    resources_key = "users"
    base_path = '/users'
    service = rca_service.RcaService()

    # Capabilities
    allow_create = True
    allow_delete = True
    allow_update = True
    allow_list = True
    allow_get = True

    # Properties
    #: User's name of VPN connection.
    name = resource2.Body('name', alternate_id=True)
    #: User's password of VPN connection.
    #: This parameter is only included in the response of Create User.
    password = resource2.Body('password')
    #: VPN user information list id = resource2.Body('name', alternate_id=True)
    vpn_endpoints = resource2.Body('vpn_endpoints')

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Пример #10
0
class AddressAssignment(resource2.Resource):
    resources_key = "address_assignments"
    resource_key = "address_assignment"

    service = provider_connectivity_service.ProviderConnectivityService("v2.0")
    base_path = '/' + service.version + \
                '/tenant_connection_requests/' \
                '%(tenant_connection_request_id)s/address_assignment'

    # capabilities
    allow_list = True

    #: tenant_connection_request unique ID.
    tenant_connection_request_id = resource2.URI(
        "tenant_connection_request_id")

    #: tenant_connection unique ID.
    tenant_connection_id = resource2.Body("tenant_connection_id")

    #: Network unique ID
    network_id = resource2.Body("network_id")

    #: mac address assigned with port
    mac_address = resource2.Body("mac_address")

    #: List of fixes IP addresses assign to port.
    fixed_ips = resource2.Body("fixed_ips")

    #: Allowed address pairs
    allowed_address_pairs = resource2.Body("allowed_address_pairs")

    @staticmethod
    def _get_id(value):
        if isinstance(value, resource2.Resource):
            # Don't check _alternate_id unless we need to. It's an uncommon
            # case and it involves looping through the class' dict.
            id = value.id or getattr(
                value, value._alternate_id(),
                hashlib.new('md5', str(value)).hexdigest())
            return id
        else:
            return value

    def __getattribute__(self, name):
        """Return an attribute on this instance

        This is mostly a pass-through except for a specialization on
        the 'id' name, as this can exist under a different name via the
        `alternate_id` argument to resource.Body.
        """
        if name == "id":
            if name in self._body:
                return self._body[name]
            elif self._alternate_id():
                return self._body[self._alternate_id()]
            else:
                return hashlib.new('md5', str(self)).hexdigest()
        else:
            return object.__getattribute__(self, name)
Пример #11
0
class RateLimit(resource2.Resource):

    #: A list of the specific limits that apply to the ``regex`` and ``uri``.
    limits = resource2.Body("limit", type=list)
    #: A regex representing which routes this rate limit applies to.
    regex = resource2.Body("regex")
    #: A URI representing which routes this rate limit applies to.
    uri = resource2.Body("uri")
Пример #12
0
class AvailabilityZone(resource2.Resource):
    resources_key = 'availabilityZoneInfo'
    base_path = '/os-availability-zone'

    service = baremetal_service.BaremetalService()

    # capabilities
    allow_list = True

    # Properties
    #: name of availability zone
    zoneName = resource2.Body('zoneName', alternate_id=True)
    name = resource2.Body('zoneName', alternate_id=True)
    #: state of availability zone
    zoneState = resource2.Body('zoneState')
    state = resource2.Body('zoneState')
    #: hosts of availability zone
    hosts = resource2.Body('hosts')

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Пример #13
0
class TenantConnection(NetworkBaseResource):
    resource_key = "tenant_connection"
    resources_key = "tenant_connections"

    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/tenant_connections'

    allow_list = True
    allow_get = True
    allow_create = True
    allow_delete = True
    allow_update = True

    _query_mapping = resource2.QueryParameters(
        "approval_request_id", "interface_type",
        "name", "description", "id", "progress",
        "tenant_id", "sort_key", "sort_dir",
    )

    approval_request_id = resource2.Body("approval_request_id")
    connected_interface = resource2.Body("connected_interface", dict)
    connected_network = resource2.Body("connected_network", dict)
    interface_type = resource2.Body("interface_type")
    description = resource2.Body("description")
    id = resource2.Body("id")
    name = resource2.Body("name")
    progress = resource2.Body("progress")
    tenant_id = resource2.Body("tenant_id")

    def execute(self, session):
        """Preform tenant connection execute."""
        url = utils.urljoin(TenantConnection.base_path, self.id, 'execute')
        headers = {'Accept': ''}
        return session.post(
            url, endpoint_filter=self.service, headers=headers)
Пример #14
0
class User(resource2.Resource):
    resource_key = "user"
    resources_key = "users"
    base_path = '/instances/%(instance_id)s/users'
    service = database_service.DatabaseService()

    # _query_mapping = resource2.QueryParameters()

    # Capabilities
    allow_create = True
    allow_delete = True
    allow_list = True
    allow_update = True
    allow_get = True

    # Properties
    #: User's name of Database instance.
    name = resource2.Body('name', alternate_id=True)

    #: Allowed access host of user.
    host = resource2.Body('host')

    #: Relevant database of this user.
    databases = resource2.Body('databases', type=list)

    #: User's password of Database instance.
    #: This parameter is only used in instance creation.
    password = resource2.Body('password')

    #: ID of instance associated with this user
    instance_id = resource2.URI('instance_id')

    def create(self, session, instance_id, **attrs):
        base = self.base_path % {"instance_id": instance_id}
        body = {"users": [attrs]}
        resp = session.post(base, endpoint_filter=self.service, json=body,
                            headers={"Accept": "application/json"})
        self._translate_response(resp, has_body=False)
        return self

    def grant(self, session, instance_id, user, databases):
        base = self.base_path % {"instance_id": instance_id}
        uri = "%s/%s/databases" % (base, user)
        resp = session.put(uri, endpoint_filter=self.service,
                           json={"databases": databases})
        self._translate_response(resp, has_body=False)
        return self

    def revoke(self, session, instance_id, user, database):
        base = self.base_path % {"instance_id": instance_id}
        uri = uri = "%s/%s/databases/%s" % (base, user, database)
        resp = session.delete(uri, endpoint_filter=self.service)
        self._translate_response(resp, has_body=False)
        return self
Пример #15
0
class ExchangePoint(resource2.Resource):
    resources_key = "exchange_points"
    service = provider_connectivity_service.ProviderConnectivityService("v1.0")
    base_path = '/' + service.version + '/icc/exchange_points'

    # Capabilities
    allow_list = True

    # Properties
    #: It identifies exchange_point resource uniquely.
    id = resource2.Body('id')
    #: Pair of location name of AWS and ECL2.0.
    location_names = resource2.Body('location_names')
Пример #16
0
class VPNInterface(NetworkBaseResource):

    resource_key = "vpn_interface"
    resources_key = "vpn_interfaces"
    base_path = '/v2.0/vpn_interfaces'
    service = network_service.NetworkService()

    allow_list = True
    allow_get = True
    allow_create = True
    allow_update = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters(
        "description", "id",
        "name", "vpn_gw_id",
        "status", "tenant_id",
        "sort_key", "sort_dir",
    )

    description = resource2.Body("description")
    id = resource2.Body("id")
    vpn_gw_id = resource2.Body("vpn_gw_id")
    name = resource2.Body("name")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
    primary = resource2.Body("primary")
    secondary = resource2.Body("secondary")

    def wait_for_interface(self, session, status='ACTIVE', failures=['ERROR'],
                           interval=2, wait=120):
        return resource2.wait_for_status(session, self, status,
                                         failures, interval, wait)
Пример #17
0
class GCPInterface(NetworkBaseResource):

    resource_key = "gcp_interface"
    resources_key = "gcp_interfaces"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gcp_interfaces'

    allow_list = True
    allow_get = True

    #: GCP Gateway to which this interface is connected.
    gcp_gw_id = resource2.Body("gcp_gw_id")
    #: Description of the GCP Interface resource.
    description = resource2.Body("description")
    #: Unique ID of the GCP Interface resource.
    id = resource2.Body("id")
    #: Name of the GCP Interface resource
    name = resource2.Body("name")
    #: The GCP Interface status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")
    #: Primary router uplink ip configuration.
    primary = resource2.Body("primary")
    #: Secondary router uplink ip configuration.
    secondary = resource2.Body("secondary")
Пример #18
0
class CIC(resource2.Resource):

    resource_key = None
    resources_key = None
    base_path = '/mCICs/%(mcic_id)s/CICs'
    service = connectivity_service.ConnectivityService()

    # capabilities
    allow_get = True
    allow_list = True
    allow_create = True
    allow_delete = True
    allow_update = True

    _query_mapping = resource2.QueryParameters("sort_key", "sort_dir")

    cic_id = resource2.Body("cic_id", alternate_id=True)
    cic_name = resource2.Body("cic_name")
    cic_status = resource2.Body("cic_status")
    network_id = resource2.Body("network_id")
    network_name = resource2.Body("network_name")
    destination_vlan = resource2.Body("destination_vlan", type=int)
    colo_vlan = resource2.Body("colo_vlan", type=int)
    bandwidth = resource2.Body("bandwidth", type=int)
    mcic_id = resource2.URI("mcic_id")

    def update(self, session, mcic_id, cic_id, has_body=True, **attrs):
        uri = self.base_path % ({'mcic_id': mcic_id})
        uri = utils.urljoin(uri, cic_id)
        args = {'json': attrs}
        resp = session.put(uri, endpoint_filter=self.service, **args)
        self._translate_response(resp, has_body=False)
        return self
Пример #19
0
class AWSService(NetworkBaseResource):

    resource_key = "aws_service"
    resources_key = "aws_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/aws_services'

    allow_list = True
    allow_get = True

    description = resource2.Body("description")
    id = resource2.Body("id")
    zone = resource2.Body("zone")
    name = resource2.Body("name")
Пример #20
0
class SoftwareDeployment(resource.Resource):
    resource_key = 'software_deployment'
    resources_key = 'software_deployments'
    base_path = '/software_deployments'
    service = orchestration_service.OrchestrationService()

    # capabilities
    allow_create = True
    allow_list = True
    allow_get = True
    allow_delete = True
    allow_update = True

    # Properties
    #: The stack action that triggers this deployment resource.
    action = resource.Body('action')
    #: The UUID of the software config resource that runs when applying to the
    #: server.
    config_id = resource.Body('config_id')
    #: A map containing the names and values of all inputs to the config.
    input_values = resource.Body('input_values', type=dict)
    #: A map containing the names and values from the deployment.
    output_values = resource.Body('output_values', type=dict)
    #: The UUID of the compute server to which the configuration applies.
    server_id = resource.Body('server_id')
    #: The ID of the authentication project which can also perform operations
    #: on this deployment.
    stack_user_project_id = resource.Body('stack_user_project_id')
    #: Current status of the software deployment.
    status = resource.Body('status')
    #: Error description for the last status change.
    status_reason = resource.Body('status_reason')
    #: The date and time when the software deployment resource was created.
    created_at = resource.Body('creation_time')
    #: The date and time when the software deployment resource was created.
    updated_at = resource.Body('updated_time')

    def create(self, session):
        # This overrides the default behavior of resource creation because
        # heat doesn't accept resource_key in its request.
        return super(SoftwareDeployment, self).create(session,
                                                      prepend_key=False)

    def update(self, session):
        # This overrides the default behavior of resource creation because
        # heat doesn't accept resource_key in its request.
        return super(SoftwareDeployment, self).update(session,
                                                      prepend_key=False)
Пример #21
0
class NameServer(resource2.Resource):
    resource_key = None
    resources_key = "nameservers"
    base_path = '/v2/zones/%(zone_id)s/nameservers'
    service = dns_service.DnsService()

    # Capabilities
    allow_list = True

    # Properties
    #: ID for the zone.
    zone_id = resource2.URI('zone_id')
    #: The hostname of the nameserver that the zone should be delegated to.
    hostname = resource2.Body('hostname', alternate_id=True)
    #: The priority of the nameserver. This is used to determine the order of the the nameserver listings,
    #: and which server is used in the SOA record for the zone. This parameter is not currently supported.
    priority = resource2.Body('priority')
Пример #22
0
class InterDCService(NetworkBaseResource):

    resource_key = "interdc_service"
    resources_key = "interdc_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/interdc_services'

    allow_list = True
    allow_get = True

    _query_mapping = resource2.QueryParameters("description", "id", "zone",
                                               "name")

    description = resource2.Body("description")
    id = resource2.Body("id")
    zone = resource2.Body("zone")
    name = resource2.Body("name")
Пример #23
0
class Operation(resource2.Resource):
    resources_key = "operations"
    service = provider_connectivity_service.ProviderConnectivityService("v1.0")
    base_path = '/' + service.version + '/icc/operations'

    # Capabilities
    allow_list = True

    _query_mapping = resource2.QueryParameters("connection_id",)

    # Properties
    #: It identifies connection resource uniquely.
    connection_id = resource2.Body('connection_id', alternate_id=True)
    #: order type.
    order_type = resource2.Body('order_type')
    #: operation phase.
    phase = resource2.Body('phase')
    #: Status of phase.
    operation_status = resource2.Body('operation_status')
    #: reception datetime. YYYY-MM-DD HH:MM:SS format.
    reception_datetime = resource2.Body('reception_datetime')
    #: commit datetime. YYYY-MM-DD HH:MM:SS format.
    commit_datetime = resource2.Body('commit_datetime')
    #: Request body is stored.
    request_body = resource2.Body('request_body')
Пример #24
0
class GCPService(NetworkBaseResource):

    resource_key = "gcp_service"
    resources_key = "gcp_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gcp_services'

    allow_list = True
    allow_get = True

    #: Description of the GCP Service resource.
    description = resource2.Body("description")
    #: Unique ID of the GCP Service resource.
    id = resource2.Body("id")
    #: Name of zone.
    zone = resource2.Body("zone")
    #: Name of the GCP Service resource.
    name = resource2.Body("name")
Пример #25
0
class ICCSubnet(subnet.Subnet):

    service = provider_connectivity_service.ProviderConnectivityService("v2.0")
    base_path = '/' + service.version + \
                '/tenant_connection_requests/' \
                '%(tenant_connection_request_id)s/subnets'

    id = resource2.Body("id")
    tenant_connection_request_id = resource2.URI(
        "tenant_connection_request_id")

    allow_list = True
    allow_create = False
    allow_delete = False
    allow_update = False
    allow_get = True

    dhcp_server_address = resource2.Body('dhcp_server_address')
Пример #26
0
class Image(resource2.Resource, metadata.MetadataMixin):
    resource_key = 'image'
    resources_key = 'images'
    base_path = '/images'
    service = compute_service.ComputeService()

    # capabilities
    allow_get = True
    allow_delete = True
    allow_list = True

    _query_mapping = resource2.QueryParameters("server",
                                               "name",
                                               "status",
                                               "type",
                                               min_disk="minDisk",
                                               min_ram="minRam",
                                               changes_since="changes-since")

    # Properties
    #: Links pertaining to this image. This is a list of dictionaries,
    #: each including keys ``href`` and ``rel``, and optionally ``type``.
    links = resource2.Body('links')
    #: The name of this image.
    name = resource2.Body('name')
    #: Timestamp when the image was created.
    created_at = resource2.Body('created')
    #: Metadata pertaining to this image. *Type: dict*
    metadata = resource2.Body('metadata', type=dict)
    #: The mimimum disk size. *Type: int*
    min_disk = resource2.Body('minDisk', type=int)
    #: The minimum RAM size. *Type: int*
    min_ram = resource2.Body('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 = resource2.Body('progress', type=int)
    #: The status of this image.
    status = resource2.Body('status')
    #: Timestamp when the image was updated.
    updated_at = resource2.Body('updated')
    #: Size of the image in bytes. *Type: int*
    size = resource2.Body('OS-EXT-IMG-SIZE:size', type=int)
Пример #27
0
class Limits(resource2.Resource):
    base_path = "/limits"
    resource_key = "limits"
    service = baremetal_service.BaremetalService()

    allow_get = True

    absolute = resource2.Body("absolute", type=AbsoluteLimits)
    rate = resource2.Body("rate", type=list)

    def get(self, session, requires_id=False):
        """Get the Limits resource.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`

        :returns: A Baremetal Limits instance
        :rtype: :class:`~ecl.baremetal.v2.limits.Limits`
        """
        request = self._prepare_request(requires_id=False, prepend_key=False)

        response = session.get(request.uri, endpoint_filter=self.service)

        body = response.json()
        body = body[self.resource_key]

        absolute_body = self._filter_component(
            body["absolute"], AbsoluteLimits._body_mapping())
        self.absolute = AbsoluteLimits.existing(**absolute_body)

        rates_body = body["rate"]

        rates = []
        for rate_body in rates_body:
            rate_body = self._filter_component(rate_body,
                                               RateLimit._body_mapping())
            rates.append(RateLimit(**rate_body))

        self.rate = rates

        return self
Пример #28
0
class ServerSegment(resource2.Resource):

    resource_key = None  # Get is not allowed.
    resources_key = 'server_segments'

    base_path = '/ec_services/%(service_id)s/server_segments'
    service = connectivity_service.ConnectivityService()

    # capabilities
    allow_get = False
    allow_list = True

    # _query_mapping = resource2.QueryParameters("mcic_id", "cic_id")

    # Properties
    #: server segment number.
    server_segment_nbr = resource2.Body('server_segment_nbr',
                                        type=int,
                                        alternate_id=True)
    #: server segment name.
    server_segment_name = resource2.Body('server_segment_name')
Пример #29
0
class ServerVolume(resource2.Resource):
    resource_key = 'volumeAttachment'
    resources_key = 'volumeAttachments'
    base_path = '/servers/%(serverId)s/os-volume_attachments'
    service = compute_service.ComputeService()

    # capabilities
    allow_create = True
    allow_get = False
    allow_update = False
    allow_delete = True
    allow_list = True

    #: Device name
    device = resource2.Body('device')
    #: Attachment ID
    id = resource2.Body('id')
    #: The ID of the server
    serverId = resource2.URI('serverId')
    #: The ID of the volume
    volumeId = resource2.Body('volumeId')
Пример #30
0
class Version(resource2.Resource):
    resource_key = 'version'
    resources_key = 'versions'
    base_path = '/'
    service = storage_service.StorageService(
        version=storage_service.StorageService.UNVERSIONED)

    # capabilities
    allow_list = True
    allow_get = True

    # Properties
    #: Version identifier included in API URL.
    id = resource2.Body('id', alternate_id=True)
    #: media-type object
    media_types = resource2.Body('media-types', type=dict)
    #: Created time of the version, although the name is "updated"
    updated = resource2.Body('updated')
    #: Version support status. Valid values are CURRENT or SUPPORTED.
    #: CURRENT is newest stable version. SUPPORTED is old supported version.
    status = resource2.Body('status')

    def list_version(self, session):
        uri = self.base_path
        resp = session.get(uri,
                           headers={"Accept": "application/json"},
                           endpoint_filter=self.service)
        resp = resp.json()[self.resources_key]

        for data in resp:
            version = self.existing(**data)
            yield version

    def get_version(self, session):
        url = self.base_path + 'v1.0'
        resp = session.get(url,
                           headers={"Accept": "application/json"},
                           endpoint_filter=self.service)
        self._translate_response(resp, has_body=True)
        return self