Merge lp:~tpatil/nova/bug839269 into lp:~hudson-openstack/nova/trunk

Proposed by Tushar Patil
Status: Merged
Approved by: Dan Prince
Approved revision: 1525
Merged at revision: 1551
Proposed branch: lp:~tpatil/nova/bug839269
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 75 lines (+15/-6)
4 files modified
nova/db/api.py (+4/-2)
nova/db/sqlalchemy/api.py (+7/-2)
nova/network/manager.py (+2/-1)
nova/tests/test_network.py (+2/-1)
To merge this branch: bzr merge lp:~tpatil/nova/bug839269
Reviewer Review Type Date Requested Status
Dan Prince (community) Approve
Brian Waldon (community) Approve
William Wolf (community) Approve
Devin Carlen (community) Approve
Review via email: mp+73879@code.launchpad.net

Commit message

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.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Looks good. Would you mind adding a docstring to fixed_ip_associate in sqlalchemy/api.py to explain that 'reserved' is the exact value that will be filtered on?

lp:~tpatil/nova/bug839269 updated
1525. By Tushar Patil

Added docstring to explain usage of reserved keyword argument

Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
William Wolf (throughnothing) wrote :

lgtm

review: Approve
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Thanks, Tushar.

review: Approve
Revision history for this message
Dan Prince (dan-prince) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/db/api.py'
--- nova/db/api.py 2011-09-08 18:47:56 +0000
+++ nova/db/api.py 2011-09-08 20:51:25 +0000
@@ -324,13 +324,15 @@
324####################324####################
325325
326326
327def fixed_ip_associate(context, address, instance_id, network_id=None):327def fixed_ip_associate(context, address, instance_id, network_id=None,
328 reserved=False):
328 """Associate fixed ip to instance.329 """Associate fixed ip to instance.
329330
330 Raises if fixed ip is not available.331 Raises if fixed ip is not available.
331332
332 """333 """
333 return IMPL.fixed_ip_associate(context, address, instance_id, network_id)334 return IMPL.fixed_ip_associate(context, address, instance_id, network_id,
335 reserved)
334336
335337
336def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):338def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
337339
=== modified file 'nova/db/sqlalchemy/api.py'
--- nova/db/sqlalchemy/api.py 2011-09-08 18:47:56 +0000
+++ nova/db/sqlalchemy/api.py 2011-09-08 20:51:25 +0000
@@ -669,14 +669,19 @@
669669
670670
671@require_admin_context671@require_admin_context
672def fixed_ip_associate(context, address, instance_id, network_id=None):672def fixed_ip_associate(context, address, instance_id, network_id=None,
673 reserved=False):
674 """Keyword arguments:
675 reserved -- should be a boolean value(True or False), exact value will be
676 used to filter on the fixed ip address
677 """
673 session = get_session()678 session = get_session()
674 with session.begin():679 with session.begin():
675 network_or_none = or_(models.FixedIp.network_id == network_id,680 network_or_none = or_(models.FixedIp.network_id == network_id,
676 models.FixedIp.network_id == None)681 models.FixedIp.network_id == None)
677 fixed_ip_ref = session.query(models.FixedIp).\682 fixed_ip_ref = session.query(models.FixedIp).\
678 filter(network_or_none).\683 filter(network_or_none).\
679 filter_by(reserved=False).\684 filter_by(reserved=reserved).\
680 filter_by(deleted=False).\685 filter_by(deleted=False).\
681 filter_by(address=address).\686 filter_by(address=address).\
682 with_lockmode('update').\687 with_lockmode('update').\
683688
=== modified file 'nova/network/manager.py'
--- nova/network/manager.py 2011-09-08 07:43:11 +0000
+++ nova/network/manager.py 2011-09-08 20:51:25 +0000
@@ -1005,7 +1005,8 @@
1005 address = network['vpn_private_address']1005 address = network['vpn_private_address']
1006 self.db.fixed_ip_associate(context,1006 self.db.fixed_ip_associate(context,
1007 address,1007 address,
1008 instance_id)1008 instance_id,
1009 reserved=True)
1009 else:1010 else:
1010 address = kwargs.get('address', None)1011 address = kwargs.get('address', None)
1011 if address:1012 if address:
10121013
=== modified file 'nova/tests/test_network.py'
--- nova/tests/test_network.py 2011-09-01 20:09:23 +0000
+++ nova/tests/test_network.py 2011-09-08 20:51:25 +0000
@@ -269,7 +269,8 @@
269269
270 db.fixed_ip_associate(mox.IgnoreArg(),270 db.fixed_ip_associate(mox.IgnoreArg(),
271 mox.IgnoreArg(),271 mox.IgnoreArg(),
272 mox.IgnoreArg()).AndReturn('192.168.0.1')272 mox.IgnoreArg(),
273 reserved=True).AndReturn('192.168.0.1')
273 db.fixed_ip_update(mox.IgnoreArg(),274 db.fixed_ip_update(mox.IgnoreArg(),
274 mox.IgnoreArg(),275 mox.IgnoreArg(),
275 mox.IgnoreArg())276 mox.IgnoreArg())