Merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:~maas-committers/maas/trunk

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 2956
Proposed branch: lp:~gmb/maas/enlist-mscm-to-RPC
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 284 lines (+130/-32)
8 files modified
src/maasserver/api/tests/test_nodegroup.py (+12/-5)
src/maasserver/models/nodegroup.py (+16/-6)
src/maasserver/models/tests/test_nodegroup.py (+50/-0)
src/provisioningserver/rpc/cluster.py (+14/-0)
src/provisioningserver/rpc/clusterservice.py (+11/-0)
src/provisioningserver/rpc/tests/test_clusterservice.py (+27/-0)
src/provisioningserver/tasks.py (+0/-9)
src/provisioningserver/tests/test_tasks.py (+0/-12)
To merge this branch: bzr merge lp:~gmb/maas/enlist-mscm-to-RPC
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+234279@code.launchpad.net

Commit message

Convert the enlist_nodes_from_mscm Celery task to an RPC call.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve
Revision history for this message
Graham Binns (gmb) wrote :

On 11 September 2014 11:28, Gavin Panella <email address hidden> wrote:
>
>> +
>> +class EnlistNodesFromMSCM(amp.Command):
>> + """Probe for and enlist mscm machines attached to the cluster.
>> +
>> + :since 1.7:
>> + """
>> + arguments = [
>> + (b"host", amp.Unicode()),
>> + (b"username", amp.Unicode()),
>> + (b"password", amp.Unicode()),
>> + ]
>> + response = []
>> + errors = {}
>
> No errors at all?

probe_and_enlist_mscm() doesn't appear to raise any, so no. This is
one of those cases where we need a catch-all, because I don't know
what might happen further down the stack (this is the one and only
time I've ever been tempted to miss Java's error declarations…)

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

The attempt to merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://security.ubuntu.com trusty-security Release
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-oops python-oops-amqp python-oops-datedir-repo python-oops-twisted python-oops-wsgi python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-seamicroclient python-simplejson python-simplestreams python-sphinx python-s...

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

The attempt to merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:2 http://security.ubuntu.com trusty-security Release [59.7 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [59.7 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:5 http://security.ubuntu.com trusty-security/main Sources [43.9 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [10.8 kB]
Get:7 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [118 kB]
Get:8 http://security.ubuntu.com trusty-security/main amd64 Packages [138 kB]
Get:9 http://security.ubuntu.com trusty-security/universe amd64 Packages [47.2 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [83.7 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [317 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [201 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,080 kB in 0s (1,756 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-oops python-oops-amqp python-oops-datedir-repo python-oops-twisted python-oops-wsgi python-openssl py...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/api/tests/test_nodegroup.py'
--- src/maasserver/api/tests/test_nodegroup.py 2014-09-10 06:35:46 +0000
+++ src/maasserver/api/tests/test_nodegroup.py 2014-09-11 11:22:16 +0000
@@ -55,7 +55,10 @@
55 )55 )
56from mock import Mock56from mock import Mock
57from provisioningserver.auth import get_recorded_nodegroup_uuid57from provisioningserver.auth import get_recorded_nodegroup_uuid
58from provisioningserver.rpc.cluster import ImportBootImages58from provisioningserver.rpc.cluster import (
59 EnlistNodesFromMSCM,
60 ImportBootImages,
61 )
59from testresources import FixtureResource62from testresources import FixtureResource
60from testtools.matchers import (63from testtools.matchers import (
61 AllMatch,64 AllMatch,
@@ -370,7 +373,9 @@
370 password = factory.make_name('password')373 password = factory.make_name('password')
371 self.become_admin()374 self.become_admin()
372375
373 mock = self.patch(nodegroup_module, 'enlist_nodes_from_mscm')376 getClientFor = self.patch(nodegroup_module, 'getClientFor')
377 client = getClientFor.return_value
378 nodegroup = factory.make_NodeGroup()
374379
375 response = self.client.post(380 response = self.client.post(
376 reverse('nodegroup_handler', args=[nodegroup.uuid]),381 reverse('nodegroup_handler', args=[nodegroup.uuid]),
@@ -385,9 +390,11 @@
385 httplib.OK, response.status_code,390 httplib.OK, response.status_code,
386 explain_unexpected_response(httplib.OK, response))391 explain_unexpected_response(httplib.OK, response))
387392
388 args = (host, username, password)393 self.expectThat(
389 matcher = MockCalledOnceWith(queue=nodegroup.uuid, args=args)394 client,
390 self.assertThat(mock.apply_async, matcher)395 MockCalledOnceWith(
396 EnlistNodesFromMSCM, host=host, username=username,
397 password=password))
391398
392399
393class TestNodeGroupAPIAuth(MAASServerTestCase):400class TestNodeGroupAPIAuth(MAASServerTestCase):
394401
=== modified file 'src/maasserver/models/nodegroup.py'
--- src/maasserver/models/nodegroup.py 2014-09-10 16:01:38 +0000
+++ src/maasserver/models/nodegroup.py 2014-09-11 11:22:16 +0000
@@ -41,13 +41,11 @@
41from provisioningserver.rpc.cluster import (41from provisioningserver.rpc.cluster import (
42 AddSeaMicro15k,42 AddSeaMicro15k,
43 AddVirsh,43 AddVirsh,
44 EnlistNodesFromMSCM,
44 ImportBootImages,45 ImportBootImages,
45 )46 )
46from provisioningserver.rpc.exceptions import NoConnectionsAvailable47from provisioningserver.rpc.exceptions import NoConnectionsAvailable
47from provisioningserver.tasks import (48from provisioningserver.tasks import enlist_nodes_from_ucsm
48 enlist_nodes_from_mscm,
49 enlist_nodes_from_ucsm,
50 )
5149
5250
53class NodeGroupManager(Manager):51class NodeGroupManager(Manager):
@@ -314,6 +312,18 @@
314 :param host: IP address for the MSCM.312 :param host: IP address for the MSCM.
315 :param username: username for MSCM.313 :param username: username for MSCM.
316 :param password: password for MSCM.314 :param password: password for MSCM.
315
316 :raises NoConnectionsAvailable: If no connections to the cluster
317 are available.
317 """318 """
318 args = (host, username, password)319 try:
319 enlist_nodes_from_mscm.apply_async(queue=self.uuid, args=args)320 client = getClientFor(self.uuid, timeout=1)
321 except NoConnectionsAvailable:
322 # No connection to the cluster so we can't do anything. We
323 # let the caller handle the error, since we don't want to
324 # just drop it.
325 raise
326 else:
327 return client(
328 EnlistNodesFromMSCM, host=host, username=username,
329 password=password)
320330
=== modified file 'src/maasserver/models/tests/test_nodegroup.py'
--- src/maasserver/models/tests/test_nodegroup.py 2014-09-10 16:01:38 +0000
+++ src/maasserver/models/tests/test_nodegroup.py 2014-09-11 11:22:16 +0000
@@ -49,6 +49,7 @@
49from provisioningserver.rpc.cluster import (49from provisioningserver.rpc.cluster import (
50 AddSeaMicro15k,50 AddSeaMicro15k,
51 AddVirsh,51 AddVirsh,
52 EnlistNodesFromMSCM,
52 ImportBootImages,53 ImportBootImages,
53 )54 )
54from provisioningserver.rpc.exceptions import NoConnectionsAvailable55from provisioningserver.rpc.exceptions import NoConnectionsAvailable
@@ -513,3 +514,52 @@
513 self.assertRaises(514 self.assertRaises(
514 NoConnectionsAvailable, nodegroup.add_seamicro15k,515 NoConnectionsAvailable, nodegroup.add_seamicro15k,
515 mac, username, password, power_control)516 mac, username, password, power_control)
517
518 def test_enlist_nodes_from_mscm_end_to_end(self):
519 nodegroup = factory.make_NodeGroup(status=NODEGROUP_STATUS.ACCEPTED)
520
521 self.useFixture(RegionEventLoopFixture("rpc"))
522 self.useFixture(RunningEventLoopFixture())
523 fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
524 protocol = fixture.makeCluster(nodegroup, EnlistNodesFromMSCM)
525 protocol.EnlistNodesFromMSCM.return_value = defer.succeed({})
526
527 host = factory.make_name('host')
528 username = factory.make_name('user')
529 password = factory.make_name('password')
530 nodegroup.enlist_nodes_from_mscm(
531 host, username, password).wait(10)
532
533 self.expectThat(
534 protocol.EnlistNodesFromMSCM,
535 MockCalledOnceWith(
536 ANY, host=host, username=username, password=password))
537
538 def test_enlist_nodes_from_mscm_calls_client_with_resource_endpoint(self):
539 getClientFor = self.patch(nodegroup_module, 'getClientFor')
540 client = getClientFor.return_value
541 nodegroup = factory.make_NodeGroup()
542
543 host = factory.make_name('host')
544 username = factory.make_name('user')
545 password = factory.make_name('password')
546 nodegroup.enlist_nodes_from_mscm(
547 host, username, password).wait(10)
548
549 self.expectThat(
550 client,
551 MockCalledOnceWith(
552 EnlistNodesFromMSCM, host=host, username=username,
553 password=password))
554
555 def test_enlist_nodes_from_mscm_raises_if_no_connection_to_cluster(self):
556 getClientFor = self.patch(nodegroup_module, 'getClientFor')
557 getClientFor.side_effect = NoConnectionsAvailable()
558 nodegroup = factory.make_NodeGroup()
559
560 host = factory.make_name('host')
561 username = factory.make_name('user')
562 password = factory.make_name('password')
563 self.assertRaises(
564 NoConnectionsAvailable, nodegroup.enlist_nodes_from_mscm,
565 host, username, password)
516566
=== modified file 'src/provisioningserver/rpc/cluster.py'
--- src/provisioningserver/rpc/cluster.py 2014-09-10 16:44:28 +0000
+++ src/provisioningserver/rpc/cluster.py 2014-09-11 11:22:16 +0000
@@ -377,3 +377,17 @@
377 errors = {377 errors = {
378 exceptions.NoIPFoundForMACAddress: b"NoIPFoundForMACAddress",378 exceptions.NoIPFoundForMACAddress: b"NoIPFoundForMACAddress",
379 }379 }
380
381
382class EnlistNodesFromMSCM(amp.Command):
383 """Probe for and enlist mscm machines attached to the cluster.
384
385 :since: 1.7
386 """
387 arguments = [
388 (b"host", amp.Unicode()),
389 (b"username", amp.Unicode()),
390 (b"password", amp.Unicode()),
391 ]
392 response = []
393 errors = {}
380394
=== modified file 'src/provisioningserver/rpc/clusterservice.py'
--- src/provisioningserver/rpc/clusterservice.py 2014-09-10 23:00:52 +0000
+++ src/provisioningserver/rpc/clusterservice.py 2014-09-11 11:22:16 +0000
@@ -29,6 +29,7 @@
29 ArchitectureRegistry,29 ArchitectureRegistry,
30 PowerTypeRegistry,30 PowerTypeRegistry,
31 )31 )
32from provisioningserver.drivers.hardware.mscm import probe_and_enlist_mscm
32from provisioningserver.drivers.hardware.seamicro import (33from provisioningserver.drivers.hardware.seamicro import (
33 probe_seamicro15k_and_enlist,34 probe_seamicro15k_and_enlist,
34 )35 )
@@ -266,6 +267,16 @@
266 raise exceptions.NoIPFoundForMACAddress(message)267 raise exceptions.NoIPFoundForMACAddress(message)
267 return {}268 return {}
268269
270 @cluster.EnlistNodesFromMSCM.responder
271 def enlist_nodes_from_mscm(self, host, username, password):
272 """enlist_nodes_from_mscm()
273
274 Implemention of
275 :py:class:`~provisioningserver.rpc.cluster.EnlistNodesFromMSCM`.
276 """
277 probe_and_enlist_mscm(host, username, password)
278 return {}
279
269280
270@implementer(IConnection)281@implementer(IConnection)
271class ClusterClient(Cluster):282class ClusterClient(Cluster):
272283
=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
--- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-10 23:00:52 +0000
+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-11 11:22:16 +0000
@@ -1256,3 +1256,30 @@
1256 probe_seamicro15k_and_enlist, MockCalledOnceWith(1256 probe_seamicro15k_and_enlist, MockCalledOnceWith(
1257 find_ip_via_arp.return_value, username, password,1257 find_ip_via_arp.return_value, username, password,
1258 power_control=power_control))1258 power_control=power_control))
1259
1260
1261class TestClusterProtocol_EnlistNodesFromMSCM(MAASTestCase):
1262
1263 def test__is_registered(self):
1264 protocol = Cluster()
1265 responder = protocol.locateResponder(
1266 cluster.EnlistNodesFromMSCM.commandName)
1267 self.assertIsNot(responder, None)
1268
1269 def test__calls_probe_and_enlist_mscm(self):
1270 probe_and_enlist_mscm = self.patch_autospec(
1271 clusterservice, 'probe_and_enlist_mscm')
1272
1273 host = factory.make_name('host')
1274 username = factory.make_name('user')
1275 password = factory.make_name('password')
1276
1277 call_responder(Cluster(), cluster.EnlistNodesFromMSCM, {
1278 'host': host,
1279 'username': username,
1280 'password': password,
1281 })
1282
1283 self.assertThat(
1284 probe_and_enlist_mscm, MockCalledOnceWith(
1285 host, username, password))
12591286
=== modified file 'src/provisioningserver/tasks.py'
--- src/provisioningserver/tasks.py 2014-09-10 17:00:43 +0000
+++ src/provisioningserver/tasks.py 2014-09-11 11:22:16 +0000
@@ -42,7 +42,6 @@
42 set_up_options_conf,42 set_up_options_conf,
43 setup_rndc,43 setup_rndc,
44 )44 )
45from provisioningserver.drivers.hardware.mscm import probe_and_enlist_mscm
46from provisioningserver.drivers.hardware.ucsm import probe_and_enlist_ucsm45from provisioningserver.drivers.hardware.ucsm import probe_and_enlist_ucsm
47from provisioningserver.logger import get_maas_logger46from provisioningserver.logger import get_maas_logger
4847
@@ -309,11 +308,3 @@
309def enlist_nodes_from_ucsm(url, username, password):308def enlist_nodes_from_ucsm(url, username, password):
310 """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_ucsm`. """309 """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_ucsm`. """
311 probe_and_enlist_ucsm(url, username, password)310 probe_and_enlist_ucsm(url, username, password)
312
313
314@task
315@log_task_events()
316@log_exception_text
317def enlist_nodes_from_mscm(host, username, password):
318 """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_mscm`. """
319 probe_and_enlist_mscm(host, username, password)
320311
=== modified file 'src/provisioningserver/tests/test_tasks.py'
--- src/provisioningserver/tests/test_tasks.py 2014-09-10 17:00:43 +0000
+++ src/provisioningserver/tests/test_tasks.py 2014-09-11 11:22:16 +0000
@@ -55,7 +55,6 @@
55 )55 )
56from provisioningserver.tags import MissingCredentials56from provisioningserver.tags import MissingCredentials
57from provisioningserver.tasks import (57from provisioningserver.tasks import (
58 enlist_nodes_from_mscm,
59 enlist_nodes_from_ucsm,58 enlist_nodes_from_ucsm,
60 refresh_secrets,59 refresh_secrets,
61 report_boot_images,60 report_boot_images,
@@ -403,14 +402,3 @@
403 mock = self.patch(tasks, 'probe_and_enlist_ucsm')402 mock = self.patch(tasks, 'probe_and_enlist_ucsm')
404 enlist_nodes_from_ucsm(url, username, password)403 enlist_nodes_from_ucsm(url, username, password)
405 self.assertThat(mock, MockCalledOnceWith(url, username, password))404 self.assertThat(mock, MockCalledOnceWith(url, username, password))
406
407
408class TestAddMSCM(PservTestCase):
409
410 def test_enlist_nodes_from_mscm(self):
411 host = 'host'
412 username = 'username'
413 password = 'password'
414 mock = self.patch(tasks, 'probe_and_enlist_mscm')
415 enlist_nodes_from_mscm(host, username, password)
416 self.assertThat(mock, MockCalledOnceWith(host, username, password))