本文整理汇总了Python中neutron.openstack.common.uuidutils.is_uuid_like函数的典型用法代码示例。如果您正苦于以下问题:Python is_uuid_like函数的具体用法?Python is_uuid_like怎么用?Python is_uuid_like使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_uuid_like函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sg_ids_grouped_by_port
def get_sg_ids_grouped_by_port(port_ids):
sg_ids_grouped_by_port = {}
session = db_api.get_session()
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
with session.begin(subtransactions=True):
# partial UUIDs must be individually matched with startswith.
# full UUIDs may be matched directly in an IN statement
partial_uuids = set(port_id for port_id in port_ids
if not uuidutils.is_uuid_like(port_id))
full_uuids = set(port_ids) - partial_uuids
or_criteria = [models_v2.Port.id.startswith(port_id)
for port_id in partial_uuids]
if full_uuids:
or_criteria.append(models_v2.Port.id.in_(full_uuids))
query = session.query(models_v2.Port,
sg_db.SecurityGroupPortBinding.security_group_id)
query = query.outerjoin(sg_db.SecurityGroupPortBinding,
models_v2.Port.id == sg_binding_port)
query = query.filter(or_(*or_criteria))
for port, sg_id in query:
if port not in sg_ids_grouped_by_port:
sg_ids_grouped_by_port[port] = []
if sg_id:
sg_ids_grouped_by_port[port].append(sg_id)
return sg_ids_grouped_by_port
示例2: process_create_port
def process_create_port(self, context, data, result):
"""Implementation of abstract method from ExtensionDriver class."""
port_id = result.get('id')
policy_profile_attr = data.get(constants.N1KV_PROFILE)
if not attributes.is_attr_set(policy_profile_attr):
policy_profile_attr = (cfg.CONF.ml2_cisco_n1kv.
default_policy_profile)
with context.session.begin(subtransactions=True):
try:
n1kv_db.get_policy_binding(port_id, context.session)
except n1kv_exc.PortBindingNotFound:
if not uuidutils.is_uuid_like(policy_profile_attr):
policy_profile = n1kv_db.get_policy_profile_by_name(
policy_profile_attr,
context.session)
if policy_profile:
policy_profile_attr = policy_profile.id
else:
LOG.error(_LE("Policy Profile %(profile)s does "
"not exist."),
{"profile": policy_profile_attr})
raise ml2_exc.MechanismDriverError()
elif not (n1kv_db.get_policy_profile_by_uuid(
context.session,
policy_profile_attr)):
LOG.error(_LE("Policy Profile %(profile)s does not "
"exist."),
{"profile": policy_profile_attr})
raise ml2_exc.MechanismDriverError()
n1kv_db.add_policy_binding(port_id,
policy_profile_attr,
context.session)
result[constants.N1KV_PROFILE] = policy_profile_attr
示例3: _record_port_status_changed_helper
def _record_port_status_changed_helper(self, current_port_status,
previous_port_status, port):
if not (port.device_id and port.id and port.device_owner and
port.device_owner.startswith('compute:') and
uuidutils.is_uuid_like(port.device_id)):
return
if (previous_port_status == constants.PORT_STATUS_ACTIVE and
current_port_status == constants.PORT_STATUS_DOWN):
event_name = nova.VIF_UNPLUGGED
elif (previous_port_status in [sql_attr.NO_VALUE,
constants.PORT_STATUS_DOWN,
constants.PORT_STATUS_BUILD]
and current_port_status in [constants.PORT_STATUS_ACTIVE,
constants.PORT_STATUS_ERROR]):
event_name = nova.VIF_PLUGGED
else:
return
status = nova.NEUTRON_NOVA_EVENT_STATUS_MAP.get(current_port_status)
self.nova_notifier.record_port_status_changed(port,
current_port_status,
previous_port_status,
None)
event = {'server_uuid': port.device_id, 'status': status,
'name': event_name, 'tag': 'port-uuid'}
self.assertEqual(event, port._notify_event)
示例4: _handler
def _handler(self, client_sock, client_addr):
"""Handle incoming lease relay stream connection.
This method will only read the first 1024 bytes and then close the
connection. The limit exists to limit the impact of misbehaving
clients.
"""
try:
msg = client_sock.recv(1024)
data = jsonutils.loads(msg)
client_sock.close()
network_id = data['network_id']
if not uuidutils.is_uuid_like(network_id):
raise ValueError(_("Network ID %s is not a valid UUID") %
network_id)
ip_address = str(netaddr.IPAddress(data['ip_address']))
lease_remaining = int(data['lease_remaining'])
self.callback(network_id, ip_address, lease_remaining)
except ValueError as e:
LOG.warn(_('Unable to parse lease relay msg to dict.'))
LOG.warn(_('Exception value: %s'), e)
LOG.warn(_('Message representation: %s'), repr(msg))
except Exception as e:
LOG.exception(_('Unable update lease. Exception'))
示例5: test_create_tenant_filter
def test_create_tenant_filter(self):
tenant = mocked.APIC_TENANT
self.mock_responses_for_create('vzFilter')
self.mock_responses_for_create('vzEntry')
filter_id = self.mgr.create_tenant_filter(tenant)
self.assert_responses_drained()
self.assertTrue(uuidutils.is_uuid_like(str(filter_id)))
示例6: convert_to_uuid_list_or_none
def convert_to_uuid_list_or_none(value_list):
if value_list is None:
return
for sg_id in value_list:
if not uuidutils.is_uuid_like(sg_id):
msg = _("'%s' is not an integer or uuid") % sg_id
raise qexception.InvalidInput(error_message=msg)
return value_list
示例7: _is_compute_port
def _is_compute_port(self, port):
try:
if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
and port['device_owner'].startswith('compute:')):
return True
except (KeyError, AttributeError):
pass
return False
示例8: existing_dhcp_networks
def existing_dhcp_networks(cls, conf, root_helper):
"""Return a list of existing networks ids that we have configs for."""
confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
return [
c for c in os.listdir(confs_dir)
if uuidutils.is_uuid_like(c)
]
示例9: test_get_router
def test_get_router(self):
router_data = {
'router': {'name': 'test_router1', 'admin_state_up': True}}
router = self.plugin.create_router(self.context, router_data)
router = self.plugin.get_router(self.context, router['id'])
self.assertTrue(uuidutils.is_uuid_like(router.get('id')))
self.assertRaises(l3.RouterNotFound, self.plugin.get_router,
self.context, uuidutils.generate_uuid())
示例10: existing_dhcp_networks
def existing_dhcp_networks(cls, conf):
"""Return a list of existing networks ids that we have configs for."""
confs_dir = cls.get_confs_dir(conf)
try:
return [
c for c in os.listdir(confs_dir)
if uuidutils.is_uuid_like(c)
]
except OSError:
return []
示例11: convert_to_uuid_or_none
def convert_to_uuid_or_none(value):
if value is None:
return
if value == "":
return
if not uuidutils.is_uuid_like(value):
msg = _("'%s' is not an integer or uuid") % value
raise qexception.InvalidInput(error_message=msg)
return value
示例12: existing_dhcp_networks
def existing_dhcp_networks(cls, conf, root_helper):
"""Return a list of existing networks ids that we have configs for."""
confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
class FakeNetwork:
def __init__(self, net_id):
self.id = net_id
return [
c for c in os.listdir(confs_dir)
if (uuidutils.is_uuid_like(c) and
cls(conf, FakeNetwork(c), root_helper).active)
]
示例13: _device_to_port_id
def _device_to_port_id(cls, device):
# REVISIT(rkukura): Consider calling into MechanismDrivers to
# process device names, or having MechanismDrivers supply list
# of device prefixes to strip.
if device.startswith(TAP_DEVICE_PREFIX):
return device[TAP_DEVICE_PREFIX_LENGTH:]
else:
# REVISIT(irenab): Consider calling into bound MD to
# handle the get_device_details RPC, then remove the 'else' clause
if not uuidutils.is_uuid_like(device):
port = db.get_port_from_device_mac(device)
if port:
return port.id
return device
示例14: _validate_external_dict
def _validate_external_dict(data, key_specs=None):
if data is None:
return
if not isinstance(data, dict):
msg = _("'%s' is not a dictionary") % data
LOG.debug(msg)
return msg
for d in data:
if not uuidutils.is_uuid_like(d):
msg = _("'%s' is not a valid UUID") % d
LOG.debug(msg)
return msg
if not isinstance(data[d], list):
msg = _("'%s' is not a list") % data[d]
LOG.debug(msg)
return msg
示例15: _validate_uuid
def _validate_uuid(data, valid_values=None):
if not uuidutils.is_uuid_like(data):
msg = _("'%s' is not a valid UUID") % data
LOG.debug(msg)
return msg