当前位置: 首页>>代码示例>>Python>>正文


Python uuidutils.is_uuid_like函数代码示例

本文整理汇总了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
开发者ID:Akanksha08,项目名称:neutron,代码行数:28,代码来源:db.py

示例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
开发者ID:Akanksha08,项目名称:neutron,代码行数:33,代码来源:n1kv_ext_driver.py

示例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)
开发者ID:aaronknister,项目名称:neutron,代码行数:31,代码来源:test_notifiers_nova.py

示例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'))
开发者ID:armando-migliaccio,项目名称:neutron,代码行数:25,代码来源:dhcp_agent.py

示例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)))
开发者ID:ArifovicH,项目名称:neutron,代码行数:7,代码来源:test_cisco_apic_manager.py

示例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
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:8,代码来源:securitygroup.py

示例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
开发者ID:Akanksha08,项目名称:neutron,代码行数:8,代码来源:nova.py

示例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)
        ]
开发者ID:Mierdin,项目名称:neutron,代码行数:9,代码来源:dhcp.py

示例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())
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:9,代码来源:test_vrouter_neutron_plugin.py

示例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 []
开发者ID:SmartInfrastructures,项目名称:neutron,代码行数:10,代码来源:dhcp.py

示例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
开发者ID:nkapotoxin,项目名称:fs_spc111t_plus_hc,代码行数:11,代码来源:qos.py

示例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)
        ]
开发者ID:CampHarmony,项目名称:neutron,代码行数:14,代码来源:dhcp.py

示例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
开发者ID:weeloongarista,项目名称:neutron,代码行数:14,代码来源:rpc.py

示例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
开发者ID:Vikash082,项目名称:group-based-policy,代码行数:16,代码来源:group_policy.py

示例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
开发者ID:CiscoSystems,项目名称:vespa,代码行数:5,代码来源:attributes.py


注:本文中的neutron.openstack.common.uuidutils.is_uuid_like函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。