Ejemplo n.º 1
0
class HealthMonitorPOST(BaseHealthMonitorType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    type = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_HEALTH_MONITOR_TYPES),
        mandatory=True)
    delay = wtypes.wsattr(wtypes.IntegerType(minimum=0), mandatory=True)
    timeout = wtypes.wsattr(wtypes.IntegerType(minimum=0), mandatory=True)
    max_retries_down = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_HM_RETRIES,
                           maximum=constants.MAX_HM_RETRIES), default=3)
    max_retries = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_HM_RETRIES,
                           maximum=constants.MAX_HM_RETRIES),
        mandatory=True)
    http_method = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_HEALTH_MONITOR_HTTP_METHODS))
    url_path = wtypes.wsattr(
        types.URLPathType())
    expected_codes = wtypes.wsattr(
        wtypes.StringType(pattern=r'^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$'))
    admin_state_up = wtypes.wsattr(bool, default=True)
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    pool_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
Ejemplo n.º 2
0
class PoolPOST(BasePoolType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    listener_id = wtypes.wsattr(wtypes.UuidType())
    loadbalancer_id = wtypes.wsattr(wtypes.UuidType())
    protocol = wtypes.wsattr(wtypes.Enum(
        str, *lib_constants.POOL_SUPPORTED_PROTOCOLS),
                             mandatory=True)
    lb_algorithm = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_LB_ALGORITHMS),
                                 mandatory=True)
    session_persistence = wtypes.wsattr(SessionPersistencePOST)
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    healthmonitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
    members = wtypes.wsattr([member.MemberSingleCreate])
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    tls_container_ref = wtypes.wsattr(wtypes.StringType(max_length=255))
    ca_tls_container_ref = wtypes.wsattr(wtypes.StringType(max_length=255))
    crl_container_ref = wtypes.wsattr(wtypes.StringType(max_length=255))
    tls_enabled = wtypes.wsattr(bool, default=False)
    tls_ciphers = wtypes.wsattr(wtypes.StringType(max_length=2048))
    tls_versions = wtypes.wsattr(
        wtypes.ArrayType(wtypes.StringType(max_length=32)))
    alpn_protocols = wtypes.wsattr(wtypes.ArrayType(types.AlpnProtocolType()))
Ejemplo n.º 3
0
class HealthMonitorSingleCreate(BaseHealthMonitorType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    type = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_HEALTH_MONITOR_TYPES),
                         mandatory=True)
    delay = wtypes.wsattr(wtypes.IntegerType(minimum=0), mandatory=True)
    timeout = wtypes.wsattr(wtypes.IntegerType(minimum=0), mandatory=True)
    max_retries_down = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_HM_RETRIES,
                           maximum=constants.MAX_HM_RETRIES),
        default=constants.DEFAULT_MAX_RETRIES_DOWN)
    max_retries = wtypes.wsattr(wtypes.IntegerType(
        minimum=constants.MIN_HM_RETRIES, maximum=constants.MAX_HM_RETRIES),
                                mandatory=True)
    http_method = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_HEALTH_MONITOR_HTTP_METHODS))
    url_path = wtypes.wsattr(types.URLPathType())
    expected_codes = wtypes.wsattr(
        wtypes.StringType(pattern=r'^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$'))
    admin_state_up = wtypes.wsattr(bool, default=True)
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    http_version = wtypes.wsattr(
        wtypes.Enum(float, *constants.SUPPORTED_HTTP_VERSIONS))
    domain_name = wtypes.wsattr(
        wtypes.StringType(min_length=1,
                          max_length=255,
                          pattern=constants.DOMAIN_NAME_REGEX))
Ejemplo n.º 4
0
class MagnumService(base.APIBase):

    host = wtypes.StringType(min_length=1, max_length=255)
    """Name of the host """

    binary = wtypes.Enum(str, *fields.MagnumServiceBinary.ALL)
    """Name of the binary"""

    state = wtypes.Enum(str, *fields.MagnumServiceState.ALL)
    """State of the binary"""

    id = wsme.wsattr(wtypes.IntegerType(minimum=1))
    """The id for the healthcheck record """

    report_count = wsme.wsattr(wtypes.IntegerType(minimum=0))
    """The number of times the heartbeat was reported """

    # disabled = wsme.wsattr(wtypes.BoolType(default=False))
    """If the service is 'disabled' administratively """

    disabled_reason = wtypes.StringType(min_length=0, max_length=255)
    """Reason for disabling """
    def __init__(self, state, **kwargs):
        super(MagnumService, self).__init__()

        self.fields = ['state']
        setattr(self, 'state', state)
        for field in objects.MagnumService.fields:
            self.fields.append(field)
            setattr(self, field, kwargs.get(field, wtypes.Unset))
Ejemplo n.º 5
0
class L7RulePUT(base.BaseType):
    """Defines attributes that are acceptable of a PUT request."""
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_L7RULE_TYPES))
    compare_type = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_L7RULE_COMPARE_TYPES))
    key = wtypes.wsattr(wtypes.StringType(max_length=255))
    value = wtypes.wsattr(wtypes.StringType(max_length=255))
    invert = wtypes.wsattr(bool)
Ejemplo n.º 6
0
class PTP(base.APIBase):
    """API representation of PTP configuration.

    This class enforces type checking and value constraints, and converts
    between the internal object model and the API representation of
    an ptp.
    """

    uuid = types.uuid
    "Unique UUID for this ptp"

    enabled = types.boolean
    "Represent the status of the ptp."

    mode = wtypes.Enum(str, 'hardware', 'software', 'legacy')
    "Time stamping mode used by ptp."

    transport = wtypes.Enum(str, 'l2', 'udp')
    "Network transport used by ptp."

    mechanism = wtypes.Enum(str, 'e2e', 'p2p')
    "Messaging mechanism used by ptp."

    links = [link.Link]
    "A list containing a self link and associated ptp links"

    isystem_uuid = types.uuid
    "The UUID of the system this ptp belongs to"

    created_at = wtypes.datetime.datetime
    updated_at = wtypes.datetime.datetime

    def __init__(self, **kwargs):
        self.fields = objects.ptp.fields.keys()
        for k in self.fields:
            setattr(self, k, kwargs.get(k))

    @classmethod
    def convert_with_links(cls, rpc_ptp, expand=True):

        ptp = PTP(**rpc_ptp.as_dict())
        if not expand:
            ptp.unset_fields_except([
                'uuid', 'enabled', 'mode', 'transport', 'mechanism',
                'isystem_uuid', 'created_at', 'updated_at'
            ])

        ptp.links = [
            link.Link.make_link('self', pecan.request.host_url, 'ptps',
                                ptp.uuid),
            link.Link.make_link('bookmark',
                                pecan.request.host_url,
                                'ptps',
                                ptp.uuid,
                                bookmark=True)
        ]

        return ptp
Ejemplo n.º 7
0
class PoolPUT(base.BaseType):
    """Defines attributes that are acceptable of a PUT request."""
    name = wtypes.wsattr(wtypes.StringType())
    description = wtypes.wsattr(wtypes.StringType())
    enabled = wtypes.wsattr(bool)
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS))
    lb_algorithm = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_LB_ALGORITHMS))
    session_persistence = wtypes.wsattr(SessionPersistencePUT)
Ejemplo n.º 8
0
def get_metrics_list():
    metrics_conf = ck_utils.get_metrics_conf(CONF.collect.metrics_conf)
    try:
        metrics = list(metrics_conf['metrics'].keys())
        cloudkitty_metrics = wtypes.Enum(wtypes.text, *metrics)
    except KeyError:
        metrics = list(DEFAULT_METRICS_CONF['metrics'].keys())
        cloudkitty_metrics = wtypes.Enum(wtypes.text, *metrics)

    return cloudkitty_metrics
Ejemplo n.º 9
0
class L7RulePOST(base.BaseType):
    """Defines mandatory and optional attributes of a POST request."""
    id = wtypes.wsattr(wtypes.UuidType())
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_L7RULE_TYPES),
                         mandatory=True)
    compare_type = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_L7RULE_COMPARE_TYPES),
                                 mandatory=True)
    key = wtypes.wsattr(wtypes.StringType(max_length=255))
    value = wtypes.wsattr(wtypes.StringType(max_length=255), mandatory=True)
    invert = wtypes.wsattr(bool, default=False)
Ejemplo n.º 10
0
class PoolSingleCreate(BasePoolType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS))
    lb_algorithm = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_LB_ALGORITHMS))
    session_persistence = wtypes.wsattr(SessionPersistencePOST)
    healthmonitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
    members = wtypes.wsattr([member.MemberSingleCreate])
Ejemplo n.º 11
0
class L7RuleSingleCreate(BaseL7Type):
    """Defines mandatory and optional attributes of a POST request."""
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_L7RULE_TYPES),
                         mandatory=True)
    compare_type = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_L7RULE_COMPARE_TYPES),
                                 mandatory=True)
    key = wtypes.wsattr(wtypes.StringType(max_length=255))
    value = wtypes.wsattr(wtypes.StringType(max_length=255), mandatory=True)
    invert = wtypes.wsattr(bool, default=False)
    admin_state_up = wtypes.wsattr(bool, default=True)
Ejemplo n.º 12
0
class L7RulePOST(BaseL7Type):
    """Defines mandatory and optional attributes of a POST request."""
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_L7RULE_TYPES),
                         mandatory=True)
    compare_type = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_L7RULE_COMPARE_TYPES),
                                 mandatory=True)
    key = wtypes.wsattr(wtypes.StringType(max_length=255))
    value = wtypes.wsattr(wtypes.StringType(max_length=255), mandatory=True)
    invert = wtypes.wsattr(bool, default=False)
    admin_state_up = wtypes.wsattr(bool, default=True)
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
Ejemplo n.º 13
0
class ListenerPOST(BaseListenerType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS),
                             mandatory=True)
    protocol_port = wtypes.wsattr(wtypes.IntegerType(
        minimum=constants.MIN_PORT_NUMBER, maximum=constants.MAX_PORT_NUMBER),
                                  mandatory=True)
    connection_limit = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_CONNECTION_LIMIT),
        default=constants.DEFAULT_CONNECTION_LIMIT)
    default_tls_container_ref = wtypes.wsattr(
        wtypes.StringType(max_length=255))
    sni_container_refs = [wtypes.StringType(max_length=255)]
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    default_pool_id = wtypes.wsattr(wtypes.UuidType())
    default_pool = wtypes.wsattr(pool.PoolSingleCreate)
    l7policies = wtypes.wsattr([l7policy.L7PolicySingleCreate], default=[])
    insert_headers = wtypes.wsattr(
        wtypes.DictType(str, wtypes.StringType(max_length=255)))
    loadbalancer_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
    timeout_client_data = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT),
        default=CONF.haproxy_amphora.timeout_client_data)
    timeout_member_connect = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT),
        default=CONF.haproxy_amphora.timeout_member_connect)
    timeout_member_data = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT),
        default=CONF.haproxy_amphora.timeout_member_data)
    timeout_tcp_inspect = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT),
        default=CONF.haproxy_amphora.timeout_tcp_inspect)
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    client_ca_tls_container_ref = wtypes.StringType(max_length=255)
    client_authentication = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_CLIENT_AUTH_MODES),
                                          default=constants.CLIENT_AUTH_NONE)
    client_crl_container_ref = wtypes.StringType(max_length=255)
    allowed_cidrs = wtypes.wsattr([types.CidrType()])
    tls_ciphers = wtypes.StringType(max_length=2048)
    tls_versions = wtypes.wsattr(
        wtypes.ArrayType(wtypes.StringType(max_length=32)))
    alpn_protocols = wtypes.wsattr(wtypes.ArrayType(types.AlpnProtocolType()))
Ejemplo n.º 14
0
class PoolPOST(base.BaseType):
    """Defines mandatory and optional attributes of a POST request."""
    id = wtypes.wsattr(wtypes.UuidType())
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    enabled = wtypes.wsattr(bool, default=True)
    listener_id = wtypes.wsattr(wtypes.UuidType())
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS),
                             mandatory=True)
    lb_algorithm = wtypes.wsattr(wtypes.text, mandatory=True)
    lb_algorithm = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_LB_ALGORITHMS),
                                 mandatory=True)
    session_persistence = wtypes.wsattr(SessionPersistencePOST)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
Ejemplo n.º 15
0
 def __init__(self, name, *args, **kwargs):
     self._name = '_advenum_%s' % name
     self._default = kwargs.pop('default', None)
     mandatory = kwargs.pop('mandatory', False)
     enum = wtypes.Enum(*args, **kwargs)
     super(AdvEnum, self).__init__(datatype=enum, fget=self._get,
                                   fset=self._set, mandatory=mandatory)
Ejemplo n.º 16
0
class MessageModel(object):
    id = wtypes.StringType(min_length=1, max_length=255)
    message = wtypes.StringType(min_length=1, max_length=255)
    message_size = wtypes.IntegerType(minimum=1)
    message_from = wtypes.Enum(str, '1.OSOMATSU', '2.KARAMATSU',
                               '3.CHOROMATSU', '4.ICHIMATSU', '5.JUSHIMATSU',
                               '6.TODOMATSU')
Ejemplo n.º 17
0
class L7PolicyPUT(BaseL7PolicyType):
    """Defines attributes that are acceptable of a PUT request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool)
    action = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_L7POLICY_ACTIONS))
    redirect_pool_id = wtypes.wsattr(wtypes.UuidType())
    redirect_url = wtypes.wsattr(types.URLType())
    redirect_prefix = wtypes.wsattr(types.URLType())
    position = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_POLICY_POSITION,
                           maximum=constants.MAX_POLICY_POSITION))
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    redirect_http_code = wtypes.wsattr(
        wtypes.Enum(int, *constants.SUPPORTED_L7POLICY_REDIRECT_HTTP_CODES))
Ejemplo n.º 18
0
class ListenerPOST(BaseListenerType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS),
                             mandatory=True)
    protocol_port = wtypes.wsattr(wtypes.IntegerType(
        minimum=constants.MIN_PORT_NUMBER, maximum=constants.MAX_PORT_NUMBER),
                                  mandatory=True)
    connection_limit = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_CONNECTION_LIMIT), default=-1)
    default_tls_container_ref = wtypes.wsattr(
        wtypes.StringType(max_length=255))
    sni_container_refs = [wtypes.StringType(max_length=255)]
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    # TODO(johnsom) Remove after deprecation (R series)
    tenant_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    default_pool_id = wtypes.wsattr(wtypes.UuidType())
    default_pool = wtypes.wsattr(pool.PoolPOST)
    l7policies = wtypes.wsattr([l7policy.L7PolicyPOST], default=[])
    insert_headers = wtypes.wsattr(
        wtypes.DictType(str, wtypes.StringType(max_length=255)))
    loadbalancer_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
Ejemplo n.º 19
0
class ListenerPUT(BaseListenerType):
    """Defines attributes that are acceptable of a PUT request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool)
    connection_limit = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_CONNECTION_LIMIT))
    default_tls_container_ref = wtypes.wsattr(
        wtypes.StringType(max_length=255))
    sni_container_refs = [wtypes.StringType(max_length=255)]
    default_pool_id = wtypes.wsattr(wtypes.UuidType())
    insert_headers = wtypes.wsattr(
        wtypes.DictType(str, wtypes.StringType(max_length=255)))
    timeout_client_data = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT))
    timeout_member_connect = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT))
    timeout_member_data = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT))
    timeout_tcp_inspect = wtypes.wsattr(
        wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
                           maximum=constants.MAX_TIMEOUT))
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    client_ca_tls_container_ref = wtypes.StringType(max_length=255)
    client_authentication = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_CLIENT_AUTH_MODES))
    client_crl_container_ref = wtypes.StringType(max_length=255)
    allowed_cidrs = wtypes.wsattr([types.CidrType()])
    tls_ciphers = wtypes.StringType(max_length=2048)
    tls_versions = wtypes.wsattr(
        wtypes.ArrayType(wtypes.StringType(max_length=32)))
Ejemplo n.º 20
0
class Quota(base.APIBase):
    """API representation of a project Quota.

    This class enforces type checking and value constraints, and converts
    between the internal object model and the API representation of Quota.
    """
    id = wsme.wsattr(wtypes.IntegerType(minimum=1))
    """unique id"""

    hard_limit = wsme.wsattr(wtypes.IntegerType(minimum=1), default=1)
    """The hard limit for total number of clusters. Default to 1 if not set"""

    project_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),
                             default=None)
    """The project id"""

    resource = wsme.wsattr(wtypes.Enum(wtypes.text,
                                       *fields.QuotaResourceName.ALL),
                           default='Cluster')
    """The resource name"""
    def __init__(self, **kwargs):
        super(Quota, self).__init__()
        self.fields = []
        for field in objects.Quota.fields:
            # Skip fields we do not expose.
            if not hasattr(self, field):
                continue
            self.fields.append(field)
            setattr(self, field, kwargs.get(field, wtypes.Unset))

    @classmethod
    def convert(cls, quota):
        return Quota(**quota.as_dict())
Ejemplo n.º 21
0
class FilterType(wtypes.UserType):
    """Query filter."""
    name = 'filtertype'
    basetype = wtypes.text

    _supported_fields = wtypes.Enum(wtypes.text, 'parent_uuid', 'root_uuid',
                                    'board', 'availability', 'interface_type',
                                    'instance_uuid', 'limit', 'marker',
                                    'sort_key', 'sort_dir', 'name')

    field = wsme.wsattr(_supported_fields, mandatory=True)
    value = wsme.wsattr(wtypes.text, mandatory=True)

    def __repr__(self):
        # for logging calls
        return '<Query %s %s>' % (self.field, self.value)

    @classmethod
    def sample(cls):
        return cls(field='interface_type', value='pci')

    def as_dict(self):
        d = dict()
        d[getattr(self, 'field')] = getattr(self, 'value')
        return d

    @staticmethod
    def validate(filters):
        for filter in filters:
            if filter.field not in FilterType._supported_fields:
                msg = _("'%s' is an unsupported field for querying.")
                raise wsme.exc.ClientSideError(msg % filter.field)
        return filters
Ejemplo n.º 22
0
class Meter(_Base):
    """One category of measurements.
    """

    name = wtypes.text
    "The unique name for the meter"

    type = wtypes.Enum(str, sample.TYPE_GAUGE, sample.TYPE_CUMULATIVE,
                       sample.TYPE_DELTA)
    "The meter type (see :ref:`measurements`)"

    unit = wtypes.text
    "The unit of measure"

    resource_id = wtypes.text
    "The ID of the :class:`Resource` for which the measurements are taken"

    project_id = wtypes.text
    "The ID of the project or tenant that owns the resource"

    user_id = wtypes.text
    "The ID of the user who last triggered an update to the resource"

    @classmethod
    def sample(cls):
        return cls(
            name='instance',
            type='gauge',
            unit='instance',
            resource_id='bd9431c1-8d69-4ad3-803a-8d4a6b89fd36',
            project_id='35b17138-b364-4e6a-a131-8f3099c5be68',
            user_id='efd87807-12d2-4b38-9c70-5f5c2ac427ff',
        )
Ejemplo n.º 23
0
class PoolPUT(BasePoolType):
    """Defines attributes that are acceptable of a PUT request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool)
    lb_algorithm = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_LB_ALGORITHMS))
    session_persistence = wtypes.wsattr(SessionPersistencePUT)
Ejemplo n.º 24
0
class PoolPOST(base.BaseType):
    """Defines mandatory and optional attributes of a POST request."""
    id = wtypes.wsattr(wtypes.UuidType())
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    enabled = wtypes.wsattr(bool, default=True)
    listener_id = wtypes.wsattr(wtypes.UuidType())
    protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS),
                             mandatory=True)
    lb_algorithm = wtypes.wsattr(wtypes.Enum(
        str, *constants.SUPPORTED_LB_ALGORITHMS),
                                 mandatory=True)
    session_persistence = wtypes.wsattr(SessionPersistencePOST)
    # TODO(johnsom) Remove after deprecation (R series)
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    health_monitor = wtypes.wsattr(health_monitor.HealthMonitorPOST)
    members = wtypes.wsattr([member.MemberPOST])
Ejemplo n.º 25
0
class SessionPersistencePUT(types.BaseType):
    """Defines attributes that are acceptable of a PUT request."""
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_SP_TYPES))
    cookie_name = wtypes.wsattr(wtypes.StringType(max_length=255),
                                default=None)
    persistence_timeout = wtypes.wsattr(wtypes.IntegerType(), default=None)
    persistence_granularity = wtypes.wsattr(types.IPAddressType(),
                                            default=None)
Ejemplo n.º 26
0
def create_enum_type(*values):
    unicode_values = []
    for v in values:
        # Python 2/3 compatible way to convert to unicode
        if hasattr(v, 'decode'):  # Python 2
            v = v.decode('ascii')
        unicode_values.append(v)
    return wtypes.Enum(wtypes.text, *unicode_values)
Ejemplo n.º 27
0
class SessionPersistencePOST(types.BaseType):
    """Defines mandatory and optional attributes of a POST request."""
    type = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_SP_TYPES),
                         mandatory=True)
    cookie_name = wtypes.wsattr(wtypes.StringType(max_length=255),
                                default=None)
    persistence_timeout = wtypes.wsattr(wtypes.IntegerType(), default=None)
    persistence_granularity = wtypes.wsattr(types.IPAddressType(),
                                            default=None)
Ejemplo n.º 28
0
class LoadBalancerPOST(BaseLoadBalancerType):
    """Defines mandatory and optional attributes of a POST request."""

    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    vip_address = wtypes.wsattr(types.IPAddressType())
    vip_port_id = wtypes.wsattr(wtypes.UuidType())
    vip_subnet_id = wtypes.wsattr(wtypes.UuidType())
    vip_network_id = wtypes.wsattr(wtypes.UuidType())
    project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
    listeners = wtypes.wsattr([listener.ListenerSingleCreate], default=[])
    pools = wtypes.wsattr([pool.PoolSingleCreate], default=[])
    # TODO(johnsom) This should be dynamic based on the loaded providers
    #               once providers are implemented.
    provider = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROVIDERS))
    # TODO(johnsom) This should be dynamic based on the loaded flavors
    #               once flavors are implemented.
    flavor = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_FLAVORS))
Ejemplo n.º 29
0
class L7PolicyPUT(base.BaseType):
    """Defines attributes that are acceptable of a PUT request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    enabled = wtypes.wsattr(bool)
    action = wtypes.wsattr(
        wtypes.Enum(str, *constants.SUPPORTED_L7POLICY_ACTIONS))
    redirect_pool_id = wtypes.wsattr(wtypes.StringType(max_length=255))
    redirect_url = wtypes.wsattr(base.URLType())
    position = wtypes.wsattr(wtypes.IntegerType())
Ejemplo n.º 30
0
class L7PolicySingleCreate(BaseL7PolicyType):
    """Defines mandatory and optional attributes of a POST request."""
    name = wtypes.wsattr(wtypes.StringType(max_length=255))
    description = wtypes.wsattr(wtypes.StringType(max_length=255))
    admin_state_up = wtypes.wsattr(bool, default=True)
    action = wtypes.wsattr(wtypes.Enum(str,
                                       *constants.SUPPORTED_L7POLICY_ACTIONS),
                           mandatory=True)
    redirect_pool = wtypes.wsattr(pool.PoolSingleCreate)
    redirect_url = wtypes.wsattr(types.URLType())
    redirect_prefix = wtypes.wsattr(types.URLType())
    position = wtypes.wsattr(wtypes.IntegerType(
        minimum=constants.MIN_POLICY_POSITION,
        maximum=constants.MAX_POLICY_POSITION),
                             default=constants.MAX_POLICY_POSITION)
    rules = wtypes.wsattr([l7rule.L7RuleSingleCreate])
    tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
    redirect_http_code = wtypes.wsattr(
        wtypes.Enum(int, *constants.SUPPORTED_L7POLICY_REDIRECT_HTTP_CODES))