diff options
| author | Tushar Patil <tushar.vitthal.patil@gmail.com> | 2011-09-12 02:11:43 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-09-12 02:11:43 +0000 |
| commit | 020d4e735977ffa4f632500f7b977c64721861e9 (patch) | |
| tree | 9436dc049ca68209847b03007f1094b70135764d /nova | |
| parent | e587fc09545eebe71b9d3bd9ed5d7fe62424a8a6 (diff) | |
| parent | 7e96a2d7c5f2ac8572c6d0fd20e4e8c7e146dce9 (diff) | |
When vpn=true in allocate ip, it attempts to allocate the ip that is reserved in the network. Unfortunately fixed_ip_associate attempts to ignore reserved ips.
This fix allows to filter reserved ip address only when vpn=True.
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/db/api.py | 6 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 9 | ||||
| -rw-r--r-- | nova/network/manager.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_network.py | 3 |
4 files changed, 15 insertions, 6 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index c03a86671..a9d2dc065 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -324,13 +324,15 @@ def migration_get_by_instance_and_status(context, instance_uuid, status): #################### -def fixed_ip_associate(context, address, instance_id, network_id=None): +def fixed_ip_associate(context, address, instance_id, network_id=None, + reserved=False): """Associate fixed ip to instance. Raises if fixed ip is not available. """ - return IMPL.fixed_ip_associate(context, address, instance_id, network_id) + return IMPL.fixed_ip_associate(context, address, instance_id, network_id, + reserved) def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 523258841..40e2ca167 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -669,14 +669,19 @@ def floating_ip_update(context, address, values): @require_admin_context -def fixed_ip_associate(context, address, instance_id, network_id=None): +def fixed_ip_associate(context, address, instance_id, network_id=None, + reserved=False): + """Keyword arguments: + reserved -- should be a boolean value(True or False), exact value will be + used to filter on the fixed ip address + """ session = get_session() with session.begin(): network_or_none = or_(models.FixedIp.network_id == network_id, models.FixedIp.network_id == None) fixed_ip_ref = session.query(models.FixedIp).\ filter(network_or_none).\ - filter_by(reserved=False).\ + filter_by(reserved=reserved).\ filter_by(deleted=False).\ filter_by(address=address).\ with_lockmode('update').\ diff --git a/nova/network/manager.py b/nova/network/manager.py index 05d928fab..da360720b 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -1005,7 +1005,8 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager): address = network['vpn_private_address'] self.db.fixed_ip_associate(context, address, - instance_id) + instance_id, + reserved=True) else: address = kwargs.get('address', None) if address: diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index c947bbc58..926ea065a 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -286,7 +286,8 @@ class VlanNetworkTestCase(test.TestCase): db.fixed_ip_associate(mox.IgnoreArg(), mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn('192.168.0.1') + mox.IgnoreArg(), + reserved=True).AndReturn('192.168.0.1') db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) |
