本文整理汇总了Python中nova.db.floating_ip_get_all函数的典型用法代码示例。如果您正苦于以下问题:Python floating_ip_get_all函数的具体用法?Python floating_ip_get_all怎么用?Python floating_ip_get_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floating_ip_get_all函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: list
def list(self, host=None):
"""Lists all floating ips (optionally by host)
Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
try:
if host is None:
floating_ips = db.floating_ip_get_all(ctxt)
else:
floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
except exception.NoFloatingIpsDefined:
print _("No floating IP addresses have been defined.")
return
for floating_ip in floating_ips:
instance_id = None
if floating_ip['fixed_ip_id']:
fixed_ip = db.fixed_ip_get(ctxt, floating_ip['fixed_ip_id'])
try:
instance = db.instance_get(ctxt, fixed_ip['instance_id'])
instance_id = instance.get('uuid', "none")
except exception.InstanceNotFound:
msg = _('Missing instance %s')
instance_id = msg % fixed_ip['instance_id']
print "%s\t%s\t%s\t%s\t%s" % (floating_ip['project_id'],
floating_ip['address'],
instance_id,
floating_ip['pool'],
floating_ip['interface'])
开发者ID:pubfox,项目名称:webservices,代码行数:28,代码来源:wic_floating.py
示例2: _get_floating_ip_info
def _get_floating_ip_info(self, context, host=None):
floating_ip_info = {"floating_ip_info": []}
try:
if host is None:
floating_ips = db.floating_ip_get_all(context)
else:
floating_ips = db.floating_ip_get_all_by_host(context, host)
except exception.NoFloatingIpsDefined:
return floating_ip_info
for floating_ip in floating_ips:
instance_uuid = None
if floating_ip['fixed_ip_id']:
fixed_ip = db.fixed_ip_get(context, floating_ip['fixed_ip_id'])
instance_uuid = fixed_ip['instance_uuid']
result = {'address': floating_ip['address'],
'pool': floating_ip['pool'],
'interface': floating_ip['interface'],
'project_id': floating_ip['project_id'],
'instance_uuid': instance_uuid}
floating_ip_info['floating_ip_info'].append(result)
return floating_ip_info
开发者ID:MVillari,项目名称:nova,代码行数:25,代码来源:floating_ips_bulk.py
示例3: _get_floating_ip_info
def _get_floating_ip_info(self, context, host=None):
floating_ip_info = {"floating_ip_info": []}
if host is None:
try:
floating_ips = db.floating_ip_get_all(context)
except exception.NoFloatingIpsDefined:
return floating_ip_info
else:
try:
floating_ips = db.floating_ip_get_all_by_host(context, host)
except exception.FloatingIpNotFoundForHost as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
for floating_ip in floating_ips:
instance_uuid = None
if floating_ip['fixed_ip_id']:
fixed_ip = db.fixed_ip_get(context, floating_ip['fixed_ip_id'])
instance_uuid = fixed_ip['instance_uuid']
result = {'address': floating_ip['address'],
'pool': floating_ip['pool'],
'interface': floating_ip['interface'],
'project_id': floating_ip['project_id'],
'instance_uuid': instance_uuid}
floating_ip_info['floating_ip_info'].append(result)
return floating_ip_info
开发者ID:B-Rich,项目名称:nova-1,代码行数:28,代码来源:floating_ips_bulk.py
示例4: list
def list(self, host=None):
"""Lists all floating ips (optionally by host)
Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
try:
if host is None:
floating_ips = db.floating_ip_get_all(ctxt)
else:
floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
except exception.NoFloatingIpsDefined:
print _("No floating IP addresses have been defined.")
return
for floating_ip in floating_ips:
instance_uuid = None
if floating_ip["fixed_ip_id"]:
fixed_ip = db.fixed_ip_get(ctxt, floating_ip["fixed_ip_id"])
instance_uuid = fixed_ip["instance_uuid"]
print "%s\t%s\t%s\t%s\t%s" % (
floating_ip["project_id"],
floating_ip["address"],
instance_uuid,
floating_ip["pool"],
floating_ip["interface"],
)
开发者ID:comstud,项目名称:nova,代码行数:25,代码来源:manage.py
示例5: _get_floating_ips
def _get_floating_ips(self, context):
'''
[
{
"fixed_ip": "10.0.0.0",
"id": 2,
"instance_id": "xxx",
"ip": "10.120.32.162",
"pool": "nova",
"host": "host1",
"type": "public",
"project_id": "xxx"
}]
'''
ips = []
try:
floating_ips_refs = db.floating_ip_get_all(context)
except exception.NoFloatingIpsDefined:
return ips
for floating_ip in floating_ips_refs:
ip = self._make_floating_ip(floating_ip)
self._set_floating_ip_metadata(context, ip)
ips.append(ip)
return ips
开发者ID:xww,项目名称:nova-old,代码行数:25,代码来源:quotas_usage.py
示例6: _get_floating_ip_info
def _get_floating_ip_info(self, context, host=None):
floating_ip_info = {"floating_ip_info": []}
try:
if host is None:
floating_ips = db.floating_ip_get_all(context)
else:
floating_ips = db.floating_ip_get_all_by_host(context, host)
except exception.NoFloatingIpsDefined:
return floating_ip_info
for floating_ip in floating_ips:
instance_uuid = None
if floating_ip["fixed_ip_id"]:
fixed_ip = db.fixed_ip_get(context, floating_ip["fixed_ip_id"])
instance_uuid = fixed_ip["instance_uuid"]
result = {
"address": floating_ip["address"],
"pool": floating_ip["pool"],
"interface": floating_ip["interface"],
"project_id": floating_ip["project_id"],
"instance_uuid": instance_uuid,
}
floating_ip_info["floating_ip_info"].append(result)
return floating_ip_info
开发者ID:nobuking,项目名称:nova,代码行数:27,代码来源:floating_ips_bulk.py
示例7: test_fail_floating_ip_in_bulk_creation
def test_fail_floating_ip_in_bulk_creation(self):
self.assertRaises(exception.FloatingIpExists,
self._create_floating_ips,
[self.floating_ip, self.floating_ip_2])
all_ips = db.floating_ip_get_all(self.context)
ip_list = [ip['address'] for ip in all_ips]
self.assertIn(self.floating_ip, ip_list)
self.assertNotIn(self.floating_ip_2, ip_list)
开发者ID:a3linux,项目名称:nova,代码行数:8,代码来源:test_floating_ips.py
示例8: test_floating_ip_in_bulk_creation
def test_floating_ip_in_bulk_creation(self):
self._delete_floating_ip()
self._create_floating_ips([self.floating_ip, self.floating_ip_2])
all_ips = db.floating_ip_get_all(self.context)
ip_list = [ip['address'] for ip in all_ips]
self.assertIn(self.floating_ip, ip_list)
self.assertIn(self.floating_ip_2, ip_list)
开发者ID:a3linux,项目名称:nova,代码行数:8,代码来源:test_floating_ips.py
示例9: format_addresses
def format_addresses(self, context):
addresses = []
if context.is_admin:
iterator = db.floating_ip_get_all(context)
else:
iterator = db.floating_ip_get_all_by_project(context,
context.project_id)
for floating_ip_ref in iterator:
address = floating_ip_ref['address']
ec2_id = None
if (floating_ip_ref['fixed_ip']
and floating_ip_ref['fixed_ip']['instance']):
instance_id = floating_ip_ref['fixed_ip']['instance']['id']
ec2_id = id_to_ec2_id(instance_id)
address_rv = {'public_ip': address,
'instance_id': ec2_id}
if context.is_admin:
details = "%s (%s)" % (address_rv['instance_id'],
floating_ip_ref['project_id'])
address_rv['instance_id'] = details
addresses.append(address_rv)
return {'addressesSet': addresses}
开发者ID:yosh,项目名称:nova,代码行数:22,代码来源:cloud.py
示例10: get_all
def get_all(cls, context):
db_floatingips = db.floating_ip_get_all(context)
return obj_base.obj_make_list(context, cls(context),
objects.FloatingIP, db_floatingips)
开发者ID:EliseCheng,项目名称:nova,代码行数:4,代码来源:floating_ip.py
注:本文中的nova.db.floating_ip_get_all函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论