本文整理汇总了Python中tempest.lib.common.utils.data_utils.rand_name方法的典型用法代码示例。如果您正苦于以下问题:Python data_utils.rand_name方法的具体用法?Python data_utils.rand_name怎么用?Python data_utils.rand_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tempest.lib.common.utils.data_utils
的用法示例。
在下文中一共展示了data_utils.rand_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_audit_template
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_audit_template(self, goal, name=None, description=None,
strategy=None):
"""Wrapper utility for creating a test audit template
:param goal: Goal UUID or name related to the audit template.
:param name: The name of the audit template. Default: My Audit Template
:param description: The description of the audit template.
:param strategy: Strategy UUID or name related to the audit template.
:return: A tuple with The HTTP response and its body
"""
description = description or data_utils.rand_name(
'test-audit_template')
resp, body = self.client.create_audit_template(
name=name, description=description, goal=goal, strategy=strategy)
self.addCleanup(
self.delete_audit_template,
audit_template_uuid=body["uuid"]
)
return resp, body
示例2: create_audit_template
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_audit_template(cls, goal, name=None, description=None,
strategy=None, scope=None):
"""Wrapper utility for creating a test audit template
:param goal: Goal UUID or name related to the audit template.
:param name: The name of the audit template. Default: My Audit Template
:param description: The description of the audit template.
:param strategy: Strategy UUID or name related to the audit template.
:param scope: Scope that will be applied on all derived audits.
:return: A tuple with The HTTP response and its body
"""
description = description or data_utils.rand_name(
'test-audit_template')
resp, body = cls.client.create_audit_template(
name=name, description=description,
goal=goal, strategy=strategy, scope=scope)
cls.created_audit_templates.add(body['uuid'])
return resp, body
示例3: create_topology_router
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_topology_router(self, router_name, routers_client=None,
tenant_id=None, **kwargs):
if not routers_client:
routers_client = self.routers_client
if not tenant_id:
tenant_id = routers_client.tenant_id
router_name_ = constants.APPLIANCE_NAME_STARTS_WITH + router_name
name = data_utils.rand_name(router_name_)
router = routers_client.create_router(
name=name, admin_state_up=True, tenant_id=tenant_id)['router']
public_network_info = {"external_gateway_info": dict(
network_id=self.topology_public_network_id)}
routers_client.update_router(router['id'], **public_network_info)
self.topology_routers[router_name] = router
self.addCleanup(self.routers_client.delete_router, router['id'])
return router
示例4: create_topology_network
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_topology_network(
self, network_name, networks_client=None,
tenant_id=None, port_security_enabled=True, **kwargs):
if not networks_client:
networks_client = self.networks_client
if not tenant_id:
tenant_id = networks_client.tenant_id
network_name_ = constants.APPLIANCE_NAME_STARTS_WITH + network_name
name = data_utils.rand_name(network_name_)
# Neutron disables port security by default so we have to check the
# config before trying to create the network with port_security_enabled
if CONF.network_feature_enabled.port_security:
port_security_enabled = True
result = networks_client.create_network(
name=name, tenant_id=tenant_id,
port_security_enabled=port_security_enabled, **kwargs)
network = result['network']
self.assertEqual(network['name'], name)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
networks_client.delete_network, network['id'])
self.topology_networks[network_name] = network
return network
示例5: test_create_update_delete_vlan_network_subnet
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def test_create_update_delete_vlan_network_subnet(self):
# Create an admin network
name = data_utils.rand_name('admin-network-')
network = self.create_network(net_name=name,
net_type='vlan',
seg_id=1000)
net_id = network['id']
# Verify an exception thrown when updating network
new_name = "New_network"
# create a subnet and verify it is an admin tenant subnet
subnet = self.create_subnet(network)
subnet_id = subnet['id']
self.assertEqual(network['tenant_id'], subnet['tenant_id'])
# Verify subnet update
new_name = "New_subnet"
body = self.update_subnet(subnet_id, name=new_name)
updated_subnet = body['subnet']
self.assertEqual(updated_subnet['name'], new_name)
# Delete subnet and network
body = self.delete_subnet(subnet_id)
# Remove subnet from cleanup list
self.subnets.pop()
body = self.delete_network(net_id)
self.networks.pop()
示例6: create_network
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_network(cls, **kwargs):
"""Wrapper utility that returns a test admin provider network."""
network_name = (kwargs.get('net_name')
or data_utils.rand_name('test-adm-net-'))
net_type = kwargs.get('net_type', "flat")
if tempest.test.is_extension_enabled('provider', 'network'):
body = {'name': network_name}
body.update({'provider:network_type': net_type,
'provider:physical_network': 'dvs'})
if net_type == 'vlan':
_vlanid = kwargs.get('seg_id')
body.update({'provider:segmentation_id': _vlanid})
body = cls.admin_networks_client.create_network(**body)
network = body['network']
cls.networks.append(network)
return network
示例7: create_volume_type
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_volume_type(self, client=None, name=None, backend_name=None):
if not client:
client = self.admin_volume_types_client
if not name:
class_name = self.__class__.__name__
name = data_utils.rand_name(class_name + '-volume-type')
randomized_name = data_utils.rand_name('scenario-type-' + name)
LOG.debug("Creating a volume type: %s on backend %s",
randomized_name, backend_name)
extra_specs = {}
if backend_name:
extra_specs = {"volume_backend_name": backend_name}
body = client.create_volume_type(name=randomized_name,
extra_specs=extra_specs)
volume_type = body['volume_type']
self.assertIn('id', volume_type)
self.addCleanup(client.delete_volume_type, volume_type['id'])
return volume_type
示例8: _create_security_group
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def _create_security_group(self):
# Create security group
sg_name = data_utils.rand_name(self.__class__.__name__)
sg_desc = sg_name + " description"
secgroup = self.compute_security_groups_client.create_security_group(
name=sg_name, description=sg_desc)['security_group']
self.assertEqual(secgroup['name'], sg_name)
self.assertEqual(secgroup['description'], sg_desc)
self.addCleanup(
test_utils.call_and_ignore_notfound_exc,
self.compute_security_groups_client.delete_security_group,
secgroup['id'])
# Add rules to the security group
self._create_loginable_secgroup_rule(secgroup['id'])
return secgroup
示例9: _create_network
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def _create_network(self, networks_client=None,
tenant_id=None,
namestart='network-smoke-',
port_security_enabled=True):
if not networks_client:
networks_client = self.networks_client
if not tenant_id:
tenant_id = networks_client.tenant_id
name = data_utils.rand_name(namestart)
network_kwargs = dict(name=name, tenant_id=tenant_id)
# Neutron disables port security by default so we have to check the
# config before trying to create the network with port_security_enabled
if CONF.network_feature_enabled.port_security:
network_kwargs['port_security_enabled'] = port_security_enabled
result = networks_client.create_network(**network_kwargs)
network = result['network']
self.assertEqual(network['name'], name)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
networks_client.delete_network,
network['id'])
return network
示例10: _create_router
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def _create_router(self, client=None, tenant_id=None,
namestart='router-smoke'):
if not client:
client = self.routers_client
if not tenant_id:
tenant_id = client.tenant_id
name = data_utils.rand_name(namestart)
result = client.create_router(name=name,
admin_state_up=True,
tenant_id=tenant_id)
router = result['router']
self.assertEqual(router['name'], name)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
client.delete_router,
router['id'])
return router
示例11: create_mtz_network_subnet
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_mtz_network_subnet(self, scope_id, tenant_project_id,
cidr=None, cidr_offset=0):
"""MTZ networks can only be created by ADMIN
All tenant network resources will be created by ADMIN.
"""
networks_client = self.admin_manager.networks_client
subnets_client = self.admin_manager.subnets_client
network_name = data_utils.rand_name('mtz-net')
create_body = {'name': network_name,
'provider:network_type': self.provider_network_type,
'provider:physical_network': scope_id}
network = HELO.create_network(self, client=networks_client,
tenant_id=tenant_project_id,
**create_body)
subnet = HELO.create_subnet(self, network, client=subnets_client,
name=network_name,
tenant_id=tenant_project_id,
cidr=cidr, cidr_offset=cidr_offset)
lswitch_list = self.vsm.get_all_logical_switches(scope_id)
lswitch_list = [x for x in lswitch_list if x['name'] == network['id']]
msg = ("network=%s is not configured by specified vdn_scope_id=%s"
% (network['id'], scope_id))
self.assertTrue(len(lswitch_list) == 1, msg=msg)
return (network['id'], network, subnet)
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:27,代码来源:test_multiple_transport_zones_basic_ops.py
示例12: create_networks
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_networks(self, dns_search_domain=None, cidr_offset=0):
prefix_name = 'dns-search' if dns_search_domain else 'no-search'
network_name = data_utils.rand_name(prefix_name)
network = self.create_network(client=self.networks_client,
name=network_name)
network = network.get('network', network)
subnet_kwargs = dict(name=network_name,
dns_nameservers=CONF.network.dns_servers,
cidr_offset=cidr_offset)
if dns_search_domain:
subnet_kwargs[DNS_SEARCH_DOMAIN] = dns_search_domain
subnet = self.create_subnet(network,
client=self.subnets_client,
**subnet_kwargs)
subnet = subnet.get('subnet', subnet)
if dns_search_domain:
self.assertEqual(dns_search_domain, subnet[DNS_SEARCH_DOMAIN])
return (network, subnet, dns_search_domain)
示例13: create_network_subnet
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def create_network_subnet(SELF, client_mgr=None, name=None,
tenant_id=None, cidr_offset=0):
client_mgr = client_mgr or SELF.manager
networks_client = client_mgr.networks_client
subnets_client = client_mgr.subnets_client
tenant_id = tenant_id or networks_client.tenant_id
name = name or data_utils.rand_name('network')
net_network = create_network(SELF, client=networks_client,
tenant_id=tenant_id, name=name)
net_subnet = create_subnet(SELF, client=subnets_client,
network=net_network,
name=net_network['name'],
cidr_offset=cidr_offset)
return net_network, net_subnet
# cloned from [email protected] Allow name parameter
示例14: _setup_network_and_servers
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def _setup_network_and_servers(self, **kwargs):
boot_with_port = kwargs.pop('boot_with_port', False)
self.security_group = self._create_security_group()
self.network, self.subnet, self.router = self.create_networks(**kwargs)
self.check_networks()
self.port_id = None
if boot_with_port:
# create a port on the network and boot with that
self.port_id = self._create_port(self.network['id'])['id']
name = data_utils.rand_name('server-smoke')
server = self._create_server(name, self.network, self.port_id)
self._check_project_network_connectivity()
floating_ip = self.create_floating_ip(server)
self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
# overwrite super class who does not accept router attributes
示例15: _perform_operations_on_firewall
# 需要导入模块: from tempest.lib.common.utils import data_utils [as 别名]
# 或者: from tempest.lib.common.utils.data_utils import rand_name [as 别名]
def _perform_operations_on_firewall(self, firewall_topo, protocol_name):
self._check_floatingip_connectivity(
firewall_topo['fip1'], firewall_topo['serv1'],
should_connect=True)
firewall_rule_2 = self.fwaasv1_client.create_firewall_rule(
name=data_utils.rand_name("fw-rule"),
action="deny",
protocol=protocol_name)
fw_rule_id2 = firewall_rule_2['firewall_rule']['id']
self.addCleanup(self._delete_rule_if_exists, fw_rule_id2)
self.addCleanup(self._delete_policy_if_exists,
firewall_topo['fw_policy_id'])
self.addCleanup(self._delete_firewall_if_exists,
firewall_topo['firewall_id'])
# Insert rule-2 to firewall policy
self.fwaasv1_client.insert_firewall_rule_in_policy(
firewall_topo['fw_policy_id'], fw_rule_id2, '',
firewall_topo['fw_rule_id1'])
self._wait_firewall_ready(firewall_topo['firewall_id'])
return fw_rule_id2