Merge lp:~gmb/maas/prob-mscm-power-params-testcase 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: 3047
Proposed branch: lp:~gmb/maas/prob-mscm-power-params-testcase
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 70 lines (+30/-1)
2 files modified
src/maasserver/rpc/nodes.py (+5/-0)
src/maasserver/rpc/tests/test_nodes.py (+25/-1)
To merge this branch: bzr merge lp:~gmb/maas/prob-mscm-power-params-testcase
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+235444@code.launchpad.net

Commit message

Fix the RPC create_node() utility, which didn't save node power parameters, unlike its API counterpart.

Power parameters need to be saved explicitly, since the NodeForms won't do it for us.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (20.0 KiB)

The attempt to merge lp:~gmb/maas/prob-mscm-power-params-testcase into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:1 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:2 http://nova.clouds.archive.ubuntu.com trusty-updates Release [59.7 kB]
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
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [120 kB]
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [84.7 kB]
Get:5 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [320 kB]
Get:6 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [203 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 788 kB in 0s (1,624 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 python-paramiko python-pexpect python-pip python-pocket-lint py...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/rpc/nodes.py'
--- src/maasserver/rpc/nodes.py 2014-09-10 16:20:31 +0000
+++ src/maasserver/rpc/nodes.py 2014-09-22 12:05:24 +0000
@@ -33,6 +33,7 @@
33 NoSuchNode,33 NoSuchNode,
34 )34 )
35from provisioningserver.utils.twisted import synchronous35from provisioningserver.utils.twisted import synchronous
36import simplejson as json
3637
3738
38@synchronous39@synchronous
@@ -128,6 +129,10 @@
128 form = AdminNodeWithMACAddressesForm(data_query_dict)129 form = AdminNodeWithMACAddressesForm(data_query_dict)
129 if form.is_valid():130 if form.is_valid():
130 node = form.save()131 node = form.save()
132 # We have to explicitly save the power parameters; the form
133 # won't do it for us.
134 node.power_parameters = json.loads(power_parameters)
135 node.save()
131 return node136 return node
132 else:137 else:
133 raise ValidationError(form.errors)138 raise ValidationError(form.errors)
134139
=== modified file 'src/maasserver/rpc/tests/test_nodes.py'
--- src/maasserver/rpc/tests/test_nodes.py 2014-09-19 03:44:04 +0000
+++ src/maasserver/rpc/tests/test_nodes.py 2014-09-22 12:05:24 +0000
@@ -25,6 +25,7 @@
25 RunningEventLoopFixture,25 RunningEventLoopFixture,
26 )26 )
27from maasserver.testing.factory import factory27from maasserver.testing.factory import factory
28from maasserver.testing.orm import reload_object
28from maasserver.testing.testcase import MAASServerTestCase29from maasserver.testing.testcase import MAASServerTestCase
29from provisioningserver.drivers import PowerTypeRegistry30from provisioningserver.drivers import PowerTypeRegistry
30from provisioningserver.rpc.cluster import DescribePowerTypes31from provisioningserver.rpc.cluster import DescribePowerTypes
@@ -66,7 +67,7 @@
66 cluster,67 cluster,
67 architecture,68 architecture,
68 power_type,69 power_type,
69 ''70 {},
70 ),71 ),
71 (72 (
72 node.nodegroup,73 node.nodegroup,
@@ -106,3 +107,26 @@
106 self.assertRaises(107 self.assertRaises(
107 NodeAlreadyExists, create_node, cluster.uuid, architecture,108 NodeAlreadyExists, create_node, cluster.uuid, architecture,
108 power_type, power_parameters, [mac_addresses[0]])109 power_type, power_parameters, [mac_addresses[0]])
110
111 def test__saves_power_parameters(self):
112 cluster = factory.make_NodeGroup()
113 cluster.accept()
114 self.prepare_cluster_rpc(cluster)
115
116 mac_addresses = [
117 factory.make_mac_address() for _ in range(3)]
118 architecture = make_usable_architecture(self)
119 power_type = random.choice(self.power_types)['name']
120 power_parameters = {
121 factory.make_name('key'): factory.make_name('value')
122 for _ in range(3)
123 }
124
125 node = create_node(
126 cluster.uuid, architecture, power_type, dumps(power_parameters),
127 mac_addresses)
128
129 # Reload the object from the DB so that we're sure its power
130 # parameters are being persisted.
131 node = reload_object(node)
132 self.assertEqual(power_parameters, node.power_parameters)