Merge lp:~allenap/maas/storage-node-special-filesystems-websocket-api into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 4813
Proposed branch: lp:~allenap/maas/storage-node-special-filesystems-websocket-api
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~allenap/maas/storage-unmount-special-fs-form-missing-tests
Diff against target: 186 lines (+47/-26)
6 files modified
src/maasserver/api/tests/test_enlistment.py (+1/-4)
src/maasserver/listener.py (+3/-3)
src/maasserver/models/filesystem.py (+2/-1)
src/maasserver/websockets/handlers/node.py (+18/-16)
src/maasserver/websockets/handlers/tests/test_device.py (+1/-1)
src/maasserver/websockets/handlers/tests/test_machine.py (+22/-1)
To merge this branch: bzr merge lp:~allenap/maas/storage-node-special-filesystems-websocket-api
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+289525@code.launchpad.net

Commit message

Add special filesystems to nodes transmitted via the WebSocket API.

The deprecated LoopingCall.deferred attribute is also no longer used by the listener.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

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

The attempt to merge lp:~allenap/maas/storage-node-special-filesystems-websocket-api 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 [116 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 [1,106 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe Sources [7,508 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,433 kB]
Get:8 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,243 kB]
Fetched 17.4 MB in 3s (4,748 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind 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-1ubuntu1).
archdetect-deb is already the newest version (1.114ubuntu3).
authbind is already the newest version (2.1.1+nmu1).
bind9 is already the newest version (1:9.10.3.dfsg.P4-4).
bind9utils is already the newest version (1:9.10.3.dfsg.P4-4).
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu2).
dh-apport is already the newest version (2.20-0ubuntu3).
dh-systemd is already the newest version (1.29ubuntu1).
distro-info is already the newest version (0.14build1).
dnsutils is already the newest version (1:9.10.3.d...

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

The attempt to merge lp:~allenap/maas/storage-node-special-filesystems-websocket-api 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 [116 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 [1,106 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe Sources [7,506 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,433 kB]
Get:8 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/main Translation-en [730 kB]
Get:9 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,241 kB]
Get:10 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial/universe Translation-en [4,185 kB]
Fetched 22.3 MB in 4s (5,541 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind 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-1ubuntu1).
archdetect-deb is already the newest version (1.114ubuntu3).
authbind is already the newest version (2.1.1+nmu1).
bind9 is already the newest version (1:9.10.3.dfsg.P4-4).
bind9utils is already the newest version (1:9.10.3.dfsg.P4-4).
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu2).
dh-apport is a...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/tests/test_enlistment.py'
2--- src/maasserver/api/tests/test_enlistment.py 2016-03-09 12:21:54 +0000
3+++ src/maasserver/api/tests/test_enlistment.py 2016-03-21 16:05:02 +0000
4@@ -433,10 +433,7 @@
5 'status_name',
6 'status_message',
7 'status_action',
8- # XXX: GavinPanella 2016-03-09 bug=1555022:
9- # special_filesystems SHOULD be amongst the fields rendered,
10- # but is not, and neither Lee nor I could figure out why.
11- # 'special_filesystems',
12+ 'special_filesystems',
13 ],
14 list(parsed_result))
15
16
17=== modified file 'src/maasserver/listener.py'
18--- src/maasserver/listener.py 2016-02-17 16:12:30 +0000
19+++ src/maasserver/listener.py 2016-03-21 16:05:02 +0000
20@@ -92,6 +92,7 @@
21 self.connectionFileno = None
22 self.notifications = set()
23 self.notifier = task.LoopingCall(self.handleNotifies)
24+ self.notifierDone = None
25 self.connecting = None
26 self.disconnecting = None
27 self.registeredChannels = False
28@@ -387,14 +388,13 @@
29 def runHandleNotify(self, delay=0, clock=reactor):
30 """Defer later the `handleNotify`."""
31 if not self.notifier.running:
32- self.notifier.start(delay, now=False)
33+ self.notifierDone = self.notifier.start(delay, now=False)
34
35 def cancelHandleNotify(self):
36 """Cancel the deferred `handleNotify` call."""
37 if self.notifier.running:
38- done = self.notifier.deferred
39 self.notifier.stop()
40- return done
41+ return self.notifierDone
42 else:
43 return succeed(None)
44
45
46=== modified file 'src/maasserver/models/filesystem.py'
47--- src/maasserver/models/filesystem.py 2016-03-09 12:21:54 +0000
48+++ src/maasserver/models/filesystem.py 2016-03-21 16:05:02 +0000
49@@ -100,7 +100,8 @@
50 BlockDevice, unique=False, null=True, blank=True)
51
52 node = ForeignKey(
53- "Node", unique=False, null=True, blank=True)
54+ "Node", unique=False, null=True, blank=True,
55+ related_name="special_filesystems")
56
57 # XXX: For CharField, why allow null *and* blank? Would
58 # CharField(null=False, blank=True, default="") not work better?
59
60=== modified file 'src/maasserver/websockets/handlers/node.py'
61--- src/maasserver/websockets/handlers/node.py 2016-03-10 17:18:02 +0000
62+++ src/maasserver/websockets/handlers/node.py 2016-03-21 16:05:02 +0000
63@@ -7,6 +7,7 @@
64 "NodeHandler",
65 ]
66
67+from itertools import chain
68 import logging
69 from operator import itemgetter
70
71@@ -45,13 +46,14 @@
72 return (
73 queryset
74 .select_related('boot_interface', 'owner', 'zone', 'domain')
75- .prefetch_related(
76- 'interface_set__ip_addresses__subnet__vlan__fabric')
77+ .prefetch_related('blockdevice_set__physicalblockdevice')
78+ .prefetch_related('blockdevice_set__virtualblockdevice')
79 .prefetch_related('interface_set__ip_addresses__subnet__space')
80+ .prefetch_related('interface_set__ip_addresses__subnet__vlan__fabric')
81 .prefetch_related('interface_set__vlan__fabric')
82+ .prefetch_related('special_filesystems')
83 .prefetch_related('tags')
84- .prefetch_related('blockdevice_set__physicalblockdevice')
85- .prefetch_related('blockdevice_set__virtualblockdevice'))
86+ )
87
88
89 class NodeHandler(TimestampedModelHandler):
90@@ -151,23 +153,23 @@
91 data["on_network"] = obj.on_network()
92
93 # Storage
94- data["disks"] = [
95- self.dehydrate_blockdevice(blockdevice, obj)
96- for blockdevice in blockdevices
97- ]
98- data["disks"] = data["disks"] + [
99- self.dehydrate_volume_group(volume_group)
100- for volume_group in VolumeGroup.objects.filter_by_node(obj)
101- ] + [
102- self.dehydrate_cache_set(cache_set)
103- for cache_set in CacheSet.objects.get_cache_sets_for_node(obj)
104- ]
105- data["disks"] = sorted(data["disks"], key=itemgetter("name"))
106+ data["disks"] = sorted(chain(
107+ (self.dehydrate_blockdevice(blockdevice, obj)
108+ for blockdevice in blockdevices),
109+ (self.dehydrate_volume_group(volume_group) for volume_group
110+ in VolumeGroup.objects.filter_by_node(obj)),
111+ (self.dehydrate_cache_set(cache_set) for cache_set
112+ in CacheSet.objects.get_cache_sets_for_node(obj)),
113+ ), key=itemgetter("name"))
114 data["supported_filesystems"] = [
115 {'key': key, 'ui': ui}
116 for key, ui in FILESYSTEM_FORMAT_TYPE_CHOICES
117 ]
118 data["storage_layout_issues"] = obj.storage_layout_issues()
119+ data["special_filesystems"] = [
120+ self.dehydrate_filesystem(filesystem)
121+ for filesystem in obj.special_filesystems.order_by("id")
122+ ]
123
124 # Events
125 data["events"] = self.dehydrate_events(obj)
126
127=== modified file 'src/maasserver/websockets/handlers/tests/test_device.py'
128--- src/maasserver/websockets/handlers/tests/test_device.py 2016-02-26 18:39:26 +0000
129+++ src/maasserver/websockets/handlers/tests/test_device.py 2016-03-21 16:05:02 +0000
130@@ -209,7 +209,7 @@
131 # number means regiond has to do more work slowing down its process
132 # and slowing down the client waiting for the response.
133 self.assertEqual(
134- query_10_count, 11,
135+ query_10_count, 12,
136 "Number of queries has changed; make sure this is expected.")
137 self.assertEqual(
138 query_10_count, query_20_count,
139
140=== modified file 'src/maasserver/websockets/handlers/tests/test_machine.py'
141--- src/maasserver/websockets/handlers/tests/test_machine.py 2016-03-17 16:37:11 +0000
142+++ src/maasserver/websockets/handlers/tests/test_machine.py 2016-03-21 16:05:02 +0000
143@@ -175,6 +175,10 @@
144 "physical_disk_count": node.physicalblockdevice_set.count(),
145 "disks": disks,
146 "storage_layout_issues": node.storage_layout_issues(),
147+ "special_filesystems": [
148+ handler.dehydrate_filesystem(filesystem)
149+ for filesystem in node.special_filesystems.order_by("id")
150+ ],
151 "supported_filesystems": [
152 {'key': key, 'ui': ui}
153 for key, ui in FILESYSTEM_FORMAT_TYPE_CHOICES],
154@@ -828,6 +832,23 @@
155 self.dehydrate_node(node, handler, include_summary=True),
156 handler.get({"system_id": node.system_id}))
157
158+ def test_get_includes_special_filesystems(self):
159+ owner = factory.make_User()
160+ handler = MachineHandler(owner, {})
161+ machine = factory.make_Node(owner=owner)
162+ filesystems = [
163+ factory.make_Filesystem(node=machine),
164+ factory.make_Filesystem(node=machine),
165+ ]
166+ self.assertThat(
167+ handler.get({"system_id": machine.system_id}),
168+ ContainsDict({
169+ "special_filesystems": Equals([
170+ handler.dehydrate_filesystem(filesystem)
171+ for filesystem in filesystems
172+ ]),
173+ }))
174+
175 def test_list(self):
176 user = factory.make_User()
177 handler = MachineHandler(user, {})
178@@ -863,7 +884,7 @@
179 # number means regiond has to do more work slowing down its process
180 # and slowing down the client waiting for the response.
181 self.assertEqual(
182- query_10_count, 9,
183+ query_10_count, 10,
184 "Number of queries has changed; make sure this is expected.")
185 self.assertEqual(
186 query_10_count, query_20_count,