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
=== modified file 'src/maasserver/triggers/tests/test_init.py'
--- src/maasserver/triggers/tests/test_init.py 2017-04-11 18:13:02 +0000
+++ src/maasserver/triggers/tests/test_init.py 2017-04-17 17:05:21 +0000
@@ -243,6 +243,7 @@
243 "vlan_vlan_create_notify",243 "vlan_vlan_create_notify",
244 "vlan_vlan_delete_notify",244 "vlan_vlan_delete_notify",
245 "vlan_vlan_machine_update_notify",245 "vlan_vlan_machine_update_notify",
246 "vlan_vlan_subnet_update_notify",
246 "vlan_vlan_update_notify",247 "vlan_vlan_update_notify",
247 "zone_zone_create_notify",248 "zone_zone_create_notify",
248 "zone_zone_delete_notify",249 "zone_zone_delete_notify",
249250
=== modified file 'src/maasserver/triggers/tests/test_websocket_listener.py'
--- src/maasserver/triggers/tests/test_websocket_listener.py 2017-04-11 01:29:40 +0000
+++ src/maasserver/triggers/tests/test_websocket_listener.py 2017-04-17 17:05:21 +0000
@@ -1909,6 +1909,26 @@
19091909
1910 @wait_for_reactor1910 @wait_for_reactor
1911 @inlineCallbacks1911 @inlineCallbacks
1912 def test__calls_handler_on_update_notification_for_vlan(self):
1913 yield deferToDatabase(register_websocket_triggers)
1914 listener = self.make_listener_without_delay()
1915 dv = DeferredValue()
1916 listener.register("subnet", lambda *args: dv.set(args))
1917 subnet = yield deferToDatabase(self.create_subnet)
1918
1919 yield listener.startService()
1920 try:
1921 yield deferToDatabase(
1922 self.update_vlan,
1923 subnet.vlan.id,
1924 {'name': factory.make_name('name')})
1925 yield dv.get(timeout=2)
1926 self.assertEqual(('update', '%s' % subnet.id), dv.value)
1927 finally:
1928 yield listener.stopService()
1929
1930 @wait_for_reactor
1931 @inlineCallbacks
1912 def test__calls_handler_on_delete_notification(self):1932 def test__calls_handler_on_delete_notification(self):
1913 yield deferToDatabase(register_websocket_triggers)1933 yield deferToDatabase(register_websocket_triggers)
1914 listener = self.make_listener_without_delay()1934 listener = self.make_listener_without_delay()
19151935
=== modified file 'src/maasserver/triggers/websocket.py'
--- src/maasserver/triggers/websocket.py 2017-04-11 01:29:40 +0000
+++ src/maasserver/triggers/websocket.py 2017-04-17 17:05:21 +0000
@@ -677,6 +677,25 @@
677 """)677 """)
678678
679679
680# Procedure that is called when vlan is updated.
681VLAN_SUBNET_NOTIFY = dedent("""\
682 CREATE OR REPLACE FUNCTION %s() RETURNS trigger AS $$
683 DECLARE
684 subnet RECORD;
685 BEGIN
686 FOR subnet IN (
687 SELECT DISTINCT maasserver_subnet.id AS id
688 FROM maasserver_subnet, maasserver_vlan
689 WHERE maasserver_vlan.id = %s)
690 LOOP
691 PERFORM pg_notify('subnet_update',CAST(subnet.id AS text));
692 END LOOP;
693 RETURN NEW;
694 END;
695 $$ LANGUAGE plpgsql;
696 """)
697
698
680# Procedure that is called when an IP address is updated to update the related699# Procedure that is called when an IP address is updated to update the related
681# node.700# node.
682STATIC_IP_ADDRESS_NODE_NOTIFY = dedent("""\701STATIC_IP_ADDRESS_NODE_NOTIFY = dedent("""\
@@ -1368,6 +1387,13 @@
1368 "maasserver_vlan",1387 "maasserver_vlan",
1369 "vlan_machine_update_notify", "update")1388 "vlan_machine_update_notify", "update")
13701389
1390 # VLAN subnet notifications
1391 register_procedure(
1392 VLAN_SUBNET_NOTIFY % ('vlan_subnet_update_notify', 'NEW.id'))
1393 register_trigger(
1394 "maasserver_vlan",
1395 "vlan_subnet_update_notify", "update")
1396
1371 # IP address node notifications1397 # IP address node notifications
1372 register_procedure(1398 register_procedure(
1373 STATIC_IP_ADDRESS_NODE_NOTIFY % (1399 STATIC_IP_ADDRESS_NODE_NOTIFY % (