本文整理汇总了Python中nova.db.floating_ip_create函数的典型用法代码示例。如果您正苦于以下问题:Python floating_ip_create函数的具体用法?Python floating_ip_create怎么用?Python floating_ip_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floating_ip_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: _create_floating_ip
def _create_floating_ip(self):
"""Create a floating ip object."""
host = "fake_host"
db.floating_ip_create(self.context,
{'address': test_ipv4_address,
'host': host})
db.floating_ip_create(self.context,
{'address': test_ipv6_address,
'host': host})
开发者ID:cotyb,项目名称:nova,代码行数:9,代码来源:test_floating_ip_dns.py
示例3: test_too_many_addresses
def test_too_many_addresses(self):
address = '192.168.0.100'
db.floating_ip_create(context.get_admin_context(),
{'address': address,
'project_id': self.project_id})
self.assertRaises(quota.QuotaError,
self.network.allocate_floating_ip,
self.context,
self.project_id)
db.floating_ip_destroy(context.get_admin_context(), address)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:10,代码来源:test_quota.py
示例4: test_too_many_addresses
def test_too_many_addresses(self):
address = "192.168.0.100"
db.floating_ip_create(context.get_admin_context(), {"address": address, "host": FLAGS.host})
float_addr = self.network.allocate_floating_ip(self.context, self.project.id)
# NOTE(vish): This assert never fails. When cloud attempts to
# make an rpc.call, the test just finishes with OK. It
# appears to be something in the magic inline callbacks
# that is breaking.
self.assertRaises(quota.QuotaError, network.API().allocate_floating_ip, self.context)
db.floating_ip_destroy(context.get_admin_context(), address)
开发者ID:superstack,项目名称:nova,代码行数:10,代码来源:test_quota.py
示例5: test_describe_addresses
def test_describe_addresses(self):
"""Makes sure describe addresses runs without raising an exception"""
address = "10.10.10.10"
db.floating_ip_create(self.context,
{'address': address,
'host': self.network.host})
self.cloud.allocate_address(self.context)
self.cloud.describe_addresses(self.context)
self.cloud.release_address(self.context,
public_ip=address)
greenthread.sleep(0.3)
db.floating_ip_destroy(self.context, address)
开发者ID:yosh,项目名称:nova,代码行数:12,代码来源:test_cloud.py
示例6: create
def create(self, ip_range, pool=None, interface=None):
"""Creates floating ips for zone by range"""
admin_context = context.get_admin_context()
if not pool:
pool = FLAGS.default_floating_pool
if not interface:
interface = FLAGS.public_interface
for address in self.address_to_hosts(ip_range):
db.floating_ip_create(admin_context,
{'address': str(address),
'pool': pool,
'interface': interface})
开发者ID:pubfox,项目名称:webservices,代码行数:12,代码来源:wic_floating.py
示例7: _create_floating_ip
def _create_floating_ip(self):
"""Create a floating ip object."""
host = "fake_host"
return db.floating_ip_create(self.context,
{'address': self.floating_ip,
'pool': 'nova',
'host': host})
开发者ID:A7Zulu,项目名称:nova,代码行数:7,代码来源:test_floating_ips.py
示例8: _setup_networking
def _setup_networking(instance_id, ip="1.2.3.4", flo_addr="1.2.1.2"):
ctxt = context.get_admin_context()
network_ref = db.project_get_networks(ctxt, "fake", associate=True)[0]
vif = {"address": "56:12:12:12:12:12", "network_id": network_ref["id"], "instance_id": instance_id}
vif_ref = db.virtual_interface_create(ctxt, vif)
fixed_ip = {
"address": ip,
"network_id": network_ref["id"],
"virtual_interface_id": vif_ref["id"],
"allocated": True,
"instance_id": instance_id,
}
db.fixed_ip_create(ctxt, fixed_ip)
fix_ref = db.fixed_ip_get_by_address(ctxt, ip)
db.floating_ip_create(ctxt, {"address": flo_addr, "fixed_ip_id": fix_ref["id"]})
开发者ID:hiteshwadekar,项目名称:nova,代码行数:16,代码来源:test_db_api.py
示例9: test_ip_association_and_allocation_of_other_project
def test_ip_association_and_allocation_of_other_project(self):
"""Makes sure that we cannot deallocaate or disassociate
a public ip of other project"""
context1 = context.RequestContext("user", "project1")
context2 = context.RequestContext("user", "project2")
address = "1.2.3.4"
float_addr = db.floating_ip_create(context1.elevated(), {"address": address, "project_id": context1.project_id})
instance = db.instance_create(context1, {"project_id": "project1"})
fix_addr = db.fixed_ip_associate_pool(context1.elevated(), 1, instance["id"])
# Associate the IP with non-admin user context
self.assertRaises(exception.NotAuthorized, self.network.associate_floating_ip, context2, float_addr, fix_addr)
# Deallocate address from other project
self.assertRaises(exception.NotAuthorized, self.network.deallocate_floating_ip, context2, float_addr)
# Now Associates the address to the actual project
self.network.associate_floating_ip(context1, float_addr, fix_addr)
# Now try dis-associating from other project
self.assertRaises(exception.NotAuthorized, self.network.disassociate_floating_ip, context2, float_addr)
# Clean up the ip addresses
self.network.deallocate_floating_ip(context1, float_addr)
self.network.deallocate_fixed_ip(context1, fix_addr)
db.floating_ip_destroy(context1.elevated(), float_addr)
db.fixed_ip_disassociate(context1.elevated(), fix_addr)
开发者ID:nicoleLiu,项目名称:nova,代码行数:31,代码来源:test_network.py
示例10: _setup_networking
def _setup_networking(instance_id, ip='1.2.3.4', flo_addr='1.2.1.2'):
ctxt = context.get_admin_context()
network_ref = db.project_get_networks(ctxt,
'fake',
associate=True)[0]
vif = {'address': '56:12:12:12:12:12',
'network_id': network_ref['id'],
'instance_id': instance_id}
vif_ref = db.virtual_interface_create(ctxt, vif)
fixed_ip = {'address': ip,
'network_id': network_ref['id'],
'virtual_interface_id': vif_ref['id'],
'allocated': True,
'instance_id': instance_id}
db.fixed_ip_create(ctxt, fixed_ip)
fix_ref = db.fixed_ip_get_by_address(ctxt, ip)
db.floating_ip_create(ctxt, {'address': flo_addr,
'fixed_ip_id': fix_ref['id']})
开发者ID:matiu2,项目名称:nova,代码行数:19,代码来源:test_db_api.py
示例11: test_associate_disassociate_address
def test_associate_disassociate_address(self):
"""Verifies associate runs cleanly without raising an exception"""
address = "10.10.10.10"
db.floating_ip_create(self.context,
{'address': address,
'host': self.network.host})
self.cloud.allocate_address(self.context)
inst = db.instance_create(self.context, {'host': self.compute.host})
fixed = self.network.allocate_fixed_ip(self.context, inst['id'])
ec2_id = cloud.id_to_ec2_id(inst['id'])
self.cloud.associate_address(self.context,
instance_id=ec2_id,
public_ip=address)
greenthread.sleep(0.3)
self.cloud.disassociate_address(self.context,
public_ip=address)
self.cloud.release_address(self.context,
public_ip=address)
greenthread.sleep(0.3)
self.network.deallocate_fixed_ip(self.context, fixed)
db.instance_destroy(self.context, inst['id'])
db.floating_ip_destroy(self.context, address)
开发者ID:yosh,项目名称:nova,代码行数:22,代码来源:test_cloud.py
示例12: test_post_live_migration_working_correctly
def test_post_live_migration_working_correctly(self):
"""Confirm post_live_migration() works as expected correctly."""
dest = 'desthost'
flo_addr = '1.2.1.2'
# Preparing datas
c = context.get_admin_context()
instance_id = self._create_instance()
i_ref = db.instance_get(c, instance_id)
db.instance_update(c, i_ref['id'], {'state_description': 'migrating',
'state': power_state.PAUSED})
v_ref = db.volume_create(c, {'size': 1, 'instance_id': instance_id})
fix_addr = db.fixed_ip_create(c, {'address': '1.1.1.1',
'instance_id': instance_id})
fix_ref = db.fixed_ip_get_by_address(c, fix_addr)
flo_ref = db.floating_ip_create(c, {'address': flo_addr,
'fixed_ip_id': fix_ref['id']})
# reload is necessary before setting mocks
i_ref = db.instance_get(c, instance_id)
# Preparing mocks
self.mox.StubOutWithMock(self.compute.volume_manager,
'remove_compute_volume')
for v in i_ref['volumes']:
self.compute.volume_manager.remove_compute_volume(c, v['id'])
self.mox.StubOutWithMock(self.compute.driver, 'unfilter_instance')
self.compute.driver.unfilter_instance(i_ref, [])
# executing
self.mox.ReplayAll()
ret = self.compute.post_live_migration(c, i_ref, dest)
# make sure every data is rewritten to dest
i_ref = db.instance_get(c, i_ref['id'])
c1 = (i_ref['host'] == dest)
flo_refs = db.floating_ip_get_all_by_host(c, dest)
c2 = (len(flo_refs) != 0 and flo_refs[0]['address'] == flo_addr)
# post operaton
self.assertTrue(c1 and c2)
db.instance_destroy(c, instance_id)
db.volume_destroy(c, v_ref['id'])
db.floating_ip_destroy(c, flo_addr)
开发者ID:cp16net,项目名称:reddwarf,代码行数:43,代码来源:test_compute.py
示例13: test_get_counters_not_empty
def test_get_counters_not_empty(self):
db.floating_ip_create(self.context,
{'address': '1.1.1.1',
'host': self.manager.host,
})
db.floating_ip_create(self.context,
{'address': '1.1.1.2',
'host': self.manager.host + "randomstring",
})
db.floating_ip_create(self.context,
{'address': '1.1.1.3',
'host': self.manager.host + "randomstring",
})
counters = list(self.pollster.get_counters(self.manager, self.context))
self.assertEqual(len(counters), 1)
self.assertEqual(counters[0].resource_metadata['address'], '1.1.1.1')
开发者ID:mfus,项目名称:ceilometer,代码行数:16,代码来源:test_network.py
示例14: _create_floating_ip
def _create_floating_ip(self):
"""Create a floating ip object."""
host = "fake_host"
return db.floating_ip_create(self.context, {"address": self.floating_ip, "pool": "nova", "host": host})
开发者ID:nati,项目名称:nova,代码行数:4,代码来源:test_floating_ips.py
示例15: test_too_many_addresses
def test_too_many_addresses(self):
address = "192.168.0.100"
db.floating_ip_create(context.get_admin_context(), {"address": address, "project_id": self.project_id})
self.assertRaises(exception.QuotaError, self.network.allocate_floating_ip, self.context, self.project_id)
db.floating_ip_destroy(context.get_admin_context(), address)
开发者ID:renuka-apte,项目名称:nova,代码行数:5,代码来源:test_quota.py
注:本文中的nova.db.floating_ip_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论