Merge ~newell-jensen/maas:redfish-commissioning into maas:master

Proposed by Newell Jensen
Status: Merged
Approved by: Andres Rodriguez
Approved revision: b6c5321734fffc45f718933e453f051b3b5bfbb3
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~newell-jensen/maas:redfish-commissioning
Merge into: maas:master
Diff against target: 74 lines (+33/-4)
2 files modified
src/maasserver/api/nodes.py (+15/-3)
src/maasserver/api/tests/test_api.py (+18/-1)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
MAAS Lander Approve
Review via email: mp+361754@code.launchpad.net

Commit message

Only update the power parameters in enlistment if the power type is 'ipmi' or 'manual'. This makes it so other power types do not have their parameters overwritten.

Description of the change

* Allows a user to update an enlisted node to a power type other than 'ipmi' or 'manual' and commission that node without the power type parameters being overwritten.

* Tested in the CI with IPMI and Redfish power type machines.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b redfish-commissioning lp:~newell-jensen/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: ec8b1d4fa68ab949097d002aea61d0bd1163c02e

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

If the machine is set to redfish and you commission, the bmc password will be changed but that won’t be reflected In MAAS.

review: Needs Fixing
Revision history for this message
Newell Jensen (newell-jensen) wrote :

> If the machine is set to redfish and you commission, the bmc password will be
> changed but that won’t be reflected In MAAS.

Steps performed:

1. Enlisted machine had IPMI power type and parameters.
2. Power type changed to Redfish. To have this work, the username and password for Redfish had to be provided along with the node id (power parameters for Redfish power type).
3. Commissioned the machine. The power type and power parameters were not changed.
4. Deployed the machine.

Are you referring to the BMC password for the IPMI interface? Why would we care about that if the power type is Redfish and we are not saving the IPMI credentials anyways?

Revision history for this message
Lee Trager (ltrager) wrote :

Since we don't modify Redfish settings in the ephemeral environment we can leverage the existing skip_bmc_config option. Just modify the CommissionForm to set skip_bmc_config to True whenever the power type is redfish and the BMC autodetect code won't be run on the client.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Needs to be done the other way around where that is totally
Possible to do and use.

On Wed, Jan 23, 2019 at 2:47 PM Lee Trager <email address hidden> wrote:

> Since we don't modify Redfish settings in the ephemeral environment we can
> leverage the existing skip_bmc_config option. Just modify the
> CommissionForm to set skip_bmc_config to True whenever the power type is
> redfish and the BMC autodetect code won't be run on the client.
> --
> https://code.launchpad.net/~newell-jensen/maas/+git/maas/+merge/361754
> You are reviewing the proposed merge of
> ~newell-jensen/maas:redfish-commissioning into maas:master.
>
--
Andres Rodriguez
Engineering Manager, MAAS
Canonical USA, Inc.

6dccce4... by Newell Jensen

Add redfish power type to parameters that will have their credentials saved.

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b redfish-commissioning lp:~newell-jensen/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 6dccce4e1a01f8194ae58112f945338dd156ce55

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

see inline.

review: Needs Information
b6c5321... by Newell Jensen

Handle redfish power type in the store_node_power_parameters so it can work properly when the booting needs to resend multiple requests.

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b redfish-commissioning lp:~newell-jensen/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: b6c5321734fffc45f718933e453f051b3b5bfbb3

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/nodes.py b/src/maasserver/api/nodes.py
2index 737f73c..cd29572 100644
3--- a/src/maasserver/api/nodes.py
4+++ b/src/maasserver/api/nodes.py
5@@ -1,4 +1,4 @@
6-# Copyright 2012-2018 Canonical Ltd. This software is licensed under the
7+# Copyright 2012-2019 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 __all__ = [
11@@ -168,7 +168,11 @@ def store_node_power_parameters(node, request):
12
13 The parameters should be JSON, passed with key `power_parameters`.
14 """
15- power_type = request.POST.get("power_type", None)
16+ # Don't overwrite redfish power type with ipmi.
17+ if node.power_type == 'redfish':
18+ power_type = node.power_type
19+ else:
20+ power_type = request.POST.get("power_type", None)
21 if power_type is None:
22 return
23
24@@ -185,7 +189,15 @@ def store_node_power_parameters(node, request):
25 power_parameters = request.POST.get("power_parameters", None)
26 if power_parameters and not power_parameters.isspace():
27 try:
28- node.power_parameters = json.loads(power_parameters)
29+ power_parameters = json.loads(power_parameters)
30+ if power_type == 'redfish':
31+ node.power_parameters = {
32+ **node.instance_power_parameters,
33+ **power_parameters
34+ }
35+ else:
36+ node.power_parameters = power_parameters
37+
38 except ValueError:
39 raise MAASAPIBadRequest("Failed to parse JSON power_parameters")
40
41diff --git a/src/maasserver/api/tests/test_api.py b/src/maasserver/api/tests/test_api.py
42index b36cfc9..c918ff8 100644
43--- a/src/maasserver/api/tests/test_api.py
44+++ b/src/maasserver/api/tests/test_api.py
45@@ -1,4 +1,4 @@
46-# Copyright 2012-2018 Canonical Ltd. This software is licensed under the
47+# Copyright 2012-2019 Canonical Ltd. This software is licensed under the
48 # GNU Affero General Public License version 3 (see the file LICENSE).
49
50 """Test maasserver API."""
51@@ -180,6 +180,23 @@ class TestStoreNodeParameters(APITestCase.ForUser):
52 self.assertEqual({}, self.node.power_parameters)
53 self.save.assert_has_calls([])
54
55+ def test_power_type_redish(self):
56+ power_parameters = {"foo": [1, 2, 3]}
57+ self.request.POST = {
58+ "power_type": 'ipmi',
59+ "power_parameters": json.dumps(power_parameters),
60+ }
61+ self.node.power_type = 'redfish'
62+ self.node.instance_power_parameters = {
63+ 'node_id': '1',
64+ }
65+ store_node_power_parameters(self.node, self.request)
66+ self.assertEqual('redfish', self.node.power_type)
67+ self.assertEqual({
68+ **power_parameters,
69+ **self.node.instance_power_parameters}, self.node.power_parameters)
70+ self.save.assert_has_calls([])
71+
72 def test_power_type_set_but_no_parameters(self):
73 # When power_type is valid, it is set. However, if power_parameters is
74 # not specified, the node's power_parameters is left alone, and the

Subscribers

People subscribed via source and target branches