本文整理汇总了Python中nova.db.floating_ip_get_by_address函数的典型用法代码示例。如果您正苦于以下问题:Python floating_ip_get_by_address函数的具体用法?Python floating_ip_get_by_address怎么用?Python floating_ip_get_by_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floating_ip_get_by_address函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_public_network_association
def test_public_network_association(self):
"""Makes sure that we can allocaate a public ip"""
# TODO(vish): better way of adding floating ips
self.context._project = self.projects[0]
self.context.project_id = self.projects[0].id
pubnet = IPy.IP(flags.FLAGS.floating_range)
address = str(pubnet[0])
try:
db.floating_ip_get_by_address(context.get_admin_context(), address)
except exception.NotFound:
db.floating_ip_create(context.get_admin_context(),
{'address': address,
'host': FLAGS.host})
float_addr = self.network.allocate_floating_ip(self.context,
self.projects[0].id)
fix_addr = self._create_address(0)
lease_ip(fix_addr)
self.assertEqual(float_addr, str(pubnet[0]))
self.network.associate_floating_ip(self.context, float_addr, fix_addr)
address = db.instance_get_floating_address(context.get_admin_context(),
self.instance_id)
self.assertEqual(address, float_addr)
self.network.disassociate_floating_ip(self.context, float_addr)
address = db.instance_get_floating_address(context.get_admin_context(),
self.instance_id)
self.assertEqual(address, None)
self.network.deallocate_floating_ip(self.context, float_addr)
self.network.deallocate_fixed_ip(self.context, fix_addr)
release_ip(fix_addr)
db.floating_ip_destroy(context.get_admin_context(), float_addr)
开发者ID:anotherjesse,项目名称:nova,代码行数:30,代码来源:test_network.py
示例2: test_translate_floating_ip_view
def test_translate_floating_ip_view(self):
floating_ip_address = self._create_floating_ip()
floating_ip = db.floating_ip_get_by_address(self.context, floating_ip_address)
view = floating_ips._translate_floating_ip_view(floating_ip)
self.assertTrue("floating_ip" in view)
self.assertTrue(view["floating_ip"]["id"])
self.assertEqual(view["floating_ip"]["ip"], self.address)
self.assertEqual(view["floating_ip"]["fixed_ip"], None)
self.assertEqual(view["floating_ip"]["instance_id"], None)
开发者ID:nicoleLiu,项目名称:nova,代码行数:9,代码来源:test_floating_ips.py
示例3: test_translate_floating_ip_view
def test_translate_floating_ip_view(self):
floating_ip_address = self._create_floating_ip()
floating_ip = db.floating_ip_get_by_address(self.context,
floating_ip_address)
view = _translate_floating_ip_view(floating_ip)
self.assertTrue('floating_ip' in view)
self.assertTrue(view['floating_ip']['id'])
self.assertEqual(view['floating_ip']['ip'], self.address)
self.assertEqual(view['floating_ip']['fixed_ip'], None)
self.assertEqual(view['floating_ip']['instance_id'], None)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:10,代码来源:test_floating_ips.py
示例4: test_translate_floating_ip_view
def test_translate_floating_ip_view(self):
floating_ip_address = self.floating_ip
floating_ip = db.floating_ip_get_by_address(self.context, floating_ip_address)
# NOTE(vish): network_get uses the id not the address
floating_ip = db.floating_ip_get(self.context, floating_ip["id"])
view = self.floating_ips._translate_floating_ip_view(floating_ip)
self.assertIn("floating_ip", view)
self.assertTrue(view["floating_ip"]["id"])
self.assertEqual(view["floating_ip"]["ip"], self.floating_ip)
self.assertIsNone(view["floating_ip"]["fixed_ip"])
self.assertIsNone(view["floating_ip"]["instance_id"])
开发者ID:isyippee,项目名称:nova,代码行数:11,代码来源:test_floating_ips.py
示例5: test_translate_floating_ip_view
def test_translate_floating_ip_view(self):
floating_ip_address = self.floating_ip
floating_ip = db.floating_ip_get_by_address(self.context,
floating_ip_address)
floating_ip['fixed_ip'] = None
floating_ip['instance'] = None
view = floating_ips_search._translate_floating_ip_view(floating_ip)
self.assertTrue('floating_ip' in view)
self.assertTrue(view['floating_ip']['id'])
self.assertEqual(view['floating_ip']['ip'], self.floating_ip)
self.assertEqual(view['floating_ip']['fixed_ip'], None)
self.assertEqual(view['floating_ip']['instance_id'], None)
开发者ID:xww,项目名称:nova-old,代码行数:12,代码来源:test_floating_ips_search.py
示例6: test_translate_floating_ip_view
def test_translate_floating_ip_view(self):
floating_ip_address = self.floating_ip
floating_ip = db.floating_ip_get_by_address(self.context,
floating_ip_address)
# NOTE(vish): network_get uses the id not the address
floating_ip = db.floating_ip_get(self.context, floating_ip['id'])
self.controller._normalize_ip(floating_ip)
view = floating_ips._translate_floating_ip_view(floating_ip)
self.assertTrue('floating_ip' in view)
self.assertTrue(view['floating_ip']['id'])
self.assertEqual(view['floating_ip']['ip'], self.floating_ip)
self.assertEqual(view['floating_ip']['fixed_ip'], None)
self.assertEqual(view['floating_ip']['instance_id'], None)
开发者ID:AnyBucket,项目名称:nova,代码行数:13,代码来源:test_floating_ips.py
示例7: get_by_address
def get_by_address(cls, context, address):
db_floatingip = db.floating_ip_get_by_address(context, str(address))
return cls._from_db_object(context, cls(context), db_floatingip)
开发者ID:EliseCheng,项目名称:nova,代码行数:3,代码来源:floating_ip.py
示例8: index
def index(self, req):
"""Return all flavors in brief."""
#flavors = self._get_flavors(req)
#return self._view_builder.index(req, flavors)
project_id=str(req.environ['HTTP_X_TENANT_ID'])
context = req.environ['nova.context']
context = context.elevated()
networks = db.network_get_all(context)
nets=[dict(network.iteritems()) for network in networks]
virtual_interfaces = db.virtual_interface_get_all(context)
vifs=[dict(vif.iteritems()) for vif in virtual_interfaces]
#make a dict of relationships between Network_IDs and Instance_IDs {1:[1,2],...}
net_vm_dict = {}
for vif in vifs:
net_id=int(vif['network_id'])
vm_id=int(vif['instance_id'])
if net_id in net_vm_dict:
net_vm_dict[net_id].append(vm_id)
else:
net_vm_dict[net_id] = [vm_id]
print net_vm_dict
#Go through the dict , filter by this project and get detailed infos
#instance_get(context, instance_id)
net_list = []
for netID in net_vm_dict:
networks= db.network_get(context, netID)
net = dict(networks.iteritems())
print str(net['project_id'])
if net['project_id']==None or net['project_id']==project_id:
print "my precious~~"
net_info = {}
net_info['id']=str(net['uuid'])
net_info['name']=str(net['label'])
net_info['cidr']=str(net['cidr'])
net_info['vm']=[]
net_list.append(net_info)
for vmID in net_vm_dict[netID]:
vms = db.instance_get(context, vmID)
vm = dict(vms.iteritems())
if vm['project_id']==project_id:
print "My VM"
vm_info = {}
#Get vm infos for each VM
vm_info['name']=str(vm['hostname'])
vm_info['id']=str(vm['uuid'])
vm_info['vm_state']=str(vm['vm_state'])
#Get fixed_ips for each VM
fixed_ips = db.fixed_ip_get_by_instance(context, vmID)
fixed_ip_info = []
for ip in fixed_ips:
fixed_ip_info.append(str(dict(ip.iteritems())['address']))
vm_info['fixed_ips'] = fixed_ip_info
#Get Floating_ips for each VM
floating_ip_info = []
for fixed_ip in fixed_ip_info:
try:
floating_ips = db.floating_ip_get_by_address(context, fixed_ip)
except exception.FloatingIpNotFoundForAddress:
print "floating not found"
continue
if floating_ips != None:
for floating_ip in floating_ips:
floating_ip_info.append(str(dict(ip.floating_ip.iteritems()['address'])))
vm_info['floating_ips']=floating_ip_info
net_info['vm'].append(vm_info)
ret_net_list={}
ret_net_list['networks']=net_list
print ret_net_list
return ret_net_list
开发者ID:HolySparky,项目名称:Openstack-NetworkAPI,代码行数:75,代码来源:networks.py
注:本文中的nova.db.floating_ip_get_by_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论