Esempio n. 1
0
def _verify_dict_keys(expected_keys, target_dict, strict=True):
    """Verify expected keys in a dictionary.

    :param expected_keys: A list of keys expected to be present.
    :param target_dict: The dictionary which should be verified.
    :param strict: Specifies whether additional keys are allowed to be present.
    :returns: None if the expected keys are found. Otherwise a human readable
    message indicating why the validation failed.
    """
    if not isinstance(target_dict, dict):
        msg = (_("Invalid input. '%(target_dict)s' must be a dictionary "
                 "with keys: %(expected_keys)s") %
               {'target_dict': target_dict, 'expected_keys': expected_keys})
        LOG.debug(msg)
        return msg

    expected_keys = set(expected_keys)
    provided_keys = set(target_dict.keys())

    predicate = expected_keys.__eq__ if strict else expected_keys.issubset

    if not predicate(provided_keys):
        msg = (_("Validation of dictionary's keys failed. "
                 "Expected keys: %(expected_keys)s "
                 "Provided keys: %(provided_keys)s") %
               {'expected_keys': expected_keys,
                'provided_keys': provided_keys})
        LOG.debug(msg)
        return msg
Esempio n. 2
0
def validate_integer(data, valid_values=None):
    """This function validates if the data is an integer.

    It checks both number or string provided to validate it's an
    integer and returns a message with the error if it's not

    :param data: The string or number to validate as integer
    :param valid_values: values to limit the 'data' to
    :return: Message if not an integer.
    """

    if valid_values is not None:
        msg = validate_values(data=data, valid_values=valid_values)
        if msg:
            return msg

    msg = _("'%s' is not an integer") % data
    try:
        fl_n = float(data)
        int_n = int(data)
    except (ValueError, TypeError, OverflowError):
        LOG.debug(msg)
        return msg

    # Fail test if non equal or boolean
    if fl_n != int_n:
        LOG.debug(msg)
        return msg
    elif isinstance(data, bool):
        msg = _("'%s' is not an integer:boolean") % data
        LOG.debug(msg)
        return msg
Esempio n. 3
0
def _verify_dict_keys(expected_keys, target_dict, strict=True):
    """Allows to verify keys in a dictionary.

    :param expected_keys: A list of keys expected to be present.
    :param target_dict: The dictionary which should be verified.
    :param strict: Specifies whether additional keys are allowed to be present.
    :return: True, if keys in the dictionary correspond to the specification.
    """
    if not isinstance(target_dict, dict):
        msg = (_("Invalid input. '%(target_dict)s' must be a dictionary "
                 "with keys: %(expected_keys)s") %
               {'target_dict': target_dict, 'expected_keys': expected_keys})
        LOG.debug(msg)
        return msg

    expected_keys = set(expected_keys)
    provided_keys = set(target_dict.keys())

    predicate = expected_keys.__eq__ if strict else expected_keys.issubset

    if not predicate(provided_keys):
        msg = (_("Validation of dictionary's keys failed. "
                 "Expected keys: %(expected_keys)s "
                 "Provided keys: %(provided_keys)s") %
               {'expected_keys': expected_keys,
                'provided_keys': provided_keys})
        LOG.debug(msg)
        return msg
Esempio n. 4
0
def validate_fixed_ips(data, valid_values=None):
    if not isinstance(data, list):
        msg = _("Invalid data format for fixed IP: '%s'") % data
        LOG.debug(msg)
        return msg

    ips = []
    for fixed_ip in data:
        if not isinstance(fixed_ip, dict):
            msg = _("Invalid data format for fixed IP: '%s'") % fixed_ip
            LOG.debug(msg)
            return msg
        if 'ip_address' in fixed_ip:
            # Ensure that duplicate entries are not set - just checking IP
            # suffices. Duplicate subnet_id's are legitimate.
            fixed_ip_address = fixed_ip['ip_address']
            if fixed_ip_address in ips:
                msg = _("Duplicate IP address '%s'") % fixed_ip_address
                LOG.debug(msg)
            else:
                msg = validate_ip_address(fixed_ip_address)
            if msg:
                return msg
            ips.append(fixed_ip_address)
        if 'subnet_id' in fixed_ip:
            msg = validate_uuid(fixed_ip['subnet_id'])
            if msg:
                return msg
Esempio n. 5
0
def validate_ip_address(data, valid_values=None):
    msg = None
    try:
        # netaddr.core.ZEROFILL is only applicable to IPv4.
        # it will remove leading zeros from IPv4 address octets.
        ip = netaddr.IPAddress(validate_no_whitespace(data),
                               flags=netaddr.core.ZEROFILL)
        # The followings are quick checks for IPv6 (has ':') and
        # IPv4.  (has 3 periods like 'xx.xx.xx.xx')
        # NOTE(yamamoto): netaddr uses libraries provided by the underlying
        # platform to convert addresses.  For example, inet_aton(3).
        # Some platforms, including NetBSD and OS X, have inet_aton
        # implementation which accepts more varying forms of addresses than
        # we want to accept here.  The following check is to reject such
        # addresses.  For Example:
        #   >>> netaddr.IPAddress('1' * 59)
        #   IPAddress('199.28.113.199')
        #   >>> netaddr.IPAddress(str(int('1' * 59) & 0xffffffff))
        #   IPAddress('199.28.113.199')
        #   >>>
        if ':' not in data and data.count('.') != 3:
            msg = _("'%s' is not a valid IP address") % data
        # A leading '0' in IPv4 address may be interpreted as an octal number,
        # e.g. 011 octal is 9 decimal. Since there is no standard saying
        # whether IP address with leading '0's should be interpreted as octal
        # or decimal, hence we reject leading '0's to avoid ambiguity.
        elif ip.version == 4 and str(ip) != data:
            msg = _("'%(data)s' is not an accepted IP address, "
                    "'%(ip)s' is recommended") % {"data": data, "ip": ip}
    except Exception:
        msg = _("'%s' is not a valid IP address") % data
    if msg:
        LOG.debug(msg)
    return msg
Esempio n. 6
0
def validate_range(data, valid_values=None):
    """Check that integer value is within a range provided.

    Test is inclusive. Allows either limit to be ignored, to allow
    checking ranges where only the lower or upper limit matter.
    It is expected that the limits provided are valid integers or
    the value None.

    :param data: The data to validate.
    :param valid_values: A list of 2 elements where element 0 is the min
    value the int data can have and element 1 is the max.
    :returns: None if the data is a valid int in the given range, otherwise
    a human readable message as to why validation failed.
    """

    min_value = valid_values[0]
    max_value = valid_values[1]
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg
    if min_value is not UNLIMITED and data < min_value:
        msg = _("'%(data)s' is too small - must be at least "
                "'%(limit)d'") % {'data': data, 'limit': min_value}
        LOG.debug(msg)
        return msg
    if max_value is not UNLIMITED and data > max_value:
        msg = _("'%(data)s' is too large - must be no larger than "
                "'%(limit)d'") % {'data': data, 'limit': max_value}
        LOG.debug(msg)
        return msg
Esempio n. 7
0
def validate_range(data, valid_values=None):
    """Check that integer value is within a range provided.

    Test is inclusive. Allows either limit to be ignored, to allow
    checking ranges where only the lower or upper limit matter.
    It is expected that the limits provided are valid integers or
    the value None.
    """

    min_value = valid_values[0]
    max_value = valid_values[1]
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg
    if min_value is not UNLIMITED and data < min_value:
        msg = _("'%(data)s' is too small - must be at least "
                "'%(limit)d'") % {'data': data, 'limit': min_value}
        LOG.debug(msg)
        return msg
    if max_value is not UNLIMITED and data > max_value:
        msg = _("'%(data)s' is too large - must be no larger than "
                "'%(limit)d'") % {'data': data, 'limit': max_value}
        LOG.debug(msg)
        return msg
Esempio n. 8
0
def validate_dict(data, key_specs=None):
    if not isinstance(data, dict):
        msg = _("'%s' is not a dictionary") % data
        LOG.debug(msg)
        return msg
    # Do not perform any further validation, if no constraints are supplied
    if not key_specs:
        return

    # Check whether all required keys are present
    required_keys = [key for key, spec in six.iteritems(key_specs)
                     if spec.get('required')]

    if required_keys:
        msg = _verify_dict_keys(required_keys, data, False)
        if msg:
            return msg

    # Check whether unexpected keys are supplied in data
    unexpected_keys = [key for key in data if key not in key_specs]
    if unexpected_keys:
        msg = _("Unexpected keys supplied: %s") % ', '.join(unexpected_keys)
        LOG.debug(msg)
        return msg

    # Perform validation and conversion of all values
    # according to the specifications.
    for key, key_validator in [(k, v) for k, v in six.iteritems(key_specs)
                               if k in data]:
        msg = _validate_dict_item(key, key_validator, data)
        if msg:
            return msg
Esempio n. 9
0
def get_and_validate_sort_keys(sorts, model):
    """Extract sort keys from sorts and ensure they are valid for the model.

    :param sorts: A list of (key, direction) tuples.
    :param model: A sqlalchemy ORM model class.
    :returns: A list of the extracted sort keys.
    :raises BadRequest: If a sort key attribute references another resource
    and cannot be used in the sort.
    """

    sort_keys = [s[0] for s in sorts]
    for sort_key in sort_keys:
        try:
            sort_key_attr = getattr(model, sort_key)
        except AttributeError:
            # Extension attributes don't support sorting. Because it
            # existed in attr_info, it will be caught here.
            msg = _("'%s' is an invalid attribute for sort key") % sort_key
            raise n_exc.BadRequest(resource=model.__tablename__, msg=msg)
        if isinstance(sort_key_attr.property,
                      properties.RelationshipProperty):
            msg = _("Attribute '%(attr)s' references another resource and "
                    "cannot be used to sort '%(resource)s' resources"
                    ) % {'attr': sort_key, 'resource': model.__tablename__}
            raise n_exc.BadRequest(resource=model.__tablename__, msg=msg)

    return sort_keys
Esempio n. 10
0
def validate_hostroutes(data, valid_values=None):
    """Validate a list of unique host route dicts.

    :param data: The data to validate. To be valid it must be a list like
    structure of host route dicts, each containing 'destination' and 'nexthop'
    key values.
    :param valid_values: Not used!
    :returns: None if data is a valid list of unique host route dicts,
    otherwise a human readable message indicating why validation failed.
    """
    if not isinstance(data, list):
        msg = _("Invalid data format for hostroute: '%s'") % data
        LOG.debug(msg)
        return msg

    expected_keys = ['destination', 'nexthop']
    hostroutes = []
    for hostroute in data:
        msg = _verify_dict_keys(expected_keys, hostroute)
        if msg:
            return msg
        msg = validate_subnet(hostroute['destination'])
        if msg:
            return msg
        msg = validate_ip_address(hostroute['nexthop'])
        if msg:
            return msg
        if hostroute in hostroutes:
            msg = _("Duplicate hostroute '%s'") % hostroute
            LOG.debug(msg)
            return msg
        hostroutes.append(hostroute)
Esempio n. 11
0
def validate_nameservers(data, valid_values=None):
    """Validate a list of unique IP addresses.

    :param data: The data to validate.
    :param valid_values: Not used!
    :returns: None if data is a list of valid IP addresses, otherwise
    a human readable message is returned indicating why validation failed.
    """
    if not hasattr(data, '__iter__'):
        msg = _("Invalid data format for nameserver: '%s'") % data
        LOG.debug(msg)
        return msg

    hosts = []
    for host in data:
        # This must be an IP address only
        msg = validate_ip_address(host)
        if msg:
            msg = _("'%(host)s' is not a valid nameserver. %(msg)s") % {
                'host': host, 'msg': msg}
            LOG.debug(msg)
            return msg
        if host in hosts:
            msg = _("Duplicate nameserver '%s'") % host
            LOG.debug(msg)
            return msg
        hosts.append(host)
Esempio n. 12
0
def validate_string(data, max_len=None):
    if not isinstance(data, six.string_types):
        msg = _("'%s' is not a valid string") % data
        LOG.debug(msg)
        return msg

    if max_len is not None and len(data) > max_len:
        msg = (_("'%(data)s' exceeds maximum length of %(max_len)s") %
               {'data': data, 'max_len': max_len})
        LOG.debug(msg)
        return msg
Esempio n. 13
0
def validate_non_negative(data, valid_values=None):
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg

    if data < 0:
        msg = _("'%s' should be non-negative") % data
        LOG.debug(msg)
        return msg
Esempio n. 14
0
def _validate_list_of_items(item_validator, data, *args, **kwargs):
    if not isinstance(data, list):
        msg = _("'%s' is not a list") % data
        return msg

    if len(set(data)) != len(data):
        msg = _("Duplicate items in the list: '%s'") % ', '.join(data)
        return msg

    for item in data:
        msg = item_validator(item, *args, **kwargs)
        if msg:
            return msg
Esempio n. 15
0
def validate_subnet(data, valid_values=None):
    msg = None
    try:
        net = netaddr.IPNetwork(validate_no_whitespace(data))
        if '/' not in data or (net.version == 4 and str(net) != data):
            msg = _("'%(data)s' isn't a recognized IP subnet cidr,"
                    " '%(cidr)s' is recommended") % {"data": data,
                                                     "cidr": net.cidr}
        else:
            return
    except Exception:
        msg = _("'%s' is not a valid IP subnet") % data
    if msg:
        LOG.debug(msg)
    return msg
Esempio n. 16
0
def validate_no_whitespace(data):
    """Validates that input has no whitespace."""
    if re.search(r'\s', data):
        msg = _("'%s' contains whitespace") % data
        LOG.debug(msg)
        raise n_exc.InvalidInput(error_message=msg)
    return data
Esempio n. 17
0
def validate_ip_pools(data, valid_values=None):
    """Validate that start and end IP addresses are present.

    In addition to this the IP addresses will also be validated.

    :param data: The data to validate. Must be a list-like structure of
    IP pool dicts that each have a 'start' and 'end' key value.
    :param valid_values: Not used!
    :returns: None if data is a valid list of IP pools, otherwise a message
    indicating why the data is invalid.
    """
    if not isinstance(data, list):
        msg = _("Invalid data format for IP pool: '%s'") % data
        LOG.debug(msg)
        return msg

    expected_keys = ['start', 'end']
    for ip_pool in data:
        msg = _verify_dict_keys(expected_keys, ip_pool)
        if msg:
            return msg
        for k in expected_keys:
            msg = validate_ip_address(ip_pool[k])
            if msg:
                return msg
Esempio n. 18
0
def convert_to_positive_float_or_none(val):
    """Converts a value to a python float if the value is positive.

    :param val: The value to convert to a positive python float.
    :returns: The value as a python float. If the val is None, None is
    returned.
    :raises ValueError, InvalidInput: A ValueError is raised if the 'val'
    is a float, but is negative. InvalidInput is raised if 'val' can't be
    converted to a python float.
    """
    # NOTE(salv-orlando): This conversion function is currently used by
    # a vendor specific extension only at the moment  It is used for
    # port's RXTX factor in neutron.plugins.vmware.extensions.qos.
    # It is deemed however generic enough to be in this module as it
    # might be used in future for other API attributes.
    if val is None:
        return
    try:
        val = float(val)
        if val < 0:
            raise ValueError()
    except (ValueError, TypeError):
        msg = _("'%s' must be a non negative decimal.") % val
        raise n_exc.InvalidInput(error_message=msg)
    return val
Esempio n. 19
0
def validate_boolean(data, valid_values=None):
    try:
        converters.convert_to_boolean(data)
    except n_exc.InvalidInput:
        msg = _("'%s' is not a valid boolean value") % data
        LOG.debug(msg)
        return msg
Esempio n. 20
0
def populate_project_info(attributes):
    """Ensure that both project_id and tenant_id attributes are present.

    If either project_id or tenant_id is present in attributes then ensure
    that both are present.

    If neither are present then attributes is not updated.

    :param attributes: a dictionary of resource/API attributes
    :type attributes: dict

    :return: the updated attributes dictionary
    :rtype: dict

    """
    if "tenant_id" in attributes and "project_id" not in attributes:
        attributes["project_id"] = attributes["tenant_id"]
    elif "project_id" in attributes and "tenant_id" not in attributes:
        # Backward compatibility for code still using tenant_id
        attributes["tenant_id"] = attributes["project_id"]

    if attributes.get("project_id") != attributes.get("tenant_id"):
        msg = _("'project_id' and 'tenant_id' do not match")
        raise exc.HTTPBadRequest(msg)

    return attributes
Esempio n. 21
0
 def test_port_bound(self):
     self._check_nexc(
         ne.PortBound,
         _("Unable to complete operation on port bigmac, "
           "port is already bound, port type: ketchup, "
           "old_mac onions, new_mac salt."),
         port_id='bigmac', vif_type='ketchup', old_mac='onions',
         new_mac='salt')
Esempio n. 22
0
 def test_bad_request_misused(self):
     try:
         self._check_nexc(
             ne.BadRequest,
             _('Bad A request: B.'),
             resource='A', msg='B')
     except AttributeError:
         pass
Esempio n. 23
0
def validate_not_empty_string(data, max_len=None):
    msg = validate_string(data, max_len=max_len)
    if msg:
        return msg
    if not data.strip():
        msg = _("'%s' Blank strings are not permitted") % data
        LOG.debug(msg)
        return msg
Esempio n. 24
0
def validate_values(data, valid_values=None, valid_values_display=None):
    """Validate that the provided 'data' is within 'valid_values'.

    :param data: The data to check within valid_values.
    :param valid_values: A collection of values that 'data' must be in to be
        valid. The collection can be any type that supports the 'in' operation.
    :param valid_values_display: A string to display that describes the valid
        values. This string is only displayed when an invalid value is
        encountered.
        If no string is provided, the string "valid_values" will be used.
    :returns: The message to return if data not in valid_values.
    :raises: TypeError if the values for 'data' or 'valid_values' are not
        compatible for comparison or doesn't have __contains__.
        If TypeError is raised this is considered a programming error and the
        inputs (data) and (valid_values) must be checked so this is never
        raised on validation.
    """

    # If valid_values is not specified we don't check against it.
    if valid_values is None:
        return

    # Check if we can use 'in' to find membership of data in valid_values
    contains = getattr(valid_values, "__contains__", None)
    if callable(contains):
        try:
            if data not in valid_values:
                valid_values_display = valid_values_display or 'valid_values'
                msg = (_("%(data)s is not in %(valid_values)s") %
                       {'data': data, 'valid_values': valid_values_display})
                LOG.debug(msg)
                return msg
        except TypeError:
                # This is a programming error
                msg = (_("'data' of type '%(typedata)s' and 'valid_values'"
                         "of type '%(typevalues)s' are not "
                         "compatible for comparison") %
                       {'typedata': type(data),
                        'typevalues': type(valid_values)})
                raise TypeError(msg)
    else:
        # This is a programming error
        msg = (_("'valid_values' does not support membership operations"))
        raise TypeError(msg)
Esempio n. 25
0
def validate_non_negative(data, valid_values=None):
    """Validate data is a positive int.

    :param data: The data to validate
    :param valid_values: Not used!
    :returns: None if data is an int and is positive, otherwise a human
    readable message as to why data is invalid.
    """
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg

    if data < 0:
        msg = _("'%s' should be non-negative") % data
        LOG.debug(msg)
        return msg
Esempio n. 26
0
def validate_string(data, max_len=None):
    """Validate data is a string object optionally capping it length.

    :param data: The data to validate.
    :param max_len: An optional cap on the length of the string.
    :returns: None if the data is a valid string type and (optionally) within
    the given max_len. Otherwise a human readable message indicating why
    the data is invalid.
    """
    if not isinstance(data, six.string_types):
        msg = _("'%s' is not a valid string") % data
        LOG.debug(msg)
        return msg

    if max_len is not None and len(data) > max_len:
        msg = (_("'%(data)s' exceeds maximum length of %(max_len)s") %
               {'data': data, 'max_len': max_len})
        LOG.debug(msg)
        return msg
Esempio n. 27
0
def validate_regex(data, valid_values=None):
    try:
        if re.match(valid_values, data):
            return
    except TypeError:
        pass

    msg = _("'%s' is not a valid input") % data
    LOG.debug(msg)
    return msg
def convert_kvp_str_to_list(data):
    """Convert a value of the form 'key=value' to ['key', 'value'].

    :raises: n_exc.InvalidInput if any of the strings are malformed
                                (e.g. do not contain a key).
    """
    kvp = [x.strip() for x in data.split('=', 1)]
    if len(kvp) == 2 and kvp[0]:
        return kvp
    msg = _("'%s' is not of the form <key>=[value]") % data
    raise n_exc.InvalidInput(error_message=msg)
Esempio n. 29
0
def validate_nameservers(data, valid_values=None):
    if not hasattr(data, '__iter__'):
        msg = _("Invalid data format for nameserver: '%s'") % data
        LOG.debug(msg)
        return msg

    hosts = []
    for host in data:
        # This must be an IP address only
        msg = validate_ip_address(host)
        if msg:
            msg = _("'%(host)s' is not a valid nameserver. %(msg)s") % {
                'host': host, 'msg': msg}
            LOG.debug(msg)
            return msg
        if host in hosts:
            msg = _("Duplicate nameserver '%s'") % host
            LOG.debug(msg)
            return msg
        hosts.append(host)
Esempio n. 30
0
def validate_dict(data, key_specs=None):
    """Validate data is a dict optionally containing a specific set of keys.

    :param data: The data to validate.
    :param key_specs: The optional list of keys that must be contained in
    data.
    :returns: None if data is a dict and (optionally) contains only key_specs.
    Otherwise a human readable message is returned indicating why data is not
    valid.
    """
    if not isinstance(data, dict):
        msg = _("'%s' is not a dictionary") % data
        LOG.debug(msg)
        return msg
    # Do not perform any further validation, if no constraints are supplied
    if not key_specs:
        return

    # Check whether all required keys are present
    required_keys = [key for key, spec in key_specs.items()
                     if spec.get('required')]

    if required_keys:
        msg = _verify_dict_keys(required_keys, data, False)
        if msg:
            return msg

    # Check whether unexpected keys are supplied in data
    unexpected_keys = [key for key in data if key not in key_specs]
    if unexpected_keys:
        msg = _("Unexpected keys supplied: %s") % ', '.join(unexpected_keys)
        LOG.debug(msg)
        return msg

    # Perform validation and conversion of all values
    # according to the specifications.
    for key, key_validator in [(k, v) for k, v in key_specs.items()
                               if k in data]:
        msg = _validate_dict_item(key, key_validator, data)
        if msg:
            return msg
Esempio n. 31
0
 def test_admin_required(self):
     self._check_nexc(ne.AdminRequired,
                      _("User does not have admin privileges: hoser."),
                      reason="hoser")
Esempio n. 32
0
 def test_network_not_found(self):
     self._check_nexc(ne.NetworkNotFound,
                      _("Network spam could not be found."),
                      net_id="spam")
Esempio n. 33
0
 def test_preexisting_device_failure(self):
     self._check_nexc(ne.PreexistingDeviceFailure,
                      _("Creation failed. hal9000 already exists."),
                      dev_name='hal9000')
Esempio n. 34
0
 def test_external_ip_address_exhausted(self):
     self._check_nexc(
         ne.ExternalIpAddressExhausted,
         _("Unable to find any IP address on external network darpanet."),
         net_id='darpanet')
Esempio n. 35
0
 def test_network_tunnel_range_error(self):
     self._check_nexc(ne.NetworkTunnelRangeError,
                      _("Invalid network tunnel range: 'rats' - present."),
                      tunnel_range='rats',
                      error='present')
Esempio n. 36
0
 def test_policy_init_error(self):
     self._check_nexc(
         ne.PolicyInitError,
         _("Failed to initialize policy policy because reason."),
         policy='policy',
         reason='reason')
Esempio n. 37
0
class DNSDomainNotFound(exceptions.NotFound):
    message = _("Domain %(dns_domain)s not found in the external DNS service")
Esempio n. 38
0
def _raise_invalid_tag(vlan_str, vlan_range):
    """Raise an exception for invalid tag."""
    raise exceptions.NetworkVlanRangeError(
        vlan_range=vlan_range,
        error=_("%s is not a valid VLAN tag") % vlan_str)
Esempio n. 39
0
 def __getattr__(self, name):
     """Allow attribute access for all keys in the dict."""
     if name in self:
         return self[name]
     raise AttributeError(_("Unknown attribute '%s'.") % name)
Esempio n. 40
0
 def test_device_not_found_error(self):
     self._check_nexc(ne.DeviceNotFoundError,
                      _("Device 'device' does not exist."),
                      device_name="device")
Esempio n. 41
0
 def test_port_not_found_on_network(self):
     self._check_nexc(ne.PortNotFoundOnNetwork,
                      _("Port serial could not be found on network USB."),
                      port_id="serial",
                      net_id="USB")
Esempio n. 42
0
 def test_port_not_found(self):
     self._check_nexc(ne.PortNotFound,
                      _("Port harbor could not be found."),
                      port_id="harbor")
Esempio n. 43
0
 def test_not_authorized(self):
     self._check_nexc(ne.NotAuthorized, _("Not authorized."))
Esempio n. 44
0
 def test_base(self):
     self._check_nexc(ne.NeutronException,
                      _('An unknown exception occurred.'))
Esempio n. 45
0
 def test_policy_check_error(self):
     self._check_nexc(ne.PolicyCheckError,
                      _("Failed to check policy policy because reason."),
                      policy='policy',
                      reason='reason')
Esempio n. 46
0
class DuplicateRecordSet(exceptions.Conflict):
    message = _("Name %(dns_name)s is duplicated in the external DNS service")
Esempio n. 47
0
 def test_network_tunnel_range_error_tuple(self):
     self._check_nexc(ne.NetworkTunnelRangeError,
                      _("Invalid network tunnel range: '3:4' - present."),
                      tunnel_range=(3, 4),
                      error='present')
Esempio n. 48
0
class ExternalDNSDriverNotFound(exceptions.NotFound):
    message = _("External DNS driver %(driver)s could not be found.")
Esempio n. 49
0
 def test_invalid_configuration_option(self):
     self._check_nexc(
         ne.InvalidConfigurationOption,
         _("An invalid value was provided for which muppet: big bird."),
         opt_name='which muppet',
         opt_value='big bird')
Esempio n. 50
0
class InvalidPTRZoneConfiguration(exceptions.Conflict):
    message = _("Value of %(parameter)s has to be multiple of %(number)s, "
                "with maximum value of %(maximum)s and minimum value of "
                "%(minimum)s")
Esempio n. 51
0
 def test_invalid_content_type(self):
     self._check_nexc(ne.InvalidContentType,
                      _("Invalid content type p**n."),
                      content_type='p**n')
Esempio n. 52
0
 def test_bad_request(self):
     self._check_nexc(ne.BadRequest,
                      _('Bad A request: B.'),
                      resource='A',
                      msg='B')
Esempio n. 53
0
 def test_over_quota(self):
     self._check_nexc(ne.OverQuota,
                      _("Quota exceeded for resources: tube socks."),
                      overs='tube socks')
Esempio n. 54
0
 def test_ip_address_generation_failure(self):
     self._check_nexc(ne.IpAddressGenerationFailure,
                      _("No more IP addresses available on network nuke."),
                      net_id='nuke')
Esempio n. 55
0
 def test_conflict(self):
     self._check_nexc(ne.Conflict, _('An unknown exception occurred.'))
Esempio n. 56
0
 def test_object_not_found(self):
     self._check_nexc(ne.ObjectNotFound,
                      _("Object fallout tato not found."),
                      id="fallout tato")
Esempio n. 57
0
 def test_invalid_input(self):
     self._check_nexc(ne.InvalidInput,
                      _("Invalid input for operation: warp core breach."),
                      error_message='warp core breach')
Esempio n. 58
0
 def test_not_found(self):
     self._check_nexc(ne.NotFound, _('An unknown exception occurred.'))
Esempio n. 59
0
 def test_subnet_not_found(self):
     self._check_nexc(ne.SubnetNotFound,
                      _("Subnet root could not be found."),
                      subnet_id="root")
Esempio n. 60
0
 def test_service_unavailable(self):
     self._check_nexc(ne.ServiceUnavailable,
                      _("The service is unavailable."))