本文整理汇总了Python中quantum.common.utils.str_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python str_uuid函数的具体用法?Python str_uuid怎么用?Python str_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_security_group
def create_security_group(self, context, security_group, default_sg=False):
"""Create security group.
If default_sg is true that means we are a default security group for
a given tenant if it does not exist.
"""
s = security_group['security_group']
if (cfg.CONF.SECURITYGROUP.proxy_mode and not context.is_admin):
raise ext_sg.SecurityGroupProxyModeNotAdmin()
if (cfg.CONF.SECURITYGROUP.proxy_mode and not s.get('external_id')):
raise ext_sg.SecurityGroupProxyMode()
if not cfg.CONF.SECURITYGROUP.proxy_mode and s.get('external_id'):
raise ext_sg.SecurityGroupNotProxyMode()
tenant_id = self._get_tenant_id_for_create(context, s)
# if in proxy mode a default security group will be created by source
if not default_sg and not cfg.CONF.SECURITYGROUP.proxy_mode:
self._ensure_default_security_group(context, tenant_id,
security_group)
if s.get('external_id'):
try:
# Check if security group already exists
sg = self.get_security_group(context, s.get('external_id'))
if sg:
raise ext_sg.SecurityGroupAlreadyExists(
name=sg.get('name', ''),
external_id=s.get('external_id'))
except ext_sg.SecurityGroupNotFound:
pass
with context.session.begin(subtransactions=True):
security_group_db = SecurityGroup(id=s.get('id') or (
utils.str_uuid()),
description=s['description'],
tenant_id=tenant_id,
name=s['name'],
external_id=s.get('external_id'))
context.session.add(security_group_db)
if s.get('name') == 'default':
for ethertype in self.sg_supported_ethertypes:
# Allow all egress traffic
db = SecurityGroupRule(
id=utils.str_uuid(), tenant_id=tenant_id,
security_group=security_group_db,
direction='egress',
ethertype=ethertype)
context.session.add(db)
# Allow intercommunication
db = SecurityGroupRule(
id=utils.str_uuid(), tenant_id=tenant_id,
security_group=security_group_db,
direction='ingress',
source_group=security_group_db,
ethertype=ethertype)
context.session.add(db)
return self._make_security_group_dict(security_group_db)
示例2: get_portinfo_random_params
def get_portinfo_random_params(self):
"""create random parameters for portinfo test"""
port_id = utils.str_uuid()
datapath_id = hex(random.randint(0, 0xffffffff))
port_no = random.randint(1, 100)
vlan_id = random.randint(0, 4095)
mac = ':'.join(["%02x" % random.randint(0, 0xff) for x in range(6)])
none = utils.str_uuid()
return port_id, datapath_id, port_no, vlan_id, mac, none
示例3: create_floatingip
def create_floatingip(self, context, floatingip):
fip = floatingip['floatingip']
tenant_id = self._get_tenant_id_for_create(context, fip)
fip_id = utils.str_uuid()
f_net_id = fip['floating_network_id']
if not self._network_is_external(context, f_net_id):
msg = "Network %s is not a valid external network" % f_net_id
raise q_exc.BadRequest(resource='floatingip', msg=msg)
# This external port is never exposed to the tenant.
# it is used purely for internal system and admin use when
# managing floating IPs.
external_port = self.create_port(context.elevated(), {
'port':
{'tenant_id': '', # tenant intentionally not set
'network_id': f_net_id,
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
'admin_state_up': True,
'device_id': fip_id,
'device_owner': DEVICE_OWNER_FLOATINGIP,
'name': ''}})
# Ensure IP addresses are allocated on external port
if not external_port['fixed_ips']:
msg = "Unable to find any IP address on external network"
# remove the external port
self.delete_port(context.elevated(), external_port['id'],
l3_port_check=False)
raise q_exc.BadRequest(resource='floatingip', msg=msg)
floating_ip_address = external_port['fixed_ips'][0]['ip_address']
try:
with context.session.begin(subtransactions=True):
floatingip_db = FloatingIP(
id=fip_id,
tenant_id=tenant_id,
floating_network_id=fip['floating_network_id'],
floating_ip_address=floating_ip_address,
floating_port_id=external_port['id'])
fip['tenant_id'] = tenant_id
# Update association with internal port
# and define external IP address
self._update_fip_assoc(context, fip,
floatingip_db, external_port)
context.session.add(floatingip_db)
# TODO(salvatore-orlando): Avoid broad catch
# Maybe by introducing base class for L3 exceptions
except q_exc.BadRequest:
LOG.exception("Unable to create Floating ip due to a "
"malformed request")
raise
except Exception:
LOG.exception("Floating IP association failed")
# Remove the port created for internal purposes
self.delete_port(context.elevated(), external_port['id'],
l3_port_check=False)
raise
return self._make_floatingip_dict(floatingip_db)
示例4: create_security_group_rule_bulk_native
def create_security_group_rule_bulk_native(self, context,
security_group_rule):
r = security_group_rule['security_group_rules']
scoped_session(context.session)
security_group_id = self._validate_security_group_rules(
context, security_group_rule)
with context.session.begin(subtransactions=True):
if not self.get_security_group(context, security_group_id):
raise ext_sg.SecurityGroupNotFound(id=security_group_id)
self._check_for_duplicate_rules(context, r)
ret = []
for rule_dict in r:
rule = rule_dict['security_group_rule']
tenant_id = self._get_tenant_id_for_create(context, rule)
db = SecurityGroupRule(
id=utils.str_uuid(), tenant_id=tenant_id,
security_group_id=rule['security_group_id'],
direction=rule['direction'],
external_id=rule.get('external_id'),
source_group_id=rule.get('source_group_id'),
ethertype=rule['ethertype'],
protocol=rule['protocol'],
port_range_min=rule['port_range_min'],
port_range_max=rule['port_range_max'],
source_ip_prefix=rule.get('source_ip_prefix'))
context.session.add(db)
ret.append(self._make_security_group_rule_dict(db))
return ret
示例5: create_subnet
def create_subnet(self, context, subnet):
s = subnet['subnet']
net = netaddr.IPNetwork(s['cidr'])
if s['gateway_ip'] == attributes.ATTR_NOT_SPECIFIED:
s['gateway_ip'] = str(netaddr.IPAddress(net.first + 1))
tenant_id = self._get_tenant_id_for_create(context, s)
with context.session.begin():
network = self._get_network(context, s["network_id"])
self._validate_subnet_cidr(network, s['cidr'])
subnet = models_v2.Subnet(tenant_id=tenant_id,
id=s.get('id') or utils.str_uuid(),
name=s['name'],
network_id=s['network_id'],
ip_version=s['ip_version'],
cidr=s['cidr'],
gateway_ip=s['gateway_ip'],
enable_dhcp=s['enable_dhcp'])
context.session.add(subnet)
pools = self._allocate_pools_for_subnet(context, s)
for pool in pools:
ip_pool = models_v2.IPAllocationPool(subnet=subnet,
first_ip=pool['start'],
last_ip=pool['end'])
context.session.add(ip_pool)
ip_range = models_v2.IPAvailabilityRange(
ipallocationpool=ip_pool,
first_ip=pool['start'],
last_ip=pool['end'])
context.session.add(ip_range)
return self._make_subnet_dict(subnet)
示例6: create_category_networkfunction
def create_category_networkfunction(self, context, category_networkfunction):
n = category_networkfunction['category_networkfunction']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
category_networkfunction = ns_category_networkfunction(id=n.get('id') or utils.str_uuid(),
category_id=n['category_id'],
networkfunction_id=n['networkfunction_id'])
context.session.add(category_networkfunction)
return self._make_category_networkfunction_dict(category_networkfunction)
示例7: create_personality
def create_personality(self, context, personality):
n = personality['personality']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
personality = ns_personalitie(id=n.get('id') or utils.str_uuid(),
file_path=n['file_path'],
file_content=n['file_content'],
image_map_id=n['image_map_id'])
context.session.add(personality)
return self._make_personality_dict(personality)
示例8: create_metadata
def create_metadata(self, context, metadata):
n = metadata['metadata']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
metadata = ns_metadata(id=n.get('id') or utils.str_uuid(),
name=n['name'],
value=n['value'],
image_map_id=n['image_map_id'])
context.session.add(metadata)
return self._make_metadata_dict(metadata)
示例9: create_networkfunction
def create_networkfunction(self, context, networkfunction):
n = networkfunction['networkfunction']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
networkfunction = ns_networkfunction(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
description=n['description'],
shared=n['shared'])
context.session.add(networkfunction)
return self._make_networkfunction_dict(networkfunction)
示例10: create_chain
def create_chain(self, context, chain):
n = chain['chain']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
chain = ns_chain(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
type=n['type'],
auto_boot=n['auto_boot'])
context.session.add(chain)
return self._make_chain_dict(chain)
示例11: create_vendor
def create_vendor(self, context, vendor):
n = vendor['vendor']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
vendor = ns_vendor(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
description=n['description'],
shared=n['shared'])
context.session.add(vendor)
return self._make_vendor_dict(vendor)
示例12: create_category
def create_category(self, context, category):
n = category['category']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
category = ns_categorie(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
description=n['description'],
shared=n['shared'])
context.session.add(category)
return self._make_category_dict(category)
示例13: create_chain_image_network
def create_chain_image_network(self, context, chain_image_network):
n = chain_image_network['chain_image_network']
with context.session.begin(subtransactions=True):
chain_image = self._get_chain_image(context, n["chain_map_id"])
self._validate_chain_image_network_id(context, chain_image, n['network_id'])
chain_image_network = ns_chain_network_associate(id=n.get('id') or utils.str_uuid(),
chain_map_id=n['chain_map_id'],
network_id=n['network_id'])
context.session.add(chain_image_network)
return self._make_chain_image_network_dict(chain_image_network)
示例14: create_chain_image
def create_chain_image(self, context, chain_image):
n = chain_image['chain_image']
with context.session.begin(subtransactions=True):
chain_image = ns_chain_image_map(id=n.get('id') or utils.str_uuid(),
name=n['name'],
chain_id=n['chain_id'],
image_map_id=n['image_map_id'],
sequence_number=n['sequence_number'],
instance_id =n['instance_id'],
instance_uuid =n['instance_uuid'])
context.session.add(chain_image)
return self._make_chain_image_dict(chain_image)
示例15: create_config_handle
def create_config_handle(self, context, config_handle):
n = config_handle['config_handle']
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin(subtransactions=True):
config_handle = ns_config_handle(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
networkfunction_id=n['networkfunction_id'],
status=n['status'],
slug=n['slug'])
context.session.add(config_handle)
return self._make_config_handle_dict(config_handle)