def test_validate_uuid(self): invalid_uuids = [ None, 123, '123', 't5069610-744b-42a7-8bd8-ceac1a229cd4', 'e5069610-744bb-42a7-8bd8-ceac1a229cd4' ] for uuid in invalid_uuids: msg = attributes._validate_uuid(uuid) error = "'%s' is not a valid UUID" % uuid self.assertEqual(error, msg) msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000') self.assertIsNone(msg)
def test_validate_uuid(self): invalid_uuids = [None, 123, '123', 't5069610-744b-42a7-8bd8-ceac1a229cd4', 'e5069610-744bb-42a7-8bd8-ceac1a229cd4'] for uuid in invalid_uuids: msg = attributes._validate_uuid(uuid) error = "'%s' is not a valid UUID" % uuid self.assertEqual(error, msg) msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000') self.assertIsNone(msg)
def _validate_subnets(self, context, subnet_ids): """Ensure UUIDs OK and subnets exist.""" for subnet_id in subnet_ids: msg = attributes._validate_uuid(subnet_id) if msg: raise vpnaas.InvalidEndpointInEndpointGroup( group_type=constants.SUBNET_ENDPOINT, endpoint=subnet_id, why=_('Invalid UUID')) try: self.core_plugin.get_subnet(context, subnet_id) except nexception.SubnetNotFound: raise vpnaas.NonExistingSubnetInEndpointGroup( subnet=subnet_id)
def _validate_subnets(self, context, subnet_ids): """Ensure UUIDs OK and subnets exist.""" for subnet_id in subnet_ids: msg = attributes._validate_uuid(subnet_id) if msg: raise vpnaas.InvalidEndpointInEndpointGroup( group_type=constants.SUBNET_ENDPOINT, endpoint=subnet_id, why=_('Invalid UUID')) try: self.core_plugin.get_subnet(context, subnet_id) except nexception.SubnetNotFound: raise vpnaas.NonExistingSubnetInEndpointGroup(subnet=subnet_id)
def _validate_port_dict(values): if not isinstance(values, dict): msg = _("%s is not a valid dictionary") % values LOG.debug(msg) return msg port_id = values.get('port_id') fixed_ip = values.get('fixed_ip_address') msg = attr._validate_uuid(port_id) if msg: return msg if fixed_ip is None: return msg = attr._validate_ip_address(fixed_ip) if msg: return msg
def test_validate_uuid(self): msg = attributes._validate_uuid('garbage') self.assertEqual("'garbage' is not a valid UUID", msg) msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000') self.assertIsNone(msg)
def test_validate_uuid(self): msg = attributes._validate_uuid('garbage') self.assertEqual(msg, "'garbage' is not a valid UUID") msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000') self.assertIsNone(msg)
def test_validate_uuid(self): msg = attributes._validate_uuid("garbage") self.assertEqual(msg, "'garbage' is not a valid UUID") msg = attributes._validate_uuid("00000000-ffff-ffff-ffff-000000000000") self.assertIsNone(msg)