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

Python base.get_rand_name函数代码示例

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

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



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

示例1: _setUp

    def _setUp(self):
        self.user = base.get_rand_name(prefix="user")
        self.password = base.get_rand_name(prefix="pass")
        self.vhost = base.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:Raghunanda,项目名称:neutron,代码行数:12,代码来源:fullstack_fixtures.py


示例2: _setUp

    def _setUp(self):
        self.user = base.get_rand_name(prefix='user')
        self.password = base.get_rand_name(prefix='pass')
        self.vhost = base.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:neoareslinux,项目名称:neutron,代码行数:13,代码来源:process.py


示例3: setUp

    def setUp(self):
        super(RabbitmqEnvironmentFixture, self).setUp()

        self.user = base.get_rand_name(prefix='user')
        self.password = base.get_rand_name(prefix='pass')
        self.vhost = base.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:bgxavier,项目名称:neutron,代码行数:15,代码来源:fullstack_fixtures.py


示例4: 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 = base.get_rand_name(
            max_length=n_const.DEVICE_NAME_MAX_LEN,
            prefix=prefix)
        try:
            return creation_func(name, *args, **kwargs)
        except RuntimeError:
            pass
开发者ID:21atlas,项目名称:neutron,代码行数:25,代码来源:base.py


示例5: create_network

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

        name = name or base.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:21atlas,项目名称:neutron,代码行数:7,代码来源:client.py


示例6: create_network

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

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

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


示例7: create_router

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

        name = name or base.get_rand_name(prefix=resource_type)
        spec = {"tenant_id": tenant_id, "name": name, "ha": ha}

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


示例8: 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 = tests_base.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:21atlas,项目名称:neutron,代码行数:35,代码来源:test_interface.py


示例9: create_router

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

        name = name or base.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:21atlas,项目名称:neutron,代码行数:10,代码来源:client.py


示例10: create_subnet

    def create_subnet(self, tenant_id, network_id,
                      cidr, gateway_ip=None, ip_version=4,
                      name=None, enable_dhcp=True):
        resource_type = 'subnet'

        name = name or base.get_rand_name(prefix=resource_type)
        spec = {'tenant_id': tenant_id, 'network_id': network_id, 'name': name,
                'cidr': cidr, 'ip_version': ip_version,
                'enable_dhcp': enable_dhcp}
        if gateway_ip:
            spec['gateway_ip'] = gateway_ip

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


示例11: test_network_lifecycle

 def test_network_lifecycle(self):
     net = self.client.create_network(name=tests_base.get_rand_name())
     listed_networks = {x.id: x.name for x in self.client.get_networks()}
     self.assertIn(net.id, listed_networks)
     self.assertEqual(listed_networks[net.id], net.name,
                      'Listed network name is not as expected.')
     updated_name = 'new %s' % net.name
     updated_net = self.client.update_network(net.id, name=updated_name)
     self.assertEqual(updated_name, updated_net.name,
                      'Updated network name is not as expected.')
     self.client.delete_network(net.id)
     with testtools.ExpectedException(self.client.NotFound,
                                      msg='Network was not deleted'):
         self.client.get_network(net.id)
开发者ID:21atlas,项目名称:neutron,代码行数:14,代码来源:test_example.py


示例12: _setUp

    def _setUp(self):
        super(OVSPortFixture, self)._setUp()

        # because in some tests this port can be used to providing connection
        # between linuxbridge agents and vlan_id can be also added to this
        # device name it has to be max LB_DEVICE_NAME_MAX_LEN long
        port_name = tests_base.get_rand_name(
            LB_DEVICE_NAME_MAX_LEN,
            PORT_PREFIX
        )

        if self.hybrid_plug:
            self.hybrid_plug_port(port_name)
        else:
            self.plug_port(port_name)
开发者ID:muraliran,项目名称:neutron,代码行数:15,代码来源:net_helpers.py


示例13: test_plug_succeeds

    def test_plug_succeeds(self):
        device_name = tests_base.get_rand_name()
        mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name
        bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge

        self.assertFalse(bridge.get_port_name_list())
        self.interface.plug(network_id=uuidutils.generate_uuid(),
                            port_id=uuidutils.generate_uuid(),
                            device_name=device_name,
                            mac_address=mac_address,
                            bridge=bridge.br_name,
                            namespace=namespace)
        self.assertIn(device_name, bridge.get_port_name_list())
        self.assertTrue(ip_lib.device_exists(device_name, namespace))
开发者ID:Blahhhhh,项目名称:neutron,代码行数:15,代码来源:test_interface.py


示例14: create_subnet

    def create_subnet(self, tenant_id, network_id, cidr, gateway_ip=None, ip_version=4, name=None, enable_dhcp=True):
        resource_type = "subnet"

        name = name or base.get_rand_name(prefix=resource_type)
        spec = {
            "tenant_id": tenant_id,
            "network_id": network_id,
            "name": name,
            "cidr": cidr,
            "ip_version": ip_version,
            "enable_dhcp": enable_dhcp,
        }
        if gateway_ip:
            spec["gateway_ip"] = gateway_ip

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


示例15: _setUp

    def _setUp(self):
        super(OVSPortFixture, self)._setUp()

        interface_config = cfg.ConfigOpts()
        interface_config.register_opts(interface.OPTS)
        ovs_interface = interface.OVSInterfaceDriver(interface_config)

        # because in some tests this port can be used to providing connection
        # between linuxbridge agents and vlan_id can be also added to this
        # device name it has to be max LB_DEVICE_NAME_MAX_LEN long
        port_name = tests_base.get_rand_name(LB_DEVICE_NAME_MAX_LEN, PORT_PREFIX)
        ovs_interface.plug_new(
            None, self.port_id, port_name, self.mac, bridge=self.bridge.br_name, namespace=self.namespace
        )
        self.addCleanup(self.bridge.delete_port, port_name)
        self.port = ip_lib.IPDevice(port_name, self.namespace)
开发者ID:bigswitch,项目名称:neutron,代码行数:16,代码来源:net_helpers.py


示例16: create_resource

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

    :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.
    """
    while True:
        name = base.get_rand_name(
            max_length=n_const.DEVICE_NAME_MAX_LEN,
            prefix=prefix)
        try:
            return creation_func(name, *args, **kwargs)
        except RuntimeError:
            pass
开发者ID:Akanksha08,项目名称:neutron,代码行数:17,代码来源:base.py


示例17: create_subnet

    def create_subnet(self, tenant_id, network_id,
                      cidr, gateway_ip=None, name=None, enable_dhcp=True,
                      ipv6_address_mode='slaac', ipv6_ra_mode='slaac'):
        resource_type = 'subnet'

        name = name or base.get_rand_name(prefix=resource_type)
        ip_version = netaddr.IPNetwork(cidr).version
        spec = {'tenant_id': tenant_id, 'network_id': network_id, 'name': name,
                'cidr': cidr, 'enable_dhcp': enable_dhcp,
                'ip_version': ip_version}
        if ip_version == constants.IP_VERSION_6:
            spec['ipv6_address_mode'] = ipv6_address_mode
            spec['ipv6_ra_mode'] = ipv6_ra_mode

        if gateway_ip:
            spec['gateway_ip'] = gateway_ip

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


示例18: create_patch_ports

def create_patch_ports(source, destination):
    """Hook up two OVS bridges.

    The result is two patch ports, each end connected to a bridge.
    The two patch port names will start with 'patch-', followed by identical
    four characters. For example patch-xyzw-fedora, and patch-xyzw-ubuntu,
    where fedora and ubuntu are random strings.

    :param source: Instance of OVSBridge
    :param destination: Instance of OVSBridge
    """
    common = tests_base.get_rand_name(max_length=4, prefix='')
    prefix = '%s-%s-' % (PATCH_PREFIX, common)

    source_name = tests_base.get_rand_device_name(prefix=prefix)
    destination_name = tests_base.get_rand_device_name(prefix=prefix)

    source.add_patch_port(source_name, destination_name)
    destination.add_patch_port(destination_name, source_name)
开发者ID:21atlas,项目名称:neutron,代码行数:19,代码来源:net_helpers.py


示例19: _generate_namespace_suffix

 def _generate_namespace_suffix(self):
     return base.get_rand_name(prefix='test')
开发者ID:rajeshmohan,项目名称:neutron,代码行数:2,代码来源:config_fixtures.py


示例20: _generate_external_bridge

 def _generate_external_bridge(self):
     return base.get_rand_name(prefix='br-ex',
                               max_length=constants.DEVICE_NAME_MAX_LEN)
开发者ID:rajeshmohan,项目名称:neutron,代码行数:3,代码来源:config_fixtures.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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