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
1=== modified file 'nova/db/api.py'
2--- nova/db/api.py 2011-09-08 18:47:56 +0000
3+++ nova/db/api.py 2011-09-08 20:51:25 +0000
4@@ -324,13 +324,15 @@
5 ####################
6
7
8-def fixed_ip_associate(context, address, instance_id, network_id=None):
9+def fixed_ip_associate(context, address, instance_id, network_id=None,
10+ reserved=False):
11 """Associate fixed ip to instance.
12
13 Raises if fixed ip is not available.
14
15 """
16- return IMPL.fixed_ip_associate(context, address, instance_id, network_id)
17+ return IMPL.fixed_ip_associate(context, address, instance_id, network_id,
18+ reserved)
19
20
21 def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
22
23=== modified file 'nova/db/sqlalchemy/api.py'
24--- nova/db/sqlalchemy/api.py 2011-09-08 18:47:56 +0000
25+++ nova/db/sqlalchemy/api.py 2011-09-08 20:51:25 +0000
26@@ -669,14 +669,19 @@
27
28
29 @require_admin_context
30-def fixed_ip_associate(context, address, instance_id, network_id=None):
31+def fixed_ip_associate(context, address, instance_id, network_id=None,
32+ reserved=False):
33+ """Keyword arguments:
34+ reserved -- should be a boolean value(True or False), exact value will be
35+ used to filter on the fixed ip address
36+ """
37 session = get_session()
38 with session.begin():
39 network_or_none = or_(models.FixedIp.network_id == network_id,
40 models.FixedIp.network_id == None)
41 fixed_ip_ref = session.query(models.FixedIp).\
42 filter(network_or_none).\
43- filter_by(reserved=False).\
44+ filter_by(reserved=reserved).\
45 filter_by(deleted=False).\
46 filter_by(address=address).\
47 with_lockmode('update').\
48
49=== modified file 'nova/network/manager.py'
50--- nova/network/manager.py 2011-09-08 07:43:11 +0000
51+++ nova/network/manager.py 2011-09-08 20:51:25 +0000
52@@ -1005,7 +1005,8 @@
53 address = network['vpn_private_address']
54 self.db.fixed_ip_associate(context,
55 address,
56- instance_id)
57+ instance_id,
58+ reserved=True)
59 else:
60 address = kwargs.get('address', None)
61 if address:
62
63=== modified file 'nova/tests/test_network.py'
64--- nova/tests/test_network.py 2011-09-01 20:09:23 +0000
65+++ nova/tests/test_network.py 2011-09-08 20:51:25 +0000
66@@ -269,7 +269,8 @@
67
68 db.fixed_ip_associate(mox.IgnoreArg(),
69 mox.IgnoreArg(),
70- mox.IgnoreArg()).AndReturn('192.168.0.1')
71+ mox.IgnoreArg(),
72+ reserved=True).AndReturn('192.168.0.1')
73 db.fixed_ip_update(mox.IgnoreArg(),
74 mox.IgnoreArg(),
75 mox.IgnoreArg())