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


Python base.get_rand_name函数代码示例

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


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


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