本文整理汇总了Python中nova.context.to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python to_dict函数的具体用法?Python to_dict怎么用?Python to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_dict函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _create
def _create(self, req, body):
context = req.environ['nova.context']
context = context.elevated()
print "context!!"
print context.to_dict()
vals = body['network']
name = vals['name']
size = vals['size']
project_id=str(req.environ['HTTP_X_TENANT_ID'])
print FLAGS.network_manager
cidr = self.get_new_cidr(context, size)
print cidr
print"!!!!!!!!!!!!!!!!strat creating"
self.create_network(context=context, label=name, fixed_range_v4=cidr, num_networks=1,
network_size=size, multi_host=None, vlan_start=None,
vpn_start=None, fixed_range_v6=None, gateway=None,
gateway_v6=None, bridge=None, bridge_interface=None,
dns1=None, dns2=None, project_id=project_id, priority=None,
uuid=None, fixed_cidr=None)
print cidr
db_net = db.network_get_by_cidr(context, cidr)
net = dict(db_net.iteritems())
ret_net={}
ret_net['network']={'id':net['uuid'],'name':net['label'],'cidr':net['cidr']}
return ret_net
开发者ID:HolySparky,项目名称:Openstack-NetworkAPI,代码行数:25,代码来源:networks.py
示例2: _inner
def _inner():
ctxt = RpcContext.from_dict(context.to_dict())
try:
rval = node_func(context=ctxt, **node_args)
res = []
# Caller might have called ctxt.reply() manually
for (reply, failure) in ctxt._response:
if failure:
raise failure[0], failure[1], failure[2]
res.append(reply)
# if ending not 'sent'...we might have more data to
# return from the function itself
if not ctxt._done:
if inspect.isgenerator(rval):
for val in rval:
res.append(val)
else:
res.append(rval)
done.send(res)
except Exception:
exc_info = sys.exc_info()
done.send_exception(
rpc_common.RemoteError(exc_info[0].__name__,
str(exc_info[1]),
''.join(traceback.format_exception(*exc_info))))
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:25,代码来源:impl_fake.py
示例3: call
def call(self, context, method, args):
node_func = getattr(self.proxy, method)
node_args = dict((str(k), v) for k, v in args.iteritems())
ctxt = RpcContext.from_dict(context.to_dict())
try:
rval = node_func(context=ctxt, **node_args)
# Caller might have called ctxt.reply() manually
for (reply, failure) in ctxt._response:
if failure:
raise failure[0], failure[1], failure[2]
yield reply
# if ending not 'sent'...we might have more data to
# return from the function itself
if not ctxt._done:
if isinstance(rval, types.GeneratorType):
for val in rval:
yield val
else:
yield rval
except Exception:
exc_info = sys.exc_info()
raise rpc_common.RemoteError(exc_info[0].__name__,
str(exc_info[1]),
''.join(traceback.format_exception(*exc_info)))
开发者ID:swapniltamse,项目名称:nova,代码行数:25,代码来源:impl_fake.py
示例4: trigger_security_group_rule_destroy_refresh
def trigger_security_group_rule_destroy_refresh(self, context, rule_ids):
LOG.debug('rule_ids=%r', rule_ids)
ctxt = context.elevated()
tenant_id = context.to_dict()['project_id']
for rule_id in rule_ids:
self.rule_manager.delete_for_sg(tenant_id, rule_id)
开发者ID:JoeMido,项目名称:midonet-openstack,代码行数:7,代码来源:sg.py
示例5: trigger_security_group_destroy_refresh
def trigger_security_group_destroy_refresh(self, context,
security_group_id):
LOG.debug('security_group_id=%r', security_group_id)
tenant_id = context.to_dict()['project_id']
# delete corresponding chain
self.chain_manager.delete_for_sg(tenant_id, security_group_id)
# delete the port group
self.pg_manager.delete(tenant_id, security_group_id, '')
开发者ID:JoeMido,项目名称:midonet-openstack,代码行数:10,代码来源:sg.py
示例6: pack_context
def pack_context(msg, context):
"""Pack context into msg.
Values for message keys need to be less than 255 chars, so we pull
context out into a bunch of separate keys. If we want to support
more arguments in rabbit messages, we may want to do the same
for args at some point.
"""
context_d = dict([("_context_%s" % key, value) for (key, value) in context.to_dict().iteritems()])
msg.update(context_d)
开发者ID:Jaesang,项目名称:nova,代码行数:11,代码来源:amqp.py
示例7: trigger_security_group_rule_create_refresh
def trigger_security_group_rule_create_refresh(self, context, rule_ids):
LOG.debug('rule_ids=%r', rule_ids)
ctxt = context.elevated()
tenant_id = context.to_dict()['project_id']
for rule_id in rule_ids:
rule = db.security_group_rule_get(ctxt, rule_id)
group = db.security_group_get(ctxt, rule['parent_group_id'])
sg_id = rule['parent_group_id']
sg_name = group['name']
self.rule_manager.create_for_sg(tenant_id, sg_id, sg_name, rule)
开发者ID:JoeMido,项目名称:midonet-openstack,代码行数:13,代码来源:sg.py
示例8: fake_create_networks
def fake_create_networks(obj, context, **kwargs):
self.assertTrue(context.to_dict()['is_admin'])
self.assertEqual(kwargs['label'], 'Test')
self.assertEqual(kwargs['cidr'], '10.2.0.0/24')
self.assertEqual(kwargs['multi_host'], False)
self.assertEqual(kwargs['num_networks'], 1)
self.assertEqual(kwargs['network_size'], 256)
self.assertEqual(kwargs['vlan_start'], 200)
self.assertEqual(kwargs['vpn_start'], 2000)
self.assertEqual(kwargs['cidr_v6'], 'fd00:2::/120')
self.assertEqual(kwargs['gateway_v6'], 'fd00:2::22')
self.assertEqual(kwargs['bridge'], 'br200')
self.assertEqual(kwargs['bridge_interface'], 'eth0')
self.assertEqual(kwargs['dns1'], '8.8.8.8')
self.assertEqual(kwargs['dns2'], '8.8.4.4')
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:15,代码来源:test_nova_manage.py
示例9: fake_create_networks
def fake_create_networks(obj, context, **kwargs):
self.assertTrue(context.to_dict()["is_admin"])
self.assertEqual(kwargs["label"], "Test")
self.assertEqual(kwargs["cidr"], "10.2.0.0/24")
self.assertEqual(kwargs["multi_host"], False)
self.assertEqual(kwargs["num_networks"], 1)
self.assertEqual(kwargs["network_size"], 256)
self.assertEqual(kwargs["vlan_start"], 200)
self.assertEqual(kwargs["vpn_start"], 2000)
self.assertEqual(kwargs["cidr_v6"], "fd00:2::/120")
self.assertEqual(kwargs["gateway"], "10.2.0.1")
self.assertEqual(kwargs["gateway_v6"], "fd00:2::22")
self.assertEqual(kwargs["bridge"], "br200")
self.assertEqual(kwargs["bridge_interface"], "eth0")
self.assertEqual(kwargs["dns1"], "8.8.8.8")
self.assertEqual(kwargs["dns2"], "8.8.4.4")
开发者ID:hesamrahimi,项目名称:nova,代码行数:16,代码来源:test_nova_manage.py
示例10: trigger_security_group_create_refresh
def trigger_security_group_create_refresh(self, context, group):
"""Create a chain and port group for the security group."""
LOG.debug('group=%r', group)
ctxt = context.elevated()
sg_ref = db.security_group_get_by_name(ctxt, group['project_id'],
group['name'])
tenant_id = context.to_dict()['project_id']
sg_id = sg_ref['id']
sg_name = group['name']
# create a chain for the security group
self.chain_manager.create_for_sg(tenant_id, sg_id, sg_name)
# create a port group for the security group
self.pg_manager.create(tenant_id, sg_id, sg_name)
开发者ID:JoeMido,项目名称:midonet-openstack,代码行数:17,代码来源:sg.py
示例11: _inner
def _inner():
ctxt = RpcContext.from_dict(context.to_dict())
try:
rval = node_func(context=ctxt, **node_args)
res = []
# Caller might have called ctxt.reply() manually
for (reply, failure) in ctxt._response:
if failure:
raise failure[0], failure[1], failure[2]
res.append(reply)
# if ending not 'sent'...we might have more data to
# return from the function itself
if not ctxt._done:
if inspect.isgenerator(rval):
for val in rval:
res.append(val)
else:
res.append(rval)
done.send(res)
except Exception as e:
done.send_exception(e)
开发者ID:Cygnet,项目名称:nova,代码行数:21,代码来源:impl_fake.py
示例12: fake_network_get_by_uuid
def fake_network_get_by_uuid(context, uuid):
self.assertTrue(context.to_dict()['is_admin'])
self.assertEqual(uuid, self.fake_net['uuid'])
return db_fakes.FakeModel(dict(test_network.fake_network,
**self.fake_net))
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:5,代码来源:test_nova_manage.py
示例13: fake_network_get_by_cidr
def fake_network_get_by_cidr(context, cidr):
self.assertTrue(context.to_dict()['is_admin'])
self.assertEqual(cidr, self.fake_net['cidr'])
return db_fakes.FakeModel(dict(test_network.fake_network,
**self.fake_net))
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:5,代码来源:test_nova_manage.py
示例14: context
def context(context, value):
"""Returns dictionary version of context"""
LOG.debug(_("Received %s"), context)
return context.to_dict()
开发者ID:anotherjesse,项目名称:nova,代码行数:4,代码来源:test_rpc.py
示例15: fake_network_get_by_cidr
def fake_network_get_by_cidr(context, cidr):
self.assertTrue(context.to_dict()["is_admin"])
self.assertEqual(cidr, self.fake_net["cidr"])
return db_fakes.FakeModel(self.fake_net)
开发者ID:hesamrahimi,项目名称:nova,代码行数:4,代码来源:test_nova_manage.py
示例16: fake_network_update
def fake_network_update(context, network_id, values):
self.assertTrue(context.to_dict()['is_admin'])
self.assertEqual(network_id, self.fake_net['id'])
self.assertEqual(values, self.fake_update_value)
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:4,代码来源:test_nova_manage.py
示例17: serialize_context
def serialize_context(self, context):
return context.to_dict()
开发者ID:BeyondTheClouds,项目名称:nova,代码行数:2,代码来源:rpc.py
示例18: fake_network_delete_safe
def fake_network_delete_safe(context, network_id):
self.assertTrue(context.to_dict()['is_admin'])
self.assertEqual(network_id, self.fake_net['id'])
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:3,代码来源:test_nova_manage.py
示例19: fake_network_get_by_uuid
def fake_network_get_by_uuid(context, uuid):
self.assertTrue(context.to_dict()["is_admin"])
self.assertEqual(uuid, self.fake_net["uuid"])
return db_fakes.FakeModel(self.fake_net)
开发者ID:hesamrahimi,项目名称:nova,代码行数:4,代码来源:test_nova_manage.py
注:本文中的nova.context.to_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论