Ejemplo n.º 1
0
class Job(resource.Resource):
    """Job Resource"""
    base_path = "/jobs"
    service = lb_service.LoadBalancerService()

    # capabilities
    allow_get = True

    #: Properties
    id = resource.Body("job_id")
    type = resource.Body("job_type")
    begin_time = resource.Body("begin_time")
    end_time = resource.Body("end_time")
    entities = resource.Body("entities")
    status = resource.Body("status")
    error_code = resource.Body("error_code")
    fail_reason = resource.Body("fail_reason")
Ejemplo n.º 2
0
class ServerDetail(Servers):
    base_path = '/cloudservers/detail'

    # capabilities
    allow_create = False
    allow_get = False
    allow_list = True

    _query_mapping = resource2.QueryParameters(
        'name',
        'status',
        'limit',
        'offset',
        'reservation_id',
        'enterprise_project_id',
        'tags',
        not_tags='not-tags',
        flavor_id='flavor'
    )

    # The total number of lists of elastic cloud servers.
    count = resource2.Body('count', type=int)
    # Elastic cloud server details list.
    servers = resource2.Body('servers', type=list)
Ejemplo n.º 3
0
class AlertConfig(resource.Resource):

    base_path = '/warnalert/alertconfig/query'
    service = anti_ddos_service.AntiDDosService()

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

    # Properties
    #: warn alert config information
    #: *Type: dict*
    warn_config = resource.Body('warn_config', type=dict)
    #: unique topic id
    topic_urn = resource.Body('topic_urn')
    #: warn alert group name
    display_name = resource.Body('display_name')

    # This overrides the default behavior of resource get
    def get(self, session, requires_id=False):
        return super(AlertConfig, self).get(session, requires_id=requires_id)
Ejemplo n.º 4
0
class Securitytoken(resource2.Resource):
    resource_key = 'credential'
    resources_key = 'credentials'
    base_path = '/OS-CREDENTIAL/securitytokens'
    service = iam_service.IamService()

    #: The access key of the securitytoken.
    access = resource2.Body('access')
    #: The secret key of the securitytoken.
    secret = resource2.Body('secret')
    #: The expire time of the securitytoken.
    expires_at = resource2.Body('expires_at')
    #: The securitytoken of the securitytoken.
    securitytoken = resource2.Body('securitytoken')

    def create(self, session, **attrs):
        endpoint_override = self.service.get_endpoint_override()
        uri = self.base_path
        response = session.post(uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=attrs)
        self._translate_response(response)
        return self
Ejemplo n.º 5
0
class Statuses(resource2.Resource):
    resource_key = 'statuses'
    resources_key = 'statuses'
    base_path = '/lbaas/loadbalancers/%(loadbalance_id)s/statuses'
    service = network_service.NetworkService()

    allow_create = False
    allow_get = True
    allow_update = False
    allow_delete = False
    allow_list = False
    # loadbalancer
    loadbalancer = resource2.Body("loadbalancer", type=dict)
    # loadbalancer id
    loadbalance_id = resource2.URI("loadbalance_id")
Ejemplo n.º 6
0
class ServerOS(resource2.Resource):
    base_path = "/cloudservers"
    allow_create = True

    service = compute_service.ComputeService()

    # admin password
    adminpass = resource2.Body("adminpass")
    # key name
    keyname = resource2.Body("keyname")
    # user id
    userid = resource2.Body("userid")
    # metadata
    metadata = resource2.Body("metadata", type=dict)

    def reinstall(self, session, server_id):
        url = utils.urljoin(self.base_path, server_id, 'reinstallos')
        headers = {'Accept': ''}
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        body = {"os-reinstall": self._body.dirty}
        return session.post(
            url, endpoint_filter=self.service, microversion=service.microversion, json=body, headers=headers,
            endpoint_override=endpoint_override).json()
Ejemplo n.º 7
0
class FlavorExtraSpecs(resource.Resource):
    resources_key = 'os-extra_specs'
    base_path = '/flavors/%(flavor_id)s/os-extra_specs'
    service = compute_service.ComputeService()

    #: The ID for the flavor.
    flavor_id = resource.URI('flavor_id')

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

    extra_specs = resource.Body('extra_specs')
Ejemplo n.º 8
0
class Quota(KmsResource):

    # Properties

    # Resource type
    type = resource.Body('type')
    #: Used resource
    #: *Type: int*
    used = resource.Body('used', type=int)
    #: Quota number for this kind of resource
    #: *Type: int*
    quota = resource.Body('quota', type=int)
    #: Error code
    error_code = resource.Body('error_code')
    #: Error message
    error_msg = resource.Body('error_msg')

    @classmethod
    def list(cls, session):
        url = utils.urljoin(cls.base_path, 'user-quotas')
        endpoint_override = cls.service.get_endpoint_override()
        headers = {
            "Accept": "application/json",
            "Content-type": "application/json",
        }
        resp = session.get(url,
                           endpoint_filter=cls.service,
                           endpoint_override=endpoint_override,
                           headers=headers)
        resp = resp.json()
        if 'error' in resp:
            return
        resources = resp['quotas']['resources']
        for r in resources:
            value = cls.existing(**r)
            yield value
Ejemplo n.º 9
0
class Endpoint(resource.Resource):
    resource_key = 'endpoint'
    resources_key = 'endpoints'
    base_path = '/endpoints'
    service = identity_service.IdentityService()

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

    _query_mapping = resource.QueryParameters('interface', 'service_id')

    # Properties
    #: Describes the interface 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.Body('interface')
    #: Setting this value to ``False`` prevents the endpoint from appearing
    #: in the service catalog. *Type: bool*
    is_enabled = resource.Body('enabled', type=bool)
    #: The links for the region resource.
    links = resource.Body('links', type=dict)
    #: Represents the containing region ID of the service endpoint.
    #: *New in v3.2* *Type: string*
    region_id = resource.Body('region_id')
    #: References the service ID to which the endpoint belongs. *Type: string*
    service_id = resource.Body('service_id')
    #: Fully qualified URL of the service endpoint. *Type: string*
    url = resource.Body('url')
    #: The id of the endpoint. *Type: string*
    id = resource.Body('id')
    #: The region of the endpoint. *Type: string*
    region = resource.Body('region')
Ejemplo n.º 10
0
class PortGroupDetail(PortGroup):

    base_path = '/portgroups/detail'

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

    _query_mapping = resource.QueryParameters(
        'node', 'address',
    )

    #: The UUID for the portgroup
    id = resource.Body('uuid', alternate_id=True)
Ejemplo n.º 11
0
class LindedResource(resource.Resource):
    base_path = "/backuppolicyresources"
    service = volume_backup_service.VolumeBackupService()

    # capabilities
    allow_create = True

    #: Properties
    resource_id = resource.Body("resource_id")
    resource_type = resource.Body("resource_type")
    availability_zone = resource.Body("availability_zone")
    os_vol_host_attr = resource.Body("os_vol_host_attr")
    message = resource.Body("message")
    code = resource.Body("code")
    success = resource.Body("success", type=bool)

    def link(self, session, backup_policy_id, resources):
        """link resources to backup policy

        :param session: openstack session
        :param backup_policy_id: backup policy id
        :param resources: resources to bound, should be a list of volume id
        :return:
        """
        _resources = [dict(resource_id=volume_id, resource_type="volume")
                      for volume_id in resources]
        body = {
            "backup_policy_id": backup_policy_id,
            "resources": _resources
        }
        endpoint_override = self.service.get_endpoint_override()
        response = session.post(self.base_path,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=body,
                                headers={})

        result = []
        response_json = response.json()
        if response_json and response_json["success_resources"]:
            for _resource in response_json["success_resources"]:
                _resource["success"] = True
                result.append(LindedResource.new(**_resource))

        if response_json and response_json["fail_resources"]:
            for _resource in response_json["fail_resources"]:
                _resource["success"] = False
                result.append(LindedResource.new(**_resource))

        return result
Ejemplo n.º 12
0
class Resource(resource.Resource):
    name_attribute = 'resource_name'
    resource_key = 'resource'
    resources_key = 'resources'
    base_path = '/stacks/%(stack_name)s/%(stack_id)s/resources'
    service = orchestration_service.OrchestrationService()

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

    # Properties
    #: A list of dictionaries containing links relevant to the resource.
    links = resource.Body('links')
    #: ID of the logical resource, usually the literal name of the resource
    #: as it appears in the stack template.
    logical_resource_id = resource.Body('logical_resource_id',
                                        alternate_id=True)
    #: Name of the resource.
    name = resource.Body('resource_name')
    #: ID of the physical resource (if any) that backs up the resource. For
    #: example, it contains a nova server ID if the resource is a nova
    #: server.
    physical_resource_id = resource.Body('physical_resource_id')
    #: A list of resource names that depend on this resource. This
    #: property facilitates the deduction of resource dependencies.
    #: *Type: list*
    required_by = resource.Body('required_by', type=list)
    #: A string representation of the resource type.
    resource_type = resource.Body('resource_type')
    #: A string representing the status the resource is currently in.
    status = resource.Body('resource_status')
    #: A string that explains why the resource is in its current status.
    status_reason = resource.Body('resource_status_reason')
    #: Timestamp of the last update made to the resource.
    updated_at = resource.Body('updated_time')
Ejemplo n.º 13
0
class ResizeServer(resource2.Resource):
    base_path = "/cloudservers/%(server_id)s/resize"
    resource_key = "resize"
    service = ecs_service.EcsServiceV1_1()

    allow_create = True

    server_id = resource2.URI('server_id')
    # extend server info
    extendparam = resource2.Body('extendparam', type=dict)
    # optional only support dedicated type host
    dedicated_host_id = resource2.Body('dedicated_host_id')
    # server size
    flavorRef = resource2.Body('flavorRef')
    # task id
    job_id = resource2.Body('job_id')
    # order id
    order_id = resource2.Body('order_id')
    error = resource2.Body('error')
    message = resource2.Body('message')
    code = resource2.Body('code')
    mode = resource2.Body('mode')
Ejemplo n.º 14
0
class DeleteServer(resource2.Resource):
    base_path = "/cloudservers/delete"

    service = ecs_service.EcsService()

    allow_create = True
    # whether delete server eip
    delete_publicip = resource2.Body('delete_publicip')
    # whether delete server volume disk
    delete_volume = resource2.Body('delete_volume')
    # ecs server id list
    servers = resource2.Body('servers', type=list)
    # ecs server id
    id = resource2.Body('id')

    # task id
    job_id = resource2.Body('job_id')
    # order id
    order_id = resource2.Body('order_id')
    error = resource2.Body('error')
    message = resource2.Body('message')
    code = resource2.Body('code')
class NetworkIPAvailability(resource.Resource):
    resource_key = 'network_ip_availability'
    resources_key = None
    base_path = '/network-ip-availabilities'
    service = vpc_service.VpcService()

    # capabilities
    allow_get = True

    # Properties
    #: The network ID.
    network_id = resource.Body('network_id')
    #: The network name.
    network_name = resource.Body('network_name')
    #: The project ID.
    project_id = resource.Body('tenant_id')
    #: The total number of IP addresses on a network.
    total_ips = resource.Body('total_ips', type=int)
    #: The number of in-use IP addresses on a network.
    used_ips = resource.Body('used_ips', type=int)
    #: The subnet IP address usage object.
    subnet_ip_availability = resource.Body('subnet_ip_availability', type=list)

    def get(self, session, requires_id=True):
        """Get a remote resource based on this instance.

        :param session: The session to use for making this request.
        :type session: :class:`~openstack.session.Session`
        :param boolean requires_id: A boolean indicating whether resource ID
                                    should be part of the requested URI.
        :return: This :class:`Resource` instance.
        :raises: :exc:`~openstack.exceptions.MethodNotSupported` if
                 :data:`Resource.allow_get` is not set to ``True``.
        """
        if not self.allow_get:
            raise exceptions.MethodNotSupported(self, "get")

        request = self._prepare_request(requires_id=requires_id)
        endpoint_override = self.service.get_endpoint_override() if self.service.get_endpoint_override() \
            else self.get_endpoint_override(session)
        service = self.get_service_filter(self, session)
        response = session.get(request.uri,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self

    def get_endpoint_override(self, session):
        endpoint = session.get_endpoint(interface=self.service.interface,
                                        service_type=self.service.service_type)
        endpoint_override = endpoint[0:endpoint.rindex('/')]
        return endpoint_override
Ejemplo n.º 16
0
class Snapshot(resource2.Resource):
    resource_key = "snapshot"
    resources_key = "snapshots"
    base_path = "/snapshots"
    service = block_store_service.BlockStoreService()

    _query_mapping = resource2.QueryParameters('all_tenants', 'name', 'status',
                                               'volume_id')

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

    # Properties
    #: A ID representing this snapshot.
    id = resource2.Body("id")
    #: Name of the snapshot. Default is None.
    name = resource2.Body("name")

    #: The current status of this snapshot. Potential values are creating,
    #: available, deleting, error, and error_deleting.
    status = resource2.Body("status")
    #: Description of snapshot. Default is None.
    description = resource2.Body("description")
    #: The timestamp of this snapshot creation.
    created_at = resource2.Body("created_at")
    #: Metadata associated with this snapshot.
    metadata = resource2.Body("metadata", type=dict)
    #: The ID of the volume this snapshot was taken of.
    volume_id = resource2.Body("volume_id")
    #: The size of the volume, in GBs.
    size = resource2.Body("size", type=int)
    #: Indicate whether to create snapshot, even if the volume is attached.
    #: Default is ``False``. *Type: bool*
    is_forced = resource2.Body("force", type=format.BoolStr)
Ejemplo n.º 17
0
class Rule(resource2.Resource):
    resource_key = 'rule'
    resources_key = 'rules'
    base_path = '/lbaas/l7policies/%(policy_id)s/rules'
    service = network_service.NetworkService()

    _query_mapping = resource2.QueryParameters("id", "tenant_id",
                                               "admin_state_up", "type",
                                               "compare_type", "invert", "key",
                                               "value")

    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True
    # the rule id
    id = resource2.Body("id")
    # tenant id
    tenant_id = resource2.Body("tenant_id")
    # Management status: true/false.
    # Instructions for use: Fixed to true
    admin_state_up = resource2.Body("admin_state_up", type=bool, default=True)
    # Matching content: Can be HOST_NAME, PATH
    type = resource2.Body("type")
    # Matching method:
    # EQUAL_TO when type is HOST_NAME.
    # REGEX when the type is PATH, STARTS_WITH, EQUAL_TO
    compare_type = resource2.Body("compare_type")
    # Whether the match is reversed, true/false.
    # Instructions for use: Fixed to false. This field can be updated but will not take effect
    invert = resource2.Body("invert", type=bool, default=False)
    # Match the content key.
    # Usage note: When the current match is HOST_NAME and PATH, this field does not take effect.
    # This field can be updated but will not take effect
    key = resource2.Body("key")
    # The value of the matching content. Its value cannot contain spaces.
    # Usage note: When the type is HOST_NAME, the value range is String(100).
    # The string can only contain English letters, numbers, "-" or ".",
    # and must start with a letter or number.
    rule_value = resource2.Body("value")
    # policy id the rule belongs to
    policy_id = resource2.URI("policy_id")
Ejemplo n.º 18
0
class InstanceHookList(resource.Resource):
    resource_key = 'instance_hanging_info'
    resources_key = 'instance_hanging_infos'
    base_path = '/scaling_instance_hook/%(scaling_group_id)s/list'
    allow_list = True
    service = auto_scaling_service.AutoScalingService()

    _query_mapping = resource.QueryParameters('instance_id')

    lifecycle_action_key = resource.Body('lifecycle_action_key')
    instance_id = resource.Body('instance_id')
    lifecycle_hook_name = resource.Body('lifecycle_hook_name')
    scaling_group_id = resource.Body('scaling_group_id')
    lifecycle_hook_status = resource.Body('lifecycle_hook_status')
    timeout = resource.Body('timeout')
    default_result = resource.Body('default_result')
Ejemplo n.º 19
0
class SchedulePolicy(resource.Resource):
    #: whether keep the first backup of current month
    remain_first_backup_of_curMonth = resource.Body(
        "remain_first_backup_of_curMonth", type=format.YNBool)
    #: the max backup amount, min value is 2
    rentention_num = resource.Body("rentention_num", type=int)
    #: backup period, valid values, 1..14 (days)
    frequency = resource.Body("frequency", type=int)
    #: backup start time of every day, example: 12:00
    start_time = resource.Body("start_time")
    #: backup policy status, ``ON``, ``OFF``
    status = resource.Body("status")
    # week frequency
    week_frequency = resource.Body("week_frequency", type=list)
    # Backup retention days
    rentention_day =  resource.Body("rentention_day", type=int)
Ejemplo n.º 20
0
class QoSRuleType(resource.Resource):
    resource_key = 'rule_type'
    resources_key = 'rule_types'
    base_path = '/qos/rule-types'
    service = network_service.NetworkService()

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

    _query_mapping = resource.QueryParameters('type')

    # Properties
    #: QoS rule type name.
    type = resource.Body('type')
class QoSDSCPMarkingRule(resource.Resource):
    resource_key = 'dscp_marking_rule'
    resources_key = 'dscp_marking_rules'
    base_path = '/qos/policies/%(qos_policy_id)s/dscp_marking_rules'
    service = network_service.NetworkService()

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

    # Properties
    #: The ID of the QoS policy who owns rule.
    qos_policy_id = resource.URI('qos_policy_id')
    #: DSCP mark field.
    dscp_mark = resource.Body('dscp_mark')
Ejemplo n.º 22
0
class Credential(resource2.Resource):
    resource_key = 'credential'
    resources_key = 'credentials'
    base_path = '/OS-CREDENTIAL/credentials'
    service = iam_service.IamService()

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

    _query_mapping = resource2.QueryParameters('user_id')

    # Properties
    #: The last_use_time of the credential.
    last_use_time = resource2.Body('last_use_time')
    #: The accesskey of the credential.
    access = resource2.Body('access')
    #: The create_time of the credential.
    create_time = resource2.Body('create_time')
    #: The user_id of the credential.
    user_id = resource2.Body('user_id')
    #: The description key of the credential.
    description = resource2.Body('description')
    #: The status key of the credential.
    status = resource2.Body('status')
    #: The secret key of the credential.
    secret = resource2.Body('secret')

    def get_credential(self, session, access_key):
        endpoint_override = self.service.get_endpoint_override()
        url = utils.urljoin(self.base_path, access_key)
        response = session.get(url, endpoint_filter=self.service,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self

    def update_credential(self, session, access_key, **attrs):
        endpoint_override = self.service.get_endpoint_override()
        url = utils.urljoin(self.base_path, access_key)
        response = session.put(url, endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=attrs)
        self._translate_response(response)
        return self
Ejemplo n.º 23
0
class Policy(resource.Resource):
    resource_key = 'policy'
    resources_key = 'policies'
    base_path = '/policies'
    service = clustering_service.ClusteringService()

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

    patch_update = True

    _query_mapping = resource.QueryParameters('name', 'type', 'sort',
                                              'global_project')

    # Properties
    #: The name of the policy.
    name = resource.Body('name')
    #: The type name of the policy.
    type = resource.Body('type')
    #: The ID of the project this policy belongs to.
    project_id = resource.Body('project')
    # The domain ID of the policy.
    domain_id = resource.Body('domain')
    #: The ID of the user who created this policy.
    user_id = resource.Body('user')
    #: The timestamp when the policy is created.
    created_at = resource.Body('created_at')
    #: The timestamp when the policy was last updated.
    updated_at = resource.Body('updated_at')
    #: The specification of the policy.
    spec = resource.Body('spec', type=dict)
    #: A dictionary containing runtime data of the policy.
    data = resource.Body('data', type=dict)
Ejemplo n.º 24
0
class Member(resource.Resource):
    base_path = '/elbaas/listeners/%(listener_id)s/members'
    service = lb_service.LoadBalancerService()

    # capabilities
    allow_create = True
    allow_delete = True
    allow_list = True

    _query_mapping = resource.QueryParameters("address", "server_address",
                                              "server_id", "status",
                                              "health_status")

    #: Properties
    #: Load balancer listener reference of this member
    listener_id = resource.URI("listener_id")
    #: EIP address of the member server
    address = resource.Body('address')
    #: internal IP address of the member server
    server_address = resource.Body('server_address')
    #: member server ID
    server_id = resource.Body('server_id')
    #: member server name
    server_name = resource.Body('server_name')
    #: member server status, valid value includes: ``ACTIVE``, ``PENDING``,
    #: ``ERROR``
    status = resource.Body('status')
    #: Health check status, valid value includes: ``NORMAL``, ``ABNORMAL``,
    #: ``UNAVAILABLE``
    health_status = resource.Body('health_status')
    #: List of listeners associated with this member.
    #: *Type: list of dicts which contain the listener IDs*
    listeners = resource.Body('listeners', type=list)
    #: UTC date and time of the member created time
    create_time = resource.Body("create_time")
    #: UTC date and time of the member updated time
    update_time = resource.Body("update_time")
Ejemplo n.º 25
0
class Profile(resource.Resource):
    resource_key = 'profile'
    resources_key = 'profiles'
    base_path = '/profiles'
    service = cluster_service.ClusterService()

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

    patch_update = True

    _query_mapping = resource.QueryParameters('sort', 'global_project', 'type',
                                              'name')

    # Bodyerties
    #: The name of the profile
    name = resource.Body('name')
    #: The type of the profile.
    type = resource.Body('type')
    #: The ID of the project this profile belongs to.
    project_id = resource.Body('project')
    #: The domain ID of the profile.
    domain_id = resource.Body('domain')
    #: The ID of the user who created this profile.
    user_id = resource.Body('user')
    #: The spec of the profile.
    spec = resource.Body('spec', type=dict)
    #: A collection of key-value pairs that are attached to the profile.
    metadata = resource.Body('metadata', type=dict)
    #: Timestamp of when the profile was created.
    created_at = resource.Body('created_at')
    #: Timestamp of when the profile was last updated.
    updated_at = resource.Body('updated_at')
Ejemplo n.º 26
0
class Member(resource2.Resource):
    resource_key = 'member'
    resources_key = 'members'
    base_path = '/lbaas/pools/%(pool_id)s/members'
    service = network_service.NetworkService()

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

    _query_mapping = resource2.QueryParameters()
    # member id
    id = resource2.Body("id")
    # tenant id
    tenant_id = resource2.Body("tenant_id")
    # member name
    name = resource2.Body("name")
    # IP address corresponding to member, for example, 192.168.3.11
    # Instructions for use: only the IP address of the main network card
    address = resource2.Body("address")
    # Back-end protocol number, value range [1,65535]
    protocol_port = resource2.Body("protocol_port", type=int)
    # Subnet id
    subnet_id = resource2.Body("subnet_id")
    # Management status, true/false.
    # Instructions for use: Fixed to true
    admin_state_up = resource2.Body("admin_state_up", type=bool, default=True)
    # Weight, ranging from [0,100].
    # Usage note: The backend with zero weight no longer accepts new requests
    weight = resource2.Body("weight", type=int, default=1)
    # The health status of the backend cloud server can be ONLINE or OFFLINE
    operating_status = resource2.Body("operating_status")
    # The pool id to which this member belongs
    pool_id = resource2.URI("pool_id")
Ejemplo n.º 27
0
class QueryOrderDetail(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders/%(order_id)s"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('offset', 'limit')

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.URI('order_id')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Total number of records.
    count = resource2.Body('count')
    # Order details.
    orderInfo = resource2.Body('orderInfo')
    # ID of the primary order item mapping the order item.
    orderlineItems = resource2.Body('orderlineItems')

    def list(cls, session, **params):
        query_params = cls._query_mapping._transpose(params)
        uri = cls.get_list_uri(params)
        service = cls.get_service_filter(cls, session)
        endpoint_override = cls.service.get_endpoint_override()

        resp = session.get(uri,
                           endpoint_filter=cls.service,
                           microversion=service.microversion,
                           endpoint_override=endpoint_override,
                           headers={"Accept": "application/json"},
                           params=query_params)

        response_json = resp.json()
        if not response_json:
            return

        value = cls.existing(**response_json)
        return value
Ejemplo n.º 28
0
class EnterpriseProjectDetail(resource2.Resource):
    """Define a EnterpriseProject class. get detail and update EP"""

    base_path = '/enterprise-projects/%(enterprise_project_id)s'
    service = eps_service.EpsService()

    # Allow operation for this resource.
    # capabilities
    allow_create = False
    allow_list = False
    allow_get = True
    allow_update = False
    allow_delete = False
    enterprise_project_id = resource2.URI("enterprise_project_id")
    enterprise_project = resource2.Body("enterprise_project")
    id = resource2.Body("id")
    name = resource2.Body("name")
    description = resource2.Body("description")
    status = resource2.Body("status", type=int)
    created_at = resource2.Body("created_at")
    updated_at = resource2.Body("updated_at")

    def get(self, session, requires_id=True):
        """Get a remote resource based on this instance.

        :param session: The session to use for making this request.
        :type session: :class:`~openstack.session.Session`
        :param boolean requires_id: A boolean indicating whether resource ID
                                    should be part of the requested URI.
        :return: This :class:`Resource` instance.
        :raises: :exc:`~openstack.exceptions.MethodNotSupported` if
                 :data:`Resource.allow_get` is not set to ``True``.
        """
        if not self.allow_get:
            raise exceptions.MethodNotSupported(self, "get")

        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        response = session.get(request.uri,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
class UnfreezeCustomer(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/unfrozens"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    customerIds = resource2.Body('customerIds', type=list)
    reason = resource2.Body('reason')
    # response
    failNum = resource2.Body('failNum')
    successNum = resource2.Body('successNum')
    failDetail = resource2.Body('failDetail', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Ejemplo n.º 30
0
class LifecycleHookBase(resource.Resource):
    resource_key = 'lifecycle_hook'
    resources_key = 'lifecycle_hooks'
    base_path = '/scaling_lifecycle_hook/%(scaling_group_id)s'
    service = auto_scaling_service.AutoScalingService()

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

    name = resource.Body("lifecycle_hook_name")
    scaling_group_id = resource.URI('scaling_group_id')
    lifecycle_hook_type = resource.Body('lifecycle_hook_type')
    default_result = resource.Body('default_result')
    default_timeout = resource.Body('default_timeout')
    notification_topic_urn = resource.Body('notification_topic_urn')
    notification_topic_name = resource.Body('notification_topic_name')
    notification_metadata = resource.Body('notification_metadata')
    create_time = resource.Body('create_time')