コード例 #1
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
コード例 #2
0
class LicenseType(resource2.Resource):
    resources_key = "license_types"
    resource_key = None
    base_path = '/license_types'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True

    # Properties
    #: id of license type.
    id = resource2.Body('id')
    #: name of license type.
    name = resource2.Body('name')
    #: description of th elicense.
    description = resource2.Body('description')
    #: true if the you can create license key by API
    has_license_key = resource2.Body('has_license_key')
    #: unit of the license
    unit = resource2.Body('unit')
    #:
    license_switch = resource2.Body('license_switch')

    @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))
コード例 #3
0
ファイル: usage.py プロジェクト: nttcom/eclsdk
class Usage(resource2.Resource):
    resources_key = "usages"
    resource_key = None
    base_path = '/usages'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True
    allow_get = True

    # Properties
    #: history id of Guest Image usage.
    id = resource2.Body('id')
    #: license type name for the usage.
    name = resource2.Body('name')
    #: license type description for the usage.
    description = resource2.Body('description')
    #: type of Guest Image usage.
    type = resource2.Body('type')
    #: if true, there is license key.
    has_license_key = resource2.Body('has_license_key')
    #: unit for the usage.
    unit = resource2.Body('unit')
    #: usage value.
    value = resource2.Body('value')
    #: uuid for the resource.
    resource_id = resource2.Body('resource_id')
    #: date to list usage from.
    From = resource2.Body('from')
    #: date to list usage to.
    #: month of the parameter must be the same as `from` .
    to = resource2.Body('to')
    #: name of license type to show.
    license_type = resource2.Body('license_type')
    #: histories of the usage
    histories = resource2.Body('histories')

    def get_usage_histories(self, session, history_id, **kwargs):
        """Shows your Guest Image usage history information."""

        params = []
        for key in kwargs.keys():
            item = "%s=%s" % (str(key), quote(str(kwargs[key]))) \
                if key in ['from', 'to'] \
                else "%s=%s" % (str(key), str(kwargs[key]))
            params.append(item)

        uri = self.base_path + '/%s/histories' % history_id
        if len(params) != 0:
            uri += '?'
            for item in params:
                uri += item + '&'
            uri = uri[:-1]

        resp = session.get(uri, endpoint_filter=self.service)
        self._translate_response(resp, has_body=True)
        return self
コード例 #4
0
    def __init__(self, plugins=None):
        """User preference for each service.

        :param list plugins: List of entry point namespaces to load.

        Create a new :class:`~ecl.profile.Profile`
        object with no preferences defined, but knowledge of the services.
        Services are identified by their service type, e.g.: 'identity',
        'compute', etc.
        """
        self._services = {}
        self._add_service(compute_service.ComputeService(version="v2"))
        self._add_service(
            connectivity_service.ConnectivityService(version="v1"))
        self._add_service(identity_service.IdentityService(version="v3"))
        self._add_service(image_service.ImageService(version="v2"))
        self._add_service(network_service.NetworkService(version="v2"))
        self._add_service(sss_service.SssService(version="v1"))
        self._add_service(
            orchestration_service.OrchestrationService(version="v1"))
        self._add_service(
            provider_connectivity_service.ProviderConnectivityService(
                version="v2"))
        self._add_service(telemetry_service.TelemetryService(version="v2"))
        self._add_service(block_store_service.BlockStoreService(version="v2"))
        self._add_service(storage_service.StorageService(version="v1"))
        self._add_service(
            security_order_service.SecurityOrderService(version="v2"))
        self._add_service(
            security_portal_service.SecurityPortalService(version="v2"))
        ## This section will be deleted if MSS v1 API is not available
        self._add_service(
            security_order_service_v1.SecurityOrderService(version="v1"))
        self._add_service(
            security_portal_service_v1.SecurityPortalService(version="v1"))
        ## end of the section
        self._add_service(rca_service.RcaService(version="v1"))
        self._add_service(baremetal_service.BaremetalService(version="v2"))
        self._add_service(
            dedicated_hypervisor_service.DedicatedHypervisorService(
                version="v1"))
        self._add_service(dns_service.DnsService(version="v2"))
        self._add_service(
            virtual_network_appliance_service.VirtualNetworkApplianceService(
                version="v1"))
        self._add_service(mvna_service.MVNAService(version="v1"))

        # NOTE: The Metric service is not added here as it currently
        # only retrieves the /capabilities API.

        if plugins:
            for plugin in plugins:
                self._load_plugin(plugin)
        self.service_keys = sorted(self._services.keys())
コード例 #5
0
ファイル: server.py プロジェクト: xinni-ge/eclsdk
class Server(resource2.Resource):
    resources_key = "servers"
    resource_key = "server"
    base_path = '/servers'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

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

    _query_mapping = resource2.QueryParameters("image", "flavor", "name",
                                               "status",
                                               changes_since="changes-since")

    # Properties
    #: id of Dedicated Hypervisor instance.
    id = resource2.Body('id')
    #: Link of the Dedicated Hypervisor server.
    links = resource2.Body('links')
    #: name of Dedicated Hypervisor instance.
    name = resource2.Body('name')
    #: description of Dedicated Hypervisor instance.
    description = resource2.Body('description')
    #: type of hypervisor. vsphere_esxi or hyper_v.
    hypervisor_type = resource2.Body('hypervisor_type')
    #: image id of Dedicated Hypervisor instance.
    imageRef = resource2.Body('imageRef')
    image = resource2.Body('imageRef')
    #: flavor id of Dedicated Hypervisor instance.
    flavorRef = resource2.Body('flavorRef')
    flavor = resource2.Body('flavorRef')
    #: Networks.
    networks = resource2.Body('networks')
    #: Password for the administrator.
    adminPass = resource2.Body('adminPass')
    admin_pass = resource2.Body('adminPass')
    #: Status of the Dedicated Hypervisor instance.
    status = resource2.Body('status')
    #: detail of baremetal server.
    baremetal_server = resource2.Body('baremetal_server')
    #: Server's availability zone.
    availability_zone = resource2.Body('availability_zone')
コード例 #6
0
class Sddc(resource2.Resource):
    resources_key = "sddcs"
    resource_key = "sddc"
    base_path = '/sddcs'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters(
        "changes-since",
        "maker",
        "limit",
        "name",
    )

    # Properties
    #: id of sddc instance.
    id = resource2.Body('id')
    #: name of sddc instance.
    name = resource2.Body('name')