Merge lp:~mpontillo/maas/fix-space-ui-updates--bug-1682663 into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 5985
Proposed branch: lp:~mpontillo/maas/fix-space-ui-updates--bug-1682663
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 86 lines (+47/-0)
3 files modified
src/maasserver/triggers/tests/test_init.py (+1/-0)
src/maasserver/triggers/tests/test_websocket_listener.py (+20/-0)
src/maasserver/triggers/websocket.py (+26/-0)
To merge this branch: bzr merge lp:~mpontillo/maas/fix-space-ui-updates--bug-1682663
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+322562@code.launchpad.net

Commit message

Add trigger to notify subnets when their parent VLAN changes.

Description of the change

Note: this was a regression due to the change from L3 spaces to L2 spaces in MAAS 2.2.

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.9 MiB)

The attempt to merge lp:~mpontillo/maas/fix-space-ui-updates--bug-1682663 into lp:maas failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [512 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [457 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [8,916 B]
Fetched 1,284 kB in 0s (2,244 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 al...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/triggers/tests/test_init.py'
2--- src/maasserver/triggers/tests/test_init.py 2017-04-11 18:13:02 +0000
3+++ src/maasserver/triggers/tests/test_init.py 2017-04-17 17:05:21 +0000
4@@ -243,6 +243,7 @@
5 "vlan_vlan_create_notify",
6 "vlan_vlan_delete_notify",
7 "vlan_vlan_machine_update_notify",
8+ "vlan_vlan_subnet_update_notify",
9 "vlan_vlan_update_notify",
10 "zone_zone_create_notify",
11 "zone_zone_delete_notify",
12
13=== modified file 'src/maasserver/triggers/tests/test_websocket_listener.py'
14--- src/maasserver/triggers/tests/test_websocket_listener.py 2017-04-11 01:29:40 +0000
15+++ src/maasserver/triggers/tests/test_websocket_listener.py 2017-04-17 17:05:21 +0000
16@@ -1909,6 +1909,26 @@
17
18 @wait_for_reactor
19 @inlineCallbacks
20+ def test__calls_handler_on_update_notification_for_vlan(self):
21+ yield deferToDatabase(register_websocket_triggers)
22+ listener = self.make_listener_without_delay()
23+ dv = DeferredValue()
24+ listener.register("subnet", lambda *args: dv.set(args))
25+ subnet = yield deferToDatabase(self.create_subnet)
26+
27+ yield listener.startService()
28+ try:
29+ yield deferToDatabase(
30+ self.update_vlan,
31+ subnet.vlan.id,
32+ {'name': factory.make_name('name')})
33+ yield dv.get(timeout=2)
34+ self.assertEqual(('update', '%s' % subnet.id), dv.value)
35+ finally:
36+ yield listener.stopService()
37+
38+ @wait_for_reactor
39+ @inlineCallbacks
40 def test__calls_handler_on_delete_notification(self):
41 yield deferToDatabase(register_websocket_triggers)
42 listener = self.make_listener_without_delay()
43
44=== modified file 'src/maasserver/triggers/websocket.py'
45--- src/maasserver/triggers/websocket.py 2017-04-11 01:29:40 +0000
46+++ src/maasserver/triggers/websocket.py 2017-04-17 17:05:21 +0000
47@@ -677,6 +677,25 @@
48 """)
49
50
51+# Procedure that is called when vlan is updated.
52+VLAN_SUBNET_NOTIFY = dedent("""\
53+ CREATE OR REPLACE FUNCTION %s() RETURNS trigger AS $$
54+ DECLARE
55+ subnet RECORD;
56+ BEGIN
57+ FOR subnet IN (
58+ SELECT DISTINCT maasserver_subnet.id AS id
59+ FROM maasserver_subnet, maasserver_vlan
60+ WHERE maasserver_vlan.id = %s)
61+ LOOP
62+ PERFORM pg_notify('subnet_update',CAST(subnet.id AS text));
63+ END LOOP;
64+ RETURN NEW;
65+ END;
66+ $$ LANGUAGE plpgsql;
67+ """)
68+
69+
70 # Procedure that is called when an IP address is updated to update the related
71 # node.
72 STATIC_IP_ADDRESS_NODE_NOTIFY = dedent("""\
73@@ -1368,6 +1387,13 @@
74 "maasserver_vlan",
75 "vlan_machine_update_notify", "update")
76
77+ # VLAN subnet notifications
78+ register_procedure(
79+ VLAN_SUBNET_NOTIFY % ('vlan_subnet_update_notify', 'NEW.id'))
80+ register_trigger(
81+ "maasserver_vlan",
82+ "vlan_subnet_update_notify", "update")
83+
84 # IP address node notifications
85 register_procedure(
86 STATIC_IP_ADDRESS_NODE_NOTIFY % (