Merge lp:~vishvananda/nova/dhcplease-flags into lp:~hudson-openstack/nova/trunk

Proposed by Joshua McKenty
Status: Merged
Approved by: Monty Taylor
Approved revision: 143
Merged at revision: 150
Proposed branch: lp:~vishvananda/nova/dhcplease-flags
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 247 lines (+50/-34)
10 files modified
bin/nova-dhcpbridge (+17/-12)
debian/nova-api.conf (+2/-1)
debian/nova-api.install (+1/-0)
debian/nova-compute.conf (+0/-2)
debian/nova-dhcp.conf (+2/-0)
debian/nova-objectstore.conf (+0/-1)
debian/nova-volume.conf (+0/-1)
nova/compute/linux_net.py (+11/-5)
nova/compute/network.py (+3/-3)
nova/tests/network_unittest.py (+14/-9)
To merge this branch: bzr merge lp:~vishvananda/nova/dhcplease-flags
Reviewer Review Type Date Requested Status
Monty Taylor (community) Needs Fixing
Joshua McKenty (community) Approve
Review via email: mp+30142@code.launchpad.net

Commit message

Fixes to dhcp lease code to use a flagfile

Description of the change

Already reviewed against soren's branch.

To post a comment you must log in.
Revision history for this message
Joshua McKenty (joshua-mckenty) wrote :

Reviewed this against soren's branch already.

review: Approve
Revision history for this message
Monty Taylor (mordred) wrote :

Needs to be merged with trunk. There is currently an unresolved merge conflict.

review: Needs Fixing
Revision history for this message
Joshua McKenty (joshua-mckenty) wrote :

> Needs to be merged with trunk. There is currently an unresolved merge
> conflict.

Looks resolved to me, am I missing something?

Revision history for this message
Soren Hansen (soren) wrote :

When attempting the merge, I get a conflict in nova/compute/linux_net.py. Fix that, and I'll approve the merge.

lp:~vishvananda/nova/dhcplease-flags updated
143. By Vish Ishaya

merged trunk

Revision history for this message
Vish Ishaya (vishvananda) wrote :

fixed again

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'bin/dhcpleasor.py' => 'bin/nova-dhcpbridge'
2--- bin/dhcpleasor.py 2010-07-15 23:13:48 +0000
3+++ bin/nova-dhcpbridge 2010-07-19 19:46:42 +0000
4@@ -18,23 +18,27 @@
5 # under the License.
6
7 """
8-dhcpleasor.py
9+nova-dhcpbridge
10
11 Handle lease database updates from DHCP servers.
12 """
13
14+import logging
15+import os
16 import sys
17-import os
18-import logging
19+
20+#TODO(joshua): there is concern that the user dnsmasq runs under will not
21+# have nova in the path. This should be verified and if it is
22+# not true the ugly line below can be removed
23 sys.path.append(os.path.abspath(os.path.join(__file__, "../../")))
24
25-logging.debug(sys.path)
26-import getopt
27-from os import environ
28+from nova import flags
29 from nova import rpc
30-from nova import flags
31+from nova import utils
32 from nova.compute import linux_net
33 from nova.compute import network
34+
35+
36 FLAGS = flags.FLAGS
37
38
39@@ -63,11 +67,12 @@
40 return res
41
42
43-def main(argv=None):
44- if argv is None:
45- argv = sys.argv
46- interface = environ.get('DNSMASQ_INTERFACE', 'br0')
47- if int(environ.get('TESTING', '0')):
48+def main():
49+ flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile)
50+ utils.default_flagfile(flagfile)
51+ argv = FLAGS(sys.argv)
52+ interface = os.environ.get('DNSMASQ_INTERFACE', 'br0')
53+ if int(os.environ.get('TESTING', '0')):
54 FLAGS.fake_rabbit = True
55 FLAGS.redis_db = 8
56 FLAGS.network_size = 32
57
58=== modified file 'debian/nova-api.conf'
59--- debian/nova-api.conf 2010-07-05 13:37:52 +0000
60+++ debian/nova-api.conf 2010-07-19 19:46:42 +0000
61@@ -1,5 +1,6 @@
62 --daemonize=1
63 --ca_path=/var/lib/nova/CA
64 --keys_path=/var/lib/nova/keys
65+--networks_path=/var/lib/nova/networks
66+--dhcpbridge_flagfile=/etc/nova/nova-dhcpbridge.conf
67 --fake_users=1
68---datastore_path=/var/lib/nova/keeper
69
70=== modified file 'debian/nova-api.install'
71--- debian/nova-api.install 2010-07-12 15:39:01 +0000
72+++ debian/nova-api.install 2010-07-19 19:46:42 +0000
73@@ -1,2 +1,3 @@
74 bin/nova-api usr/bin
75 debian/nova-api.conf etc/nova
76+debian/nova-dhcpbridge.conf etc/nova
77
78=== modified file 'debian/nova-compute.conf'
79--- debian/nova-compute.conf 2010-07-14 23:48:05 +0000
80+++ debian/nova-compute.conf 2010-07-19 19:46:42 +0000
81@@ -1,8 +1,6 @@
82 --ca_path=/var/lib/nova/CA
83 --keys_path=/var/lib/nova/keys
84---datastore_path=/var/lib/nova/keeper
85 --instances_path=/var/lib/nova/instances
86---networks_path=/var/lib/nova/networks
87 --simple_network_template=/usr/share/nova/interfaces.template
88 --libvirt_xml_template=/usr/share/nova/libvirt.xml.template
89 --vpn_client_template=/usr/share/nova/client.ovpn.template
90
91=== added file 'debian/nova-dhcp.conf'
92--- debian/nova-dhcp.conf 1970-01-01 00:00:00 +0000
93+++ debian/nova-dhcp.conf 2010-07-19 19:46:42 +0000
94@@ -0,0 +1,2 @@
95+--networks_path=/var/lib/nova/networks
96+--fake_users=1
97
98=== modified file 'debian/nova-objectstore.conf'
99--- debian/nova-objectstore.conf 2010-07-05 13:37:52 +0000
100+++ debian/nova-objectstore.conf 2010-07-19 19:46:42 +0000
101@@ -1,7 +1,6 @@
102 --daemonize=1
103 --ca_path=/var/lib/nova/CA
104 --keys_path=/var/lib/nova/keys
105---datastore_path=/var/lib/nova/keeper
106 --fake_users=1
107 --images_path=/var/lib/nova/images
108 --buckets_path=/var/lib/nova/buckets
109
110=== modified file 'debian/nova-volume.conf'
111--- debian/nova-volume.conf 2010-07-05 13:37:52 +0000
112+++ debian/nova-volume.conf 2010-07-19 19:46:42 +0000
113@@ -1,7 +1,6 @@
114 --daemonize=1
115 --ca_path=/var/lib/nova/CA
116 --keys_path=/var/lib/nova/keys
117---datastore_path=/var/lib/nova/keeper
118 --fake_users=1
119 --images_path=/var/lib/nova/images
120 --buckets_path=/var/lib/nova/buckets
121
122=== modified file 'nova/compute/linux_net.py'
123--- nova/compute/linux_net.py 2010-07-18 17:02:04 +0000
124+++ nova/compute/linux_net.py 2010-07-19 19:46:42 +0000
125@@ -28,12 +28,16 @@
126 from nova import flags
127 FLAGS=flags.FLAGS
128
129-def execute(cmd):
130+flags.DEFINE_string('dhcpbridge_flagfile',
131+ '/etc/nova-dhcpbridge.conf',
132+ 'location of flagfile for dhcpbridge')
133+
134+def execute(cmd, addl_env=None):
135 if FLAGS.fake_network:
136 logging.debug("FAKE NET: %s" % cmd)
137 return "fake", 0
138 else:
139- return utils.execute(cmd)
140+ return utils.execute(cmd, addl_env=addl_env)
141
142 def runthis(desc, cmd):
143 if FLAGS.fake_network:
144@@ -61,7 +65,7 @@
145
146 def bind_public_ip(ip, interface):
147 runthis("Binding IP to interface: %s", "sudo ip addr add %s dev %s" % (ip, interface))
148-
149+
150 def unbind_public_ip(ip, interface):
151 runthis("Binding IP to interface: %s", "sudo ip addr del %s dev %s" % (ip, interface))
152
153@@ -99,7 +103,7 @@
154 ' --except-interface=lo',
155 ' --dhcp-range=%s,static,600s' % (net.dhcp_range_start),
156 ' --dhcp-hostsfile=%s' % dhcp_file(net['vlan'], 'conf'),
157- ' --dhcp-script=%s' % bin_file('dhcpleasor.py'),
158+ ' --dhcp-script=%s' % bin_file('nova-dhcpbridge'),
159 ' --leasefile-ro']
160 return ''.join(cmd)
161
162@@ -139,7 +143,9 @@
163 if os.path.exists(lease_file):
164 os.unlink(lease_file)
165
166- Popen(dnsmasq_cmd(network).split(" "))
167+ # FLAGFILE in env
168+ env = {'FLAGFILE' : FLAGS.dhcpbridge_flagfile}
169+ execute(dnsmasq_cmd(network), addl_env=env)
170
171 def stop_dnsmasq(network):
172 """ stops the dnsmasq instance for a given network """
173
174=== modified file 'nova/compute/network.py'
175--- nova/compute/network.py 2010-07-16 22:42:40 +0000
176+++ nova/compute/network.py 2010-07-19 19:46:42 +0000
177@@ -251,7 +251,7 @@
178 raise compute_exception.NoMoreAddresses("Project %s with network %s" %
179 (project_id, str(self.network)))
180
181- def lease_ip(self, ip_str):
182+ def lease_ip(self, ip_str):
183 logging.debug("Leasing allocated IP %s" % (ip_str))
184
185 def release_ip(self, ip_str):
186@@ -566,10 +566,10 @@
187
188 def deallocate_ip(address):
189 return get_network_by_address(address).deallocate_ip(address)
190-
191+
192 def release_ip(address):
193 return get_network_by_address(address).release_ip(address)
194-
195+
196 def lease_ip(address):
197 return get_network_by_address(address).lease_ip(address)
198
199
200=== modified file 'nova/tests/network_unittest.py'
201--- nova/tests/network_unittest.py 2010-07-15 23:13:48 +0000
202+++ nova/tests/network_unittest.py 2010-07-19 19:46:42 +0000
203@@ -19,16 +19,15 @@
204 import IPy
205 import os
206 import logging
207-import unittest
208
209 from nova import flags
210 from nova import test
211-from nova import exception
212+from nova import utils
213+from nova.auth import users
214+from nova.compute import network
215 from nova.compute.exception import NoMoreAddresses
216-from nova.compute import network
217-from nova.auth import users
218-from nova import utils
219
220+FLAGS = flags.FLAGS
221
222 class NetworkTestCase(test.TrialTestCase):
223 def setUp(self):
224@@ -180,14 +179,20 @@
225
226 class FakeDNSMasq(object):
227 def issue_ip(self, mac, ip, hostname, interface):
228- cmd = "%s add %s %s %s" % (binpath('dhcpleasor.py'), mac, ip, hostname)
229- env = {'DNSMASQ_INTERFACE': interface, 'TESTING' : '1'}
230+ cmd = "%s add %s %s %s" % (binpath('nova-dhcpbridge'),
231+ mac, ip, hostname)
232+ env = {'DNSMASQ_INTERFACE': interface,
233+ 'TESTING' : '1',
234+ 'FLAGFILE' : FLAGS.dhcpbridge_flagfile}
235 (out, err) = utils.execute(cmd, addl_env=env)
236 logging.debug("ISSUE_IP: %s, %s " % (out, err))
237
238 def release_ip(self, mac, ip, hostname, interface):
239- cmd = "%s del %s %s %s" % (binpath('dhcpleasor.py'), mac, ip, hostname)
240- env = {'DNSMASQ_INTERFACE': interface, 'TESTING' : '1'}
241+ cmd = "%s del %s %s %s" % (binpath('nova-dhcpbridge'),
242+ mac, ip, hostname)
243+ env = {'DNSMASQ_INTERFACE': interface,
244+ 'TESTING' : '1',
245+ 'FLAGFILE' : FLAGS.dhcpbridge_flagfile}
246 (out, err) = utils.execute(cmd, addl_env=env)
247 logging.debug("RELEASE_IP: %s, %s " % (out, err))
248