本文整理汇总了Python中nova.db.fixed_ip_associate_pool函数的典型用法代码示例。如果您正苦于以下问题:Python fixed_ip_associate_pool函数的具体用法?Python fixed_ip_associate_pool怎么用?Python fixed_ip_associate_pool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fixed_ip_associate_pool函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_instance_dns
def test_instance_dns(self):
fixedip = '192.168.0.101'
self.mox.StubOutWithMock(db, 'network_get')
self.mox.StubOutWithMock(db, 'network_update')
self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
self.mox.StubOutWithMock(db, 'instance_get')
self.mox.StubOutWithMock(db,
'virtual_interface_get_by_instance_and_network')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
db.fixed_ip_update(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
db.instance_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn({'security_groups':
[{'id': 0}]})
db.instance_get(self.context,
1).AndReturn({'display_name': HOST})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(fixedip)
db.network_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(networks[0])
db.network_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
self.mox.ReplayAll()
self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
networks[0]['id'])
addresses = self.network.instance_dns_manager.get_entries_by_name(HOST)
self.assertEqual(len(addresses), 1)
self.assertEqual(addresses[0], fixedip)
开发者ID:swapniltamse,项目名称:nova,代码行数:34,代码来源:test_network.py
示例2: test_add_fixed_ip_instance_without_vpn_requested_networks
def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
self.mox.StubOutWithMock(db, 'network_get')
self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
self.mox.StubOutWithMock(db, 'instance_get')
self.mox.StubOutWithMock(db,
'virtual_interface_get_by_instance_and_network')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
db.fixed_ip_update(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
db.instance_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn({'security_groups':
[{'id': 0}]})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn('192.168.0.101')
db.network_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(networks[0])
self.mox.ReplayAll()
self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
networks[0]['id'])
开发者ID:CaptTofu,项目名称:reddwarf,代码行数:25,代码来源:test_network.py
示例3: test_allocate_fixed_ip
def test_allocate_fixed_ip(self):
self.mox.StubOutWithMock(db, "fixed_ip_associate_pool")
self.mox.StubOutWithMock(db, "fixed_ip_update")
self.mox.StubOutWithMock(db, "virtual_interface_get_by_instance_and_network")
db.fixed_ip_associate_pool(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn("192.168.0.1")
db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
{"id": 0}
)
self.mox.ReplayAll()
network = dict(networks[0])
network["vpn_private_address"] = "192.168.0.2"
self.network.allocate_fixed_ip(None, 0, network)
开发者ID:kavanista,项目名称:nova,代码行数:15,代码来源:test_network.py
示例4: associate_pool
def associate_pool(cls, context, network_id, instance_uuid=None,
host=None, vif_id=None):
db_fixedip = db.fixed_ip_associate_pool(context, network_id,
instance_uuid=instance_uuid,
host=host,
virtual_interface_id=vif_id)
return cls._from_db_object(context, cls(context), db_fixedip)
开发者ID:375670450,项目名称:nova,代码行数:7,代码来源:fixed_ip.py
示例5: 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
示例6: test_add_fixed_ip_instance_without_vpn_requested_networks
def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
self.mox.StubOutWithMock(db, "network_get")
self.mox.StubOutWithMock(db, "fixed_ip_associate_pool")
self.mox.StubOutWithMock(db, "instance_get")
self.mox.StubOutWithMock(db, "virtual_interface_get_by_instance_and_network")
self.mox.StubOutWithMock(db, "fixed_ip_update")
db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
{"id": 0}
)
db.instance_get(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({"security_groups": [{"id": 0}]})
db.fixed_ip_associate_pool(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn("192.168.0.101")
db.network_get(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(networks[0])
self.mox.ReplayAll()
self.network.add_fixed_ip_to_instance(self.context, 1, HOST, networks[0]["id"])
开发者ID:nicoleLiu,项目名称:nova,代码行数:17,代码来源:test_network.py
示例7: test_allocate_fixed_ip
def test_allocate_fixed_ip(self):
self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
self.mox.StubOutWithMock(db,
'virtual_interface_get_by_instance_and_network')
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn('192.168.0.1')
db.fixed_ip_update(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
self.mox.ReplayAll()
network = dict(networks[0])
network['vpn_private_address'] = '192.168.0.2'
self.network.allocate_fixed_ip(None, 0, network)
开发者ID:lovocas,项目名称:nova,代码行数:19,代码来源:test_network.py
示例8: allocate_fixed_ips
def allocate_fixed_ips(self, context, tenant_id, quantum_net_id, network_tenant_id, vif_rec):
"""Allocates a single fixed IPv4 address for a virtual interface."""
admin_context = context.elevated()
network = db.network_get_by_uuid(admin_context, quantum_net_id)
address = None
if network["cidr"]:
address = db.fixed_ip_associate_pool(admin_context, network["id"], vif_rec["instance_id"])
values = {"allocated": True, "virtual_interface_id": vif_rec["id"]}
db.fixed_ip_update(admin_context, address, values)
return [address]
开发者ID:pknouff,项目名称:nova,代码行数:10,代码来源:nova_ipam_lib.py
示例9: allocate_fixed_ip
def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
"""Allocates a single fixed IPv4 address for a virtual interface."""
admin_context = context.elevated()
network = db.network_get_by_uuid(admin_context, quantum_net_id)
if network['cidr']:
address = db.fixed_ip_associate_pool(admin_context,
network['id'],
vif_rec['instance_id'])
values = {'allocated': True,
'virtual_interface_id': vif_rec['id']}
db.fixed_ip_update(admin_context, address, values)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:11,代码来源:nova_ipam_lib.py
示例10: associate_pool
def associate_pool(cls, context, network_id, instance_uuid=None, host=None):
db_fixedip = db.fixed_ip_associate_pool(context, network_id, instance_uuid=instance_uuid, host=host)
return cls._from_db_object(context, cls(), db_fixedip)
开发者ID:wputra,项目名称:MOS-centos,代码行数:3,代码来源:fixed_ip.py
注:本文中的nova.db.fixed_ip_associate_pool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论