Merge lp:~rvb/maas/bug-1415538 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3497
Proposed branch: lp:~rvb/maas/bug-1415538
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 63 lines (+22/-2)
3 files modified
src/maasserver/dhcp.py (+3/-1)
src/maasserver/tests/test_dhcp.py (+8/-0)
src/provisioningserver/dhcp/tests/test_config.py (+11/-1)
To merge this branch: bzr merge lp:~rvb/maas/bug-1415538
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+247860@code.launchpad.net

Commit message

Do not generate the 'option routers' stanza if router IP is None.

Description of the change

The main problem here is that interface.router_ip is None when "unset".

To post a comment you must log in.
Revision history for this message
Christian Reis (kiko) wrote :

On Wed, Jan 28, 2015 at 04:35:42PM -0000, Raphaël Badin wrote:
> === modified file 'src/maasserver/dhcp.py'
> --- src/maasserver/dhcp.py 2014-10-03 19:29:51 +0000
> +++ src/maasserver/dhcp.py 2015-01-28 16:35:10 +0000
> @@ -56,7 +56,7 @@
> 'subnet_cidr': unicode(interface.network.cidr),
> 'broadcast_ip': interface.broadcast_ip,
> 'interface': interface.interface,
> - 'router_ip': unicode(interface.router_ip),
> + 'router_ip': interface.router_ip,

Should subnet_cidr above now be unicode()d as well?
--
Christian Robottom Reis | [+1] 612 888 4935 | http://launchpad.net/~kiko
Canonical VP Hyperscale | [+55 16] 9 9112 6430

Revision history for this message
Gavin Panella (allenap) wrote :

Tip top.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> On Wed, Jan 28, 2015 at 04:35:42PM -0000, Raphaël Badin wrote:
> > === modified file 'src/maasserver/dhcp.py'
> > --- src/maasserver/dhcp.py 2014-10-03 19:29:51 +0000
> > +++ src/maasserver/dhcp.py 2015-01-28 16:35:10 +0000
> > @@ -56,7 +56,7 @@
> > 'subnet_cidr': unicode(interface.network.cidr),
> > 'broadcast_ip': interface.broadcast_ip,
> > 'interface': interface.interface,
> > - 'router_ip': unicode(interface.router_ip),
> > + 'router_ip': interface.router_ip,
>
> Should subnet_cidr above now be unicode()d as well?

We need to keep the unicode() in the expression unicode(interface.network.cidr) because the type interface.network.cidr is netaddr.IPNetwork and it needs to be converted to a string representation. A managed interface *cannot* have a None interface.network. (But it can have a None router_ip, hence the fix here).

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (19.5 KiB)

The attempt to merge lp:~rvb/maas/bug-1415538 into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [62.0 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Get:4 http://security.ubuntu.com trusty-security/main Sources [64.8 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:5 http://security.ubuntu.com trusty-security/universe Sources [17.4 kB]
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [200 kB]
Get:7 http://nova.clouds.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [85.3 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [160 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [99.4 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [407 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [243 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,402 kB in 2s (476 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-bson python-bzrlib python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-iscpy python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-pyparsing python-p...

Revision history for this message
MAAS Lander (maas-lander) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/dhcp.py'
2--- src/maasserver/dhcp.py 2014-10-03 19:29:51 +0000
3+++ src/maasserver/dhcp.py 2015-01-30 07:57:17 +0000
4@@ -56,7 +56,9 @@
5 'subnet_cidr': unicode(interface.network.cidr),
6 'broadcast_ip': interface.broadcast_ip,
7 'interface': interface.interface,
8- 'router_ip': unicode(interface.router_ip),
9+ 'router_ip': (
10+ None if not interface.router_ip
11+ else unicode(interface.router_ip)),
12 'dns_servers': dns_servers,
13 'ntp_server': ntp_server,
14 'domain_name': interface.nodegroup.name,
15
16=== modified file 'src/maasserver/tests/test_dhcp.py'
17--- src/maasserver/tests/test_dhcp.py 2014-11-07 13:16:58 +0000
18+++ src/maasserver/tests/test_dhcp.py 2015-01-30 07:57:17 +0000
19@@ -200,6 +200,14 @@
20 self.expectThat(
21 config['ip_range_low'], Not(Equals(interface.static_ip_range_low)))
22
23+ def test__doesnt_convert_None_router_ip(self):
24+ interface = factory.make_NodeGroupInterface(factory.make_NodeGroup())
25+ interface.router_ip = None
26+ interface.save()
27+ config = make_subnet_config(
28+ interface, factory.make_name('dns'), factory.make_name('ntp'))
29+ self.assertEqual(None, config['router_ip'])
30+
31
32 class TestDoConfigureDHCP(MAASServerTestCase):
33 """Tests for `do_configure_dhcp`."""
34
35=== modified file 'src/provisioningserver/dhcp/tests/test_config.py'
36--- src/provisioningserver/dhcp/tests/test_config.py 2014-11-07 15:50:30 +0000
37+++ src/provisioningserver/dhcp/tests/test_config.py 2015-01-30 07:57:17 +0000
38@@ -147,7 +147,7 @@
39 config.get_config('dhcpd.conf.template', **params),
40 Contains(router_ip))
41
42- def test__renders_without_router_ip(self):
43+ def test__renders_with_empty_string_router_ip(self):
44 params = make_sample_params()
45 params['dhcp_subnets'][0]['router_ip'] = ''
46 template = self.patch_template()
47@@ -157,6 +157,16 @@
48 config.get_config('dhcpd.conf.template', **params))
49 self.assertNotIn("routers", rendered)
50
51+ def test__renders_with_None_router_ip(self):
52+ params = make_sample_params()
53+ params['dhcp_subnets'][0]['router_ip'] = None
54+ template = self.patch_template()
55+ rendered = template.substitute(params)
56+ self.assertEqual(
57+ rendered,
58+ config.get_config('dhcpd.conf.template', **params))
59+ self.assertNotIn("routers", rendered)
60+
61
62 class TestComposeConditionalBootloader(PservTestCase):
63 """Tests for `compose_conditional_bootloader`."""