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

Python utils.get_rand_name函数代码示例

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

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



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

示例1: test_db_find_column_type_list

    def test_db_find_column_type_list(self):
        """Fixate output for vsctl/native ovsdb_interface.

        Makes sure that db_find search queries give the same result for both
        implementations.
        """
        bridge_name = utils.get_rand_name(prefix=net_helpers.BR_PREFIX)
        self.addCleanup(self.ovs.delete_bridge, bridge_name)
        br = self.ovs.add_bridge(bridge_name)
        port_name = utils.get_rand_name(prefix=net_helpers.PORT_PREFIX)
        br.add_port(port_name)
        self.ovs.set_db_attribute('Port', port_name, 'tag', 42)

        # wrap list/find in transaction so we get a single isolated snapshot
        with self.ovs.ovsdb.transaction(check_error=True) as txn:
            tags = txn.add(self.ovs.ovsdb.db_list('Port', columns=['tag']))
            len_0_list = txn.add(self.ovs.ovsdb.db_find(
                    'Port', ('tag', '!=', []), columns=['tag']))
            single_value = txn.add(self.ovs.ovsdb.db_find(
                    'Port', ('tag', '=', 42), columns=['tag']))

        # Make sure that there is data to query.
        # It should be, but let's be a little paranoid here as otherwise
        # the test has no sense
        tags_present = [t for t in tags.result if t['tag'] != []]
        self.assertTrue(tags_present)
        tags_42 = [t for t in tags_present if t['tag'] == 42]
        self.assertEqual(tags_42, single_value.result)
        self.assertItemsEqual(len_0_list.result, tags_present)
开发者ID:eayunstack,项目名称:neutron,代码行数:29,代码来源:test_ovs_lib.py


示例2: generate_device_details

 def generate_device_details(self, name=None, ip_cidrs=None,
                             mac_address=None, namespace=None):
     return Device(name or utils.get_rand_name(),
                   ip_cidrs or ["%s/24" % TEST_IP],
                   mac_address or
                   net.get_random_mac('fa:16:3e:00:00:00'.split(':')),
                   namespace or utils.get_rand_name())
开发者ID:eayunstack,项目名称:neutron,代码行数:7,代码来源:test_ip_lib.py


示例3: create_ovs_vif_port

 def create_ovs_vif_port(self, iface_id=None, mac=None,
                         iface_field='iface-id'):
     if iface_id is None:
         iface_id = utils.get_rand_name()
     if mac is None:
         mac = utils.get_rand_name()
     attrs = ('external_ids', {iface_field: iface_id, 'attached-mac': mac})
     port_name, ofport = self.create_ovs_port(attrs)
     return ovs_lib.VifPort(port_name, ofport, iface_id, mac, self.br)
开发者ID:eayunstack,项目名称:neutron,代码行数:9,代码来源:test_ovs_lib.py


示例4: test_macvtap_exists

    def test_macvtap_exists(self):
        namespace = self.useFixture(net_helpers.NamespaceFixture())
        src_dev_name = utils.get_rand_name()
        src_dev = namespace.ip_wrapper.add_dummy(src_dev_name)
        self.addCleanup(self._safe_delete_device, src_dev)

        dev_name = utils.get_rand_name()
        device = namespace.ip_wrapper.add_macvtap(dev_name, src_dev_name)
        self.addCleanup(self._safe_delete_device, device)

        self._check_for_device_name(namespace.ip_wrapper, dev_name, True)
        device.link.delete()
        self._check_for_device_name(namespace.ip_wrapper, dev_name, False)
开发者ID:igordcard,项目名称:neutron,代码行数:13,代码来源:test_ip_lib.py


示例5: _setUp

    def _setUp(self):
        self.user = common_utils.get_rand_name(prefix='user')
        self.password = common_utils.get_rand_name(prefix='pass')
        self.vhost = common_utils.get_rand_name(prefix='vhost')

        self._execute('add_user', self.user, self.password)
        self.addCleanup(self._execute, 'delete_user', self.user)

        self._execute('add_vhost', self.vhost)
        self.addCleanup(self._execute, 'delete_vhost', self.vhost)

        self._execute('set_permissions', '-p', self.vhost, self.user,
                      '.*', '.*', '.*')
开发者ID:igordcard,项目名称:neutron,代码行数:13,代码来源:process.py


示例6: create_resource

def create_resource(prefix, creation_func, *args, **kwargs):
    """Create a new resource that does not already exist.

    If prefix isn't 'max_length' in size, a random suffix is concatenated to
    ensure it is random. Otherwise, 'prefix' is used as is.

    :param prefix: The prefix for a randomly generated name
    :param creation_func: A function taking the name of the resource
           to be created as it's first argument.  An error is assumed
           to indicate a name collision.
    :param *args *kwargs: These will be passed to the create function.
    """

    # Don't generate a random name if prefix is already full-length.
    if len(prefix) == n_const.DEVICE_NAME_MAX_LEN:
        return creation_func(prefix, *args, **kwargs)

    while True:
        name = utils.get_rand_name(
            max_length=n_const.DEVICE_NAME_MAX_LEN,
            prefix=prefix)
        try:
            return creation_func(name, *args, **kwargs)
        except RuntimeError:
            pass
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:25,代码来源:base.py


示例7: create_security_group

    def create_security_group(self, tenant_id, name=None):
        resource_type = 'security_group'

        name = name or utils.get_rand_name(prefix=resource_type)
        spec = {'tenant_id': tenant_id, 'name': name}

        return self._create_resource(resource_type, spec)
开发者ID:sebrandon1,项目名称:neutron,代码行数:7,代码来源:client.py


示例8: test_do_main_default_options

    def test_do_main_default_options(self):
        int_br = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
        self.conf.set_override("ovs_integration_bridge", int_br.br_name)
        self.conf.set_override("ovs_all_ports", False)

        noskip = collections.defaultdict(list)
        skip = collections.defaultdict(list)
        # add two vifs, one skipped, and a non-vif port to int_br
        for collection in (noskip, skip):
            collection[int_br].append(
                self.useFixture(net_helpers.OVSPortFixture(int_br)).port.name)
        # set skippable vif to be skipped
        int_br.ovsdb.db_set(
            'Interface', skip[int_br][0],
            ('external_ids', {constants.SKIP_CLEANUP: "True"})
        ).execute(check_error=True)
        device_name = utils.get_rand_name()
        skip[int_br].append(device_name)
        int_br.add_port(device_name, ('type', 'internal'))
        # sanity check
        for collection in (noskip, skip):
            for bridge, ports in collection.items():
                port_list = bridge.get_port_name_list()
                for port in ports:
                    self.assertIn(port, port_list)
        ovs_cleanup.do_main(self.conf)
        ports = int_br.get_port_name_list()
        for vif in noskip[int_br]:
            self.assertNotIn(vif, ports)
        for port in skip[int_br]:
            self.assertIn(port, ports)
开发者ID:openstack,项目名称:neutron,代码行数:31,代码来源:test_ovs_cleanup.py


示例9: test_plug_with_namespace_sets_mtu_higher_than_bridge

    def test_plug_with_namespace_sets_mtu_higher_than_bridge(self):
        device_mtu = 1450

        # Create a new OVS bridge
        ovs_bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
        self.assertFalse(ovs_bridge.get_port_name_list())

        # Add a new linuxbridge port with reduced MTU to OVS bridge
        lb_bridge = self.useFixture(
            net_helpers.LinuxBridgeFixture()).bridge
        lb_bridge_port = self.useFixture(
            net_helpers.LinuxBridgePortFixture(lb_bridge))
        lb_bridge_port.port.link.set_mtu(device_mtu - 1)
        ovs_bridge.add_port(lb_bridge_port.port.name)

        # Now plug a device with intended MTU that is higher than for the port
        # above and validate that its MTU is not reduced to the least MTU on
        # the bridge
        device_name = utils.get_rand_name()
        mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name
        self.interface.plug(network_id=uuidutils.generate_uuid(),
                            port_id=uuidutils.generate_uuid(),
                            device_name=device_name,
                            mac_address=mac_address,
                            bridge=ovs_bridge.br_name,
                            namespace=namespace,
                            mtu=device_mtu)

        self.assertIn(device_name, ovs_bridge.get_port_name_list())
        self.assertTrue(ip_lib.device_exists(device_name, namespace))
        self.assertEqual(
            device_mtu,
            ip_lib.IPDevice(device_name, namespace=namespace).link.mtu
        )
开发者ID:sebrandon1,项目名称:neutron,代码行数:35,代码来源:test_interface.py


示例10: create_network

    def create_network(self, tenant_id, name=None, external=False):
        resource_type = 'network'

        name = name or utils.get_rand_name(prefix=resource_type)
        spec = {'tenant_id': tenant_id, 'name': name}
        spec['router:external'] = external
        return self._create_resource(resource_type, spec)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:7,代码来源:client.py


示例11: test_db_add_to_new_object

 def test_db_add_to_new_object(self):
     ovsdb = self.ovs.ovsdb
     brname = utils.get_rand_name(prefix=net_helpers.BR_PREFIX)
     br = ovs_lib.OVSBridge(brname)  # doesn't create
     self.addCleanup(br.destroy)
     with ovsdb.transaction(check_error=True) as txn:
         txn.add(ovsdb.add_br(brname))
         txn.add(ovsdb.db_add('Bridge', brname, 'protocols', 'OpenFlow10'))
开发者ID:eayunstack,项目名称:neutron,代码行数:8,代码来源:test_ovs_lib.py


示例12: test_bridge_lifecycle_baseovs

 def test_bridge_lifecycle_baseovs(self):
     name = utils.get_rand_name(prefix=net_helpers.BR_PREFIX)
     self.addCleanup(self.ovs.delete_bridge, name)
     br = self.ovs.add_bridge(name)
     self.assertEqual(br.br_name, name)
     self.assertTrue(self.ovs.bridge_exists(name))
     self.ovs.delete_bridge(name)
     self.assertFalse(self.ovs.bridge_exists(name))
开发者ID:eayunstack,项目名称:neutron,代码行数:8,代码来源:test_ovs_lib.py


示例13: test_set_link_alias

    def test_set_link_alias(self):
        attr = self.generate_device_details()
        device = self.manage_device(attr)
        alias = utils.get_rand_name()

        device.link.set_alias(alias)

        self.assertEqual(alias, device.link.alias)
开发者ID:igordcard,项目名称:neutron,代码行数:8,代码来源:test_ip_lib.py


示例14: test_set_mtu

    def test_set_mtu(self):
        device_name = utils.get_rand_name()
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name

        self._test_mtu_set_after_action(
            device_name, self.bridge_name, namespace,
            functools.partial(
                self.interface.set_mtu,
                device_name=device_name, namespace=namespace))
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:9,代码来源:test_interface.py


示例15: setUp

 def setUp(self):
     super(TestKeepalivedStateChange, self).setUp()
     self.conf_fixture = self.useFixture(fixture_config.Config())
     kd.register_l3_agent_keepalived_opts(self.conf_fixture)
     self.router_id = uuidutils.generate_uuid()
     self.conf_dir = self.get_default_temp_dir().path
     self.cidr = '169.254.128.1/24'
     self.interface_name = utils.get_rand_name()
     self.monitor = keepalived_state_change.MonitorDaemon(
         self.get_temp_file_path('monitor.pid'),
         self.router_id,
         1,
         2,
         utils.get_rand_name(),
         self.conf_dir,
         self.interface_name,
         self.cidr)
     mock.patch.object(self.monitor, 'notify_agent').start()
     self.line = '1: %s    inet %s' % (self.interface_name, self.cidr)
开发者ID:openstack,项目名称:neutron,代码行数:19,代码来源:test_keepalived_state_change.py


示例16: create_router

    def create_router(self, tenant_id, name=None, ha=False,
                      external_network=None):
        resource_type = 'router'

        name = name or utils.get_rand_name(prefix=resource_type)
        spec = {'tenant_id': tenant_id, 'name': name, 'ha': ha}
        if external_network:
            spec['external_gateway_info'] = {"network_id": external_network}

        return self._create_resource(resource_type, spec)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:10,代码来源:client.py


示例17: setUp

 def setUp(self):
     super(OVSAgentTestFramework, self).setUp()
     agent_rpc = ('neutron.plugins.ml2.drivers.openvswitch.agent.'
                  'ovs_neutron_agent.OVSPluginApi')
     mock.patch(agent_rpc).start()
     mock.patch('neutron.agent.rpc.PluginReportStateAPI').start()
     self.br_int = utils.get_rand_name(n_const.DEVICE_NAME_MAX_LEN,
                                       prefix='br-int')
     self.br_tun = utils.get_rand_name(n_const.DEVICE_NAME_MAX_LEN,
                                       prefix='br-tun')
     self.br_phys = utils.get_rand_name(n_const.DEVICE_NAME_MAX_LEN,
                                        prefix='br-phys')
     patch_name_len = n_const.DEVICE_NAME_MAX_LEN - len("-patch-tun")
     self.patch_tun = "%s-patch-tun" % self.br_int[patch_name_len:]
     self.patch_int = "%s-patch-int" % self.br_tun[patch_name_len:]
     self.ovs = ovs_lib.BaseOVS()
     self.config = self._configure_agent()
     self.driver = interface.OVSInterfaceDriver(self.config)
     self.namespace = self.useFixture(net_helpers.NamespaceFixture()).name
开发者ID:eayunstack,项目名称:neutron,代码行数:19,代码来源:base.py


示例18: test_db_add_ref

    def test_db_add_ref(self):
        ovsdb = self.ovs.ovsdb
        brname = utils.get_rand_name(prefix=net_helpers.BR_PREFIX)
        br = ovs_lib.OVSBridge(brname)  # doesn't create
        self.addCleanup(br.destroy)
        with ovsdb.transaction(check_error=True) as txn:
            br = txn.add(ovsdb.db_create('Bridge', name=brname))
            txn.add(ovsdb.db_add('Open_vSwitch', '.', 'bridges', br))

        self.assertIn(brname, self.ovs.get_bridges())
开发者ID:eayunstack,项目名称:neutron,代码行数:10,代码来源:test_ovs_lib.py


示例19: test_bridge_lifecycle_ovsbridge

 def test_bridge_lifecycle_ovsbridge(self):
     name = utils.get_rand_name(prefix=net_helpers.BR_PREFIX)
     br = ovs_lib.OVSBridge(name)
     self.assertEqual(br.br_name, name)
     # Make sure that instantiating an OVSBridge does not actually create
     self.assertFalse(self.ovs.bridge_exists(name))
     self.addCleanup(self.ovs.delete_bridge, name)
     br.create()
     self.assertTrue(self.ovs.bridge_exists(name))
     br.destroy()
     self.assertFalse(self.ovs.bridge_exists(name))
开发者ID:eayunstack,项目名称:neutron,代码行数:11,代码来源:test_ovs_lib.py


示例20: _create_test_port_dict

 def _create_test_port_dict(self):
     return {'id': uuidutils.generate_uuid(),
             'mac_address': net.get_random_mac(
                 'fa:16:3e:00:00:00'.split(':')),
             'fixed_ips': [{
                 'ip_address': '10.%d.%d.%d' % (
                      random.randint(3, 254),
                      random.randint(3, 254),
                      random.randint(3, 254))}],
             'vif_name': utils.get_rand_name(
                 self.driver.DEV_NAME_LEN, self.driver.DEV_NAME_PREFIX)}
开发者ID:eayunstack,项目名称:neutron,代码行数:11,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_random_mac函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_rand_device_name函数代码示例发布时间: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