Merge lp:~ltrager/maas/lp1687500 into lp:~maas-committers/maas/trunk

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 6034
Proposed branch: lp:~ltrager/maas/lp1687500
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 83 lines (+19/-0)
2 files modified
src/maasserver/dhcp.py (+1/-0)
src/maasserver/tests/test_dhcp.py (+18/-0)
To merge this branch: bzr merge lp:~ltrager/maas/lp1687500
Reviewer Review Type Date Requested Status
Newell Jensen (community) Approve
Review via email: mp+323480@code.launchpad.net

Commit message

If a StaticIPAddress has no subnet ip_is_on_vlan now returns False to prevent an AttributeError

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

LGTM logic wise. Whether or not this is the way forward as we discussed on IRC is TBD.

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

The attempt to merge lp:~ltrager/maas/lp1687500 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [527 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main Sources [68.9 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [257 kB]
Fetched 1,159 kB in 0s (2,056 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1buil...

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

The attempt to merge lp:~ltrager/maas/lp1687500 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 102 kB in 0s (199 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest ver...

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 2017-01-28 00:51:47 +0000
3+++ src/maasserver/dhcp.py 2017-05-02 22:00:32 +0000
4@@ -210,6 +210,7 @@
5 """Return True if `ip_address` is on `vlan`."""
6 return (
7 ip_is_sticky_or_auto(ip_address) and
8+ ip_address.subnet is not None and
9 ip_address.subnet.vlan_id == vlan.id and
10 ip_address.ip is not None and
11 ip_address.ip != "")
12
13=== modified file 'src/maasserver/tests/test_dhcp.py'
14--- src/maasserver/tests/test_dhcp.py 2017-01-28 00:51:47 +0000
15+++ src/maasserver/tests/test_dhcp.py 2017-05-02 22:00:32 +0000
16@@ -542,42 +542,56 @@
17 "alloc_type": IPADDRESS_TYPE.STICKY,
18 "has_ip": True,
19 "on_vlan": True,
20+ "on_subnet": True,
21 "result": True,
22 }),
23 ("sticky_not_on_vlan_with_ip", {
24 "alloc_type": IPADDRESS_TYPE.STICKY,
25 "has_ip": True,
26 "on_vlan": False,
27+ "on_subnet": True,
28 "result": False,
29 }),
30 ("auto_on_vlan_with_ip", {
31 "alloc_type": IPADDRESS_TYPE.AUTO,
32 "has_ip": True,
33 "on_vlan": True,
34+ "on_subnet": True,
35 "result": True,
36 }),
37 ("auto_on_vlan_without_ip", {
38 "alloc_type": IPADDRESS_TYPE.AUTO,
39 "has_ip": False,
40 "on_vlan": True,
41+ "on_subnet": True,
42 "result": False,
43 }),
44 ("auto_not_on_vlan_with_ip", {
45 "alloc_type": IPADDRESS_TYPE.AUTO,
46 "has_ip": True,
47 "on_vlan": False,
48+ "on_subnet": True,
49 "result": False,
50 }),
51 ("discovered", {
52 "alloc_type": IPADDRESS_TYPE.DISCOVERED,
53 "has_ip": True,
54 "on_vlan": True,
55+ "on_subnet": True,
56 "result": False,
57 }),
58 ("user_reserved", {
59 "alloc_type": IPADDRESS_TYPE.USER_RESERVED,
60 "has_ip": True,
61 "on_vlan": True,
62+ "on_subnet": True,
63+ "result": False,
64+ }),
65+ ("not_on_subnet", {
66+ "alloc_type": IPADDRESS_TYPE.STICKY,
67+ "has_ip": True,
68+ "on_vlan": False,
69+ "on_subnet": False,
70 "result": False,
71 }),
72 )
73@@ -593,6 +607,10 @@
74 ip = factory.pick_ip_in_Subnet(subnet)
75 ip_address = factory.make_StaticIPAddress(
76 alloc_type=self.alloc_type, ip=ip, subnet=subnet)
77+ if not self.on_subnet:
78+ # make_StaticIPAddress always creates a subnet so set it to None.
79+ ip_address.subnet = None
80+ ip_address.save()
81 self.assertEquals(
82 self.result,
83 dhcp.ip_is_on_vlan(ip_address, expected_vlan))