Merge lp:~blake-rouse/maas/fix-1571622 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Andres Rodriguez
Approved revision: no longer in the source branch.
Merged at revision: 4940
Proposed branch: lp:~blake-rouse/maas/fix-1571622
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 56 lines (+20/-4)
2 files modified
src/maasserver/websockets/handlers/fabric.py (+4/-2)
src/maasserver/websockets/handlers/tests/test_fabric.py (+16/-2)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1571622
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+292379@code.launchpad.net

Commit message

Make sure that the vlan_ids for a fabric are ordered by ID so the default VLAN comes first.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

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

The attempt to merge lp:~blake-rouse/maas/fix-1571622 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Get:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Hit:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main Sources [867 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe Sources [7,750 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/multiverse Sources [180 kB]
Get:8 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,204 kB]
Get:9 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main Translation-en [569 kB]
Get:10 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,541 kB]
Get:11 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe Translation-en [4,358 kB]
Get:12 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [145 kB]
Get:13 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB]
Fetched 23.0 MB in 3s (6,044 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind bash bind9 bind9utils build-essential 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 libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-bson python3-convoy python3-coverage 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-mock python3-netaddr python3-netifaces 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-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu3).
archdetect-deb is already the newest version (1.117ubuntu2).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest v...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/websockets/handlers/fabric.py'
2--- src/maasserver/websockets/handlers/fabric.py 2016-03-28 13:54:47 +0000
3+++ src/maasserver/websockets/handlers/fabric.py 2016-04-20 13:47:29 +0000
4@@ -28,10 +28,12 @@
5
6 def dehydrate(self, obj, data, for_list=False):
7 data["name"] = obj.get_name()
8- data["vlan_ids"] = [
9+ # The default VLAN always has the lowest ID. We sort to place the
10+ # lowest ID first.
11+ data["vlan_ids"] = sorted([
12 vlan.id
13 for vlan in obj.vlan_set.all()
14- ]
15+ ])
16 return data
17
18 def delete(self, parameters):
19
20=== modified file 'src/maasserver/websockets/handlers/tests/test_fabric.py'
21--- src/maasserver/websockets/handlers/tests/test_fabric.py 2016-03-28 13:54:47 +0000
22+++ src/maasserver/websockets/handlers/tests/test_fabric.py 2016-04-20 13:47:29 +0000
23@@ -21,10 +21,10 @@
24 "class_type": fabric.class_type,
25 "updated": dehydrate_datetime(fabric.updated),
26 "created": dehydrate_datetime(fabric.created),
27- "vlan_ids": [
28+ "vlan_ids": sorted([
29 vlan.id
30 for vlan in fabric.vlan_set.all()
31- ],
32+ ]),
33 }
34 return data
35
36@@ -42,6 +42,20 @@
37 self.dehydrate_fabric(fabric),
38 handler.get({"id": fabric.id}))
39
40+ def test_get_default_vlan_is_first(self):
41+ user = factory.make_User()
42+ handler = FabricHandler(user, {})
43+ fabric = factory.make_Fabric()
44+ default_vlan = fabric.get_default_vlan()
45+ tagged_vlan_ids = [
46+ factory.make_VLAN(fabric=fabric).id
47+ for _ in range(3)
48+ ]
49+ observed = handler.get({"id": fabric.id})
50+ self.assertEqual(
51+ [default_vlan.id] + tagged_vlan_ids,
52+ observed["vlan_ids"])
53+
54 def test_list(self):
55 user = factory.make_User()
56 handler = FabricHandler(user, {})