本文整理汇总了Python中quantum.common.utils.str_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python str_uuid函数的具体用法?Python str_uuid怎么用?Python str_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:a3linux,项目名称:quantum,代码行数:57,代码来源:securitygroups_db.py
示例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
开发者ID:Blackspan,项目名称:quantum,代码行数:9,代码来源:test_db.py
示例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)
开发者ID:ddutta,项目名称:quantum,代码行数:60,代码来源:l3_db.py
示例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
开发者ID:a3linux,项目名称:quantum,代码行数:30,代码来源:securitygroups_db.py
示例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)
开发者ID:vbannai,项目名称:quantum,代码行数:31,代码来源:db_base_plugin_v2.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:9,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:10,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:10,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:11,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:11,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:11,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:11,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:12,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:12,代码来源:nwservices_db.py
示例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)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:12,代码来源:nwservices_db.py
示例16: create_subnet
def create_subnet(self, context, subnet):
s = subnet['subnet']
self._validate_subnet(s)
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(subtransactions=True):
network = self._get_network(context, s["network_id"])
self._validate_subnet_cidr(network, s['cidr'])
# The 'shared' attribute for subnets is for internal plugin
# use only. It is not exposed through the API
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'],
enable_dhcp=s['enable_dhcp'],
gateway_ip=s['gateway_ip'],
shared=network.shared)
# perform allocate pools first, since it might raise an error
pools = self._allocate_pools_for_subnet(context, s)
context.session.add(subnet)
if s['dns_nameservers'] != attributes.ATTR_NOT_SPECIFIED:
for addr in s['dns_nameservers']:
ns = models_v2.DNSNameServer(address=addr,
subnet_id=subnet.id)
context.session.add(ns)
if s['host_routes'] != attributes.ATTR_NOT_SPECIFIED:
for rt in s['host_routes']:
route = models_v2.Route(subnet_id=subnet.id,
destination=rt['destination'],
nexthop=rt['nexthop'])
context.session.add(route)
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)
开发者ID:missall,项目名称:quantum,代码行数:52,代码来源:db_base_plugin_v2.py
示例17: create_port
def create_port(self, context, port):
p = port['port']
# NOTE(jkoelker) Get the tenant_id outside of the session to avoid
# unneeded db action if the operation raises
tenant_id = self._get_tenant_id_for_create(context, p)
with context.session.begin(subtransactions=True):
network = self._get_network(context, p["network_id"])
# Ensure that a MAC address is defined and it is unique on the
# network
if p['mac_address'] == attributes.ATTR_NOT_SPECIFIED:
p['mac_address'] = QuantumDbPluginV2._generate_mac(
context, p["network_id"])
else:
# Ensure that the mac on the network is unique
if not QuantumDbPluginV2._check_unique_mac(context,
p["network_id"],
p['mac_address']):
raise q_exc.MacAddressInUse(net_id=p["network_id"],
mac=p['mac_address'])
# Returns the IP's for the port
ips = self._allocate_ips_for_port(context, network, port)
port = models_v2.Port(tenant_id=tenant_id,
name=p['name'],
id=p.get('id') or utils.str_uuid(),
network_id=p['network_id'],
mac_address=p['mac_address'],
admin_state_up=p['admin_state_up'],
status=constants.PORT_STATUS_ACTIVE,
device_id=p['device_id'],
device_owner=p['device_owner'])
context.session.add(port)
# Update the allocated IP's
if ips:
with context.session.begin(subtransactions=True):
for ip in ips:
LOG.debug("Allocated IP %s (%s/%s/%s)", ip['ip_address'],
port['network_id'], ip['subnet_id'], port.id)
allocated = models_v2.IPAllocation(
network_id=port['network_id'],
port_id=port.id,
ip_address=ip['ip_address'],
subnet_id=ip['subnet_id'],
expiration=self._default_allocation_expiration()
)
context.session.add(allocated)
return self._make_port_dict(port)
开发者ID:missall,项目名称:quantum,代码行数:52,代码来源:db_base_plugin_v2.py
示例18: create_network
def create_network(self, context, network):
n = network['network']
# NOTE(jkoelker) Get the tenant_id outside of the session to avoid
# unneeded db action if the operation raises
tenant_id = self._get_tenant_id_for_create(context, n)
with context.session.begin():
network = models_v2.Network(tenant_id=tenant_id,
id=n.get('id') or utils.str_uuid(),
name=n['name'],
admin_state_up=n['admin_state_up'],
status="ACTIVE")
context.session.add(network)
return self._make_network_dict(network)
开发者ID:vbannai,项目名称:quantum,代码行数:13,代码来源:db_base_plugin_v2.py
示例19: create_chain_image_conf
def create_chain_image_conf(self, context, chain_image_conf):
n = chain_image_conf['chain_image_conf']
with context.session.begin(subtransactions=True):
chain_image = self._get_chain_image(context, n["chain_map_id"])
#self._validate_chain_image_conf_id(context, chain_image, n['networkfunction_id'])
chain_image_conf = ns_chain_configuration_associate(id=n.get('id') or utils.str_uuid(),
chain_map_id=n['chain_map_id'],
networkfunction_id=n['networkfunction_id'],
config_handle_id=n['config_handle_id'])
context.session.add(chain_image_conf)
return self._make_chain_image_conf_dict(chain_image_conf)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:13,代码来源:nwservices_db.py
示例20: create_session
def create_session(self, context, session):
""" handle creation of a single session """
# single request processing
s = session['session']
# NOTE(jkoelker) Get the tenant_id outside of the session to avoid
# unneeded db action if the operation raises
tenant_id = self._get_tenant_id_for_create(context, s)
with context.session.begin(subtransactions=True):
session = LB_Session_Persistance(id=s.get('id') or utils.str_uuid(),
type=s['type'],
cookie_name=s['cookie_name'])
context.session.add(session)
return self._make_session_dict(session)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:13,代码来源:loadbalancer_db.py
注:本文中的quantum.common.utils.str_uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论