Merge ~troyanov/maas:ipmi-power-off-mode-settings into maas:master

Proposed by Anton Troyanov
Status: Merged
Approved by: Anton Troyanov
Approved revision: aba365a591d3c79fdd2bb18a2d5e81f8fc8836ae
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~troyanov/maas:ipmi-power-off-mode-settings
Merge into: maas:master
Diff against target: 43 lines (+15/-0)
2 files modified
src/provisioningserver/drivers/power/ipmi.py (+13/-0)
src/provisioningserver/tests/test_power_driver_command.py (+2/-0)
Reviewer Review Type Date Requested Status
Peter Makowski Approve
Adam Collard (community) Approve
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+455689@code.launchpad.net

Commit message

fix: add power-off-mode to ipmi settings

Description of the change

Existing behaviour was:

```
if power_off_mode == "soft":
  ipmipower_command.append("--soft")
else:
  ipmipower_command.append("--off")
```

This basically mimics the same approach that was exposed via API, where for the method `def power_off(self, request, system_id)` we had "hard" to be the default value:

```
stop_mode = request.POST.get("stop_mode", "hard")
```

And also the Node model has defaults as "hard":
`def stop(self, user=None, stop_mode="hard", comment=None)`

The name for the exposed property is "power-off-mode" as thats how existing IPMI driver wants it (not the "stop_mode")
```
power_info.power_parameters["power_off_mode"] = stop_mode
```

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

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

UNIT TESTS
-b ipmi-power-off-mode-settings lp:~troyanov/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 7a0f6d02c4ed71ed5a558c9536b8de3a15bcf309

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

UNIT TESTS
-b ipmi-power-off-mode-settings lp:~troyanov/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 30c7dc590e3d3c369fce2135e3963b8b7fe04a10

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

UNIT TESTS
-b ipmi-power-off-mode-settings lp:~troyanov/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: aba365a591d3c79fdd2bb18a2d5e81f8fc8836ae

review: Approve
Revision history for this message
Adam Collard (adam-collard) :
review: Approve
Revision history for this message
Peter Makowski (petermakowski) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/provisioningserver/drivers/power/ipmi.py b/src/provisioningserver/drivers/power/ipmi.py
index f3f0806..752ae66 100644
--- a/src/provisioningserver/drivers/power/ipmi.py
+++ b/src/provisioningserver/drivers/power/ipmi.py
@@ -233,6 +233,11 @@ IPMI_WORKAROUND_FLAG_CHOICES = [
233 ["", "None"],233 ["", "None"],
234]234]
235235
236IPMI_POWER_OFF_MODE_CHOICES = [
237 ["soft", "Soft power off"],
238 ["hard", "Power off"],
239]
240
236241
237@enum.unique242@enum.unique
238class IPMI_PRIVILEGE_LEVEL(enum.Enum):243class IPMI_PRIVILEGE_LEVEL(enum.Enum):
@@ -306,6 +311,14 @@ class IPMIPowerDriver(PowerDriver):
306 make_setting_field(311 make_setting_field(
307 "mac_address", "Power MAC", scope=SETTING_SCOPE.NODE312 "mac_address", "Power MAC", scope=SETTING_SCOPE.NODE
308 ),313 ),
314 make_setting_field(
315 "power_off_mode",
316 "Power off mode",
317 field_type="choice",
318 choices=IPMI_POWER_OFF_MODE_CHOICES,
319 default="hard",
320 required=False,
321 ),
309 ]322 ]
310 ip_extractor = make_ip_extractor("power_address")323 ip_extractor = make_ip_extractor("power_address")
311 wait_time = (4, 8, 16, 32)324 wait_time = (4, 8, 16, 32)
diff --git a/src/provisioningserver/tests/test_power_driver_command.py b/src/provisioningserver/tests/test_power_driver_command.py
index 93aaace..3ea8a5a 100644
--- a/src/provisioningserver/tests/test_power_driver_command.py
+++ b/src/provisioningserver/tests/test_power_driver_command.py
@@ -111,6 +111,8 @@ class TestPowerDriverCommand(MAASTestCase):
111 "opensesspriv",111 "opensesspriv",
112 "--workaround-flags",112 "--workaround-flags",
113 "authcap",113 "authcap",
114 "--power-off-mode",
115 "hard",
114 ]116 ]
115 )117 )
116118

Subscribers

People subscribed via source and target branches