def _validate_service_context_list(data, valid_values=None): if not isinstance(data, list): msg = _("invalid data format for service context list: '%s'") % data LOG.debug(msg) return msg key_specs = { 'network_id': { 'type:uuid': None }, 'subnet_id': { 'type:uuid': None }, 'port_id': { 'type:uuid': None }, 'router_id': { 'type:uuid': None }, 'role': { 'type:string': None }, 'index': { 'type:non_negative': None, 'convert_to': attr.convert_to_int }, } for sc_entry in data: msg = attr._validate_dict_or_empty(sc_entry, key_specs=key_specs) if msg: LOG.debug(msg) return msg
def test_validate_dict_or_empty(self): dictionary, constraints = self._construct_dict_and_constraints() # Check whether an empty dictionary is valid. msg = attributes._validate_dict_or_empty({}, constraints) self.assertIsNone(msg, 'Validation of a None dictionary failed.') # Check validation of a regular dictionary. msg = attributes._validate_dict_or_none(dictionary, constraints) self.assertIsNone(msg, 'Validation of a valid dictionary failed.') self.assertIsNone(msg, 'Validation of a valid dictionary failed.')
def _validate_service_context_list(data, valid_values=None): if not isinstance(data, list): msg = _("invalid data format for service context list: '%s'") % data LOG.debug(msg) return msg key_specs = { 'network_id': {'type:uuid': None}, 'subnet_id': {'type:uuid': None}, 'port_id': {'type:uuid': None}, 'router_id': {'type:uuid': None}, 'role': {'type:string': None}, 'index': {'type:non_negative': None, 'convert_to': attr.convert_to_int}, } for sc_entry in data: msg = attr._validate_dict_or_empty(sc_entry, key_specs=key_specs) if msg: LOG.debug(msg) return msg