• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python uuidutils.is_uuid_like函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.openstack.common.uuidutils.is_uuid_like函数的典型用法代码示例。如果您正苦于以下问题:Python is_uuid_like函数的具体用法?Python is_uuid_like怎么用?Python is_uuid_like使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_uuid_like函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_create_router

 def test_create_router(self):
     router_data = {
         'router': {'name': 'test_router1', 'admin_state_up': True}}
     result = self.plugin.create_router(self.context, router_data)
     self.assertTrue(uuidutils.is_uuid_like(result.get('id')))
     self.driver.create_router.assert_called_once_with(mock.ANY)
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:6,代码来源:test_vrouter_neutron_plugin.py


示例17: test_l3_create_router

 def test_l3_create_router(self):
     router = self.interceptor.create_router(self.context, {'router': {}})
     self.assertTrue(uuidutils.is_uuid_like(router.get('id')))
     self.l3.create_router.assert_called_with(self.context,
                                              {'router': {'metadata': {}}})
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:5,代码来源:test_interceptor.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.register_config函数代码示例发布时间:2022-05-27
下一篇:
Python uuidutils.generate_uuid函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap