diff --git a/bin/dhcpleasor.py b/bin/nova-dhcpbridge similarity index 83% rename from bin/dhcpleasor.py rename to bin/nova-dhcpbridge index 07ff325f1..d15924e57 100755 --- a/bin/dhcpleasor.py +++ b/bin/nova-dhcpbridge @@ -18,23 +18,27 @@ # under the License. """ -dhcpleasor.py +nova-dhcpbridge Handle lease database updates from DHCP servers. """ -import sys -import os import logging +import os +import sys + +#TODO(joshua): there is concern that the user dnsmasq runs under will not +# have nova in the path. This should be verified and if it is +# not true the ugly line below can be removed sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) -logging.debug(sys.path) -import getopt -from os import environ -from nova import rpc from nova import flags +from nova import rpc +from nova import utils from nova.compute import linux_net from nova.compute import network + + FLAGS = flags.FLAGS @@ -63,11 +67,12 @@ def init_leases(interface): return res -def main(argv=None): - if argv is None: - argv = sys.argv - interface = environ.get('DNSMASQ_INTERFACE', 'br0') - if int(environ.get('TESTING', '0')): +def main(): + flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile) + utils.default_flagfile(flagfile) + argv = FLAGS(sys.argv) + interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') + if int(os.environ.get('TESTING', '0')): FLAGS.fake_rabbit = True FLAGS.redis_db = 8 FLAGS.network_size = 32 diff --git a/debian/nova-api.conf b/debian/nova-api.conf index 9cd4051b1..d0b796878 100644 --- a/debian/nova-api.conf +++ b/debian/nova-api.conf @@ -1,5 +1,6 @@ --daemonize=1 --ca_path=/var/lib/nova/CA --keys_path=/var/lib/nova/keys +--networks_path=/var/lib/nova/networks +--dhcpbridge_flagfile=/etc/nova/nova-dhcpbridge.conf --fake_users=1 ---datastore_path=/var/lib/nova/keeper diff --git a/debian/nova-api.install b/debian/nova-api.install index 02dbda02d..89615d302 100644 --- a/debian/nova-api.install +++ b/debian/nova-api.install @@ -1,2 +1,3 @@ bin/nova-api usr/bin debian/nova-api.conf etc/nova +debian/nova-dhcpbridge.conf etc/nova diff --git a/debian/nova-compute.conf b/debian/nova-compute.conf index e4ca3fe95..d862f2328 100644 --- a/debian/nova-compute.conf +++ b/debian/nova-compute.conf @@ -1,8 +1,6 @@ --ca_path=/var/lib/nova/CA --keys_path=/var/lib/nova/keys ---datastore_path=/var/lib/nova/keeper --instances_path=/var/lib/nova/instances ---networks_path=/var/lib/nova/networks --simple_network_template=/usr/share/nova/interfaces.template --libvirt_xml_template=/usr/share/nova/libvirt.xml.template --vpn_client_template=/usr/share/nova/client.ovpn.template diff --git a/debian/nova-dhcp.conf b/debian/nova-dhcp.conf new file mode 100644 index 000000000..0aafe7549 --- /dev/null +++ b/debian/nova-dhcp.conf @@ -0,0 +1,2 @@ +--networks_path=/var/lib/nova/networks +--fake_users=1 diff --git a/debian/nova-objectstore.conf b/debian/nova-objectstore.conf index af3271d3b..03f5df051 100644 --- a/debian/nova-objectstore.conf +++ b/debian/nova-objectstore.conf @@ -1,7 +1,6 @@ --daemonize=1 --ca_path=/var/lib/nova/CA --keys_path=/var/lib/nova/keys ---datastore_path=/var/lib/nova/keeper --fake_users=1 --images_path=/var/lib/nova/images --buckets_path=/var/lib/nova/buckets diff --git a/debian/nova-volume.conf b/debian/nova-volume.conf index af3271d3b..03f5df051 100644 --- a/debian/nova-volume.conf +++ b/debian/nova-volume.conf @@ -1,7 +1,6 @@ --daemonize=1 --ca_path=/var/lib/nova/CA --keys_path=/var/lib/nova/keys ---datastore_path=/var/lib/nova/keeper --fake_users=1 --images_path=/var/lib/nova/images --buckets_path=/var/lib/nova/buckets diff --git a/nova/tests/network_unittest.py b/nova/tests/network_unittest.py index a822cc1d9..444063d0f 100644 --- a/nova/tests/network_unittest.py +++ b/nova/tests/network_unittest.py @@ -19,16 +19,15 @@ import IPy import os import logging -import unittest from nova import flags from nova import test -from nova import exception -from nova.compute.exception import NoMoreAddresses -from nova.compute import network -from nova.auth import users from nova import utils +from nova.auth import users +from nova.compute import network +from nova.compute.exception import NoMoreAddresses +FLAGS = flags.FLAGS class NetworkTestCase(test.TrialTestCase): def setUp(self): @@ -180,14 +179,20 @@ def binpath(script): class FakeDNSMasq(object): def issue_ip(self, mac, ip, hostname, interface): - cmd = "%s add %s %s %s" % (binpath('dhcpleasor.py'), mac, ip, hostname) - env = {'DNSMASQ_INTERFACE': interface, 'TESTING' : '1'} + cmd = "%s add %s %s %s" % (binpath('nova-dhcpbridge'), + mac, ip, hostname) + env = {'DNSMASQ_INTERFACE': interface, + 'TESTING' : '1', + 'FLAGFILE' : FLAGS.dhcpbridge_flagfile} (out, err) = utils.execute(cmd, addl_env=env) logging.debug("ISSUE_IP: %s, %s " % (out, err)) def release_ip(self, mac, ip, hostname, interface): - cmd = "%s del %s %s %s" % (binpath('dhcpleasor.py'), mac, ip, hostname) - env = {'DNSMASQ_INTERFACE': interface, 'TESTING' : '1'} + cmd = "%s del %s %s %s" % (binpath('nova-dhcpbridge'), + mac, ip, hostname) + env = {'DNSMASQ_INTERFACE': interface, + 'TESTING' : '1', + 'FLAGFILE' : FLAGS.dhcpbridge_flagfile} (out, err) = utils.execute(cmd, addl_env=env) logging.debug("RELEASE_IP: %s, %s " % (out, err))