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
1=== modified file 'src/maasserver/rpc/nodes.py'
2--- src/maasserver/rpc/nodes.py 2014-09-10 16:20:31 +0000
3+++ src/maasserver/rpc/nodes.py 2014-09-22 12:05:24 +0000
4@@ -33,6 +33,7 @@
5 NoSuchNode,
6 )
7 from provisioningserver.utils.twisted import synchronous
8+import simplejson as json
9
10
11 @synchronous
12@@ -128,6 +129,10 @@
13 form = AdminNodeWithMACAddressesForm(data_query_dict)
14 if form.is_valid():
15 node = form.save()
16+ # We have to explicitly save the power parameters; the form
17+ # won't do it for us.
18+ node.power_parameters = json.loads(power_parameters)
19+ node.save()
20 return node
21 else:
22 raise ValidationError(form.errors)
23
24=== modified file 'src/maasserver/rpc/tests/test_nodes.py'
25--- src/maasserver/rpc/tests/test_nodes.py 2014-09-19 03:44:04 +0000
26+++ src/maasserver/rpc/tests/test_nodes.py 2014-09-22 12:05:24 +0000
27@@ -25,6 +25,7 @@
28 RunningEventLoopFixture,
29 )
30 from maasserver.testing.factory import factory
31+from maasserver.testing.orm import reload_object
32 from maasserver.testing.testcase import MAASServerTestCase
33 from provisioningserver.drivers import PowerTypeRegistry
34 from provisioningserver.rpc.cluster import DescribePowerTypes
35@@ -66,7 +67,7 @@
36 cluster,
37 architecture,
38 power_type,
39- ''
40+ {},
41 ),
42 (
43 node.nodegroup,
44@@ -106,3 +107,26 @@
45 self.assertRaises(
46 NodeAlreadyExists, create_node, cluster.uuid, architecture,
47 power_type, power_parameters, [mac_addresses[0]])
48+
49+ def test__saves_power_parameters(self):
50+ cluster = factory.make_NodeGroup()
51+ cluster.accept()
52+ self.prepare_cluster_rpc(cluster)
53+
54+ mac_addresses = [
55+ factory.make_mac_address() for _ in range(3)]
56+ architecture = make_usable_architecture(self)
57+ power_type = random.choice(self.power_types)['name']
58+ power_parameters = {
59+ factory.make_name('key'): factory.make_name('value')
60+ for _ in range(3)
61+ }
62+
63+ node = create_node(
64+ cluster.uuid, architecture, power_type, dumps(power_parameters),
65+ mac_addresses)
66+
67+ # Reload the object from the DB so that we're sure its power
68+ # parameters are being persisted.
69+ node = reload_object(node)
70+ self.assertEqual(power_parameters, node.power_parameters)