Skip to content

Commit

Permalink
Stub additional FloatingIP methods in FlatManager
Browse files Browse the repository at this point in the history
Fixes bug #989746.

Added some stub methods for floating ip allocation in FlatManager in
order to prevent exceptions from being raised when they are called.

Changed get_floating_ip_by_address() in FlatManager to return a dict
with expected keys for a floating ip, rather than None.

Updated patch from Andrew Laski and added unit tests.

Change-Id: I4ee1f5cf986b6f3411605aae5c1bc4e8cc2377b1
  • Loading branch information
fredericlepied committed Feb 13, 2013
1 parent 635fadd commit 5640dab
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
31 changes: 31 additions & 0 deletions nova/network/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,37 @@ def get_floating_ips_by_fixed_address(self, context, fixed_address):
# we major version the network_rpcapi to 2.0.
return []

@network_api.wrap_check_policy
def allocate_floating_ip(self, context, project_id, pool):
"""Gets a floating ip from the pool."""
return None

@network_api.wrap_check_policy
def deallocate_floating_ip(self, context, address,
affect_auto_assigned):
"""Returns a floating ip to the pool."""
return None

@network_api.wrap_check_policy
def associate_floating_ip(self, context, floating_address, fixed_address,
affect_auto_assigned=False):
"""Associates a floating ip with a fixed ip.
Makes sure everything makes sense then calls _associate_floating_ip,
rpc'ing to correct host if i'm not it.
"""
return None

@network_api.wrap_check_policy
def disassociate_floating_ip(self, context, address,
affect_auto_assigned=False):
"""Disassociates a floating ip from its fixed ip.
Makes sure everything makes sense then calls _disassociate_floating_ip,
rpc'ing to correct host if i'm not it.
"""
return None

def migrate_instance_start(self, context, instance_uuid,
floating_addresses,
rxtx_factor=None, project_id=None,
Expand Down
17 changes: 17 additions & 0 deletions nova/tests/network/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,23 @@ def test_instance_dns(self):
self.assertEqual(len(addresses), 1)
self.assertEqual(addresses[0], fixedip)

def test_allocate_floating_ip(self):
self.assertEqual(self.network.allocate_floating_ip(self.context,
1, None), None)

def test_deallocate_floating_ip(self):
self.assertEqual(self.network.deallocate_floating_ip(self.context,
1, None), None)

def test_associate_floating_ip(self):
self.assertEqual(self.network.associate_floating_ip(self.context,
None, None), None)

def test_disassociate_floating_ip(self):
self.assertEqual(self.network.disassociate_floating_ip(self.context,
None, None),
None)


class VlanNetworkTestCase(test.TestCase):
def setUp(self):
Expand Down

0 comments on commit 5640dab

Please sign in to comment.