Merge lp:~newell-jensen/maas/fix-1516065-1.9 into lp:maas/1.9

Proposed by Newell Jensen
Status: Merged
Approved by: Gavin Panella
Approved revision: 4504
Merged at revision: 4504
Proposed branch: lp:~newell-jensen/maas/fix-1516065-1.9
Merge into: lp:maas/1.9
Diff against target: 97 lines (+23/-12)
2 files modified
src/provisioningserver/drivers/power/ipmi.py (+11/-5)
src/provisioningserver/drivers/power/tests/test_ipmi.py (+12/-7)
To merge this branch: bzr merge lp:~newell-jensen/maas/fix-1516065-1.9
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+278086@code.launchpad.net

Commit message

Do not fail to power manage a machine if BMC does not support changing the boot order.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/drivers/power/ipmi.py'
2--- src/provisioningserver/drivers/power/ipmi.py 2015-11-17 19:49:40 +0000
3+++ src/provisioningserver/drivers/power/ipmi.py 2015-11-19 22:57:18 +0000
4@@ -26,6 +26,7 @@
5 PowerDriver,
6 PowerFatalError,
7 )
8+from provisioningserver.logger import get_maas_logger
9 from provisioningserver.utils import shell
10 from provisioningserver.utils.network import find_ip_via_arp
11 from provisioningserver.utils.shell import (
12@@ -42,6 +43,9 @@
13 """
14
15
16+maaslog = get_maas_logger("drivers.power.ipmi")
17+
18+
19 def is_set(setting):
20 return not (setting is None or setting == "" or setting.isspace())
21
22@@ -63,7 +67,8 @@
23 return env
24
25 @staticmethod
26- def _issue_ipmi_chassis_config_command(command, change, address, env):
27+ def _issue_ipmi_chassis_config_command(
28+ command, power_change, power_address, env):
29 with NamedTemporaryFile() as tmp_config:
30 # Write out the chassis configuration.
31 tmp_config.write(IPMI_CONFIG)
32@@ -78,18 +83,19 @@
33 if "password invalid" in stderr:
34 raise PowerAuthError("Invalid password.")
35 if process.returncode != 0:
36- raise PowerFatalError(
37- "Failed to power %s %s: %s" % (change, address, stderr))
38+ maaslog.warning(
39+ 'Failed to change the boot order to PXE %s: %s' % (
40+ power_address, stderr))
41
42 @staticmethod
43- def _issue_ipmi_power_command(command, change, address, env):
44+ def _issue_ipmi_power_command(command, power_change, power_address, env):
45 command = tuple(command) # For consistency when testing.
46 try:
47 output = call_and_check(command, env=env)
48 except ExternalProcessError as e:
49 raise PowerFatalError(
50 "Failed to power %s %s: %s" % (
51- change, address, e.output_as_unicode))
52+ power_change, power_address, e.output_as_unicode))
53 else:
54 if 'on' in output:
55 return 'on'
56
57=== modified file 'src/provisioningserver/drivers/power/tests/test_ipmi.py'
58--- src/provisioningserver/drivers/power/tests/test_ipmi.py 2015-11-17 19:49:40 +0000
59+++ src/provisioningserver/drivers/power/tests/test_ipmi.py 2015-11-19 22:57:18 +0000
60@@ -268,7 +268,7 @@
61 ipmipower_command, env=env))
62 self.expectThat(result, Equals('other'))
63
64- def test__issue_ipmi_command_issues_raises_power_auth_error(self):
65+ def test__issue_ipmi_command_raises_power_fatal_error(self):
66 _, _, _, _, _, _, _, context = make_parameters()
67 ipmi_power_driver = IPMIPowerDriver()
68 popen_mock = self.patch(ipmi_module, 'Popen')
69@@ -280,17 +280,22 @@
70 PowerAuthError, ipmi_power_driver._issue_ipmi_command,
71 'on', **context)
72
73- def test__issue_ipmi_command_issues_raises_power_fatal_error(self):
74+ def test__issue_ipmi_command_logs_maaslog_warning(self):
75 _, _, _, _, _, _, _, context = make_parameters()
76 ipmi_power_driver = IPMIPowerDriver()
77 popen_mock = self.patch(ipmi_module, 'Popen')
78 process = popen_mock.return_value
79- process.communicate.return_value = (None, '')
80+ process.communicate.return_value = (None, 'maaslog error')
81 process.returncode = -1
82-
83- self.assertRaises(
84- PowerFatalError, ipmi_power_driver._issue_ipmi_command,
85- 'on', **context)
86+ maaslog = self.patch(ipmi_module, 'maaslog')
87+ self.patch(ipmi_power_driver, '_issue_ipmi_power_command')
88+
89+ ipmi_power_driver._issue_ipmi_command('on', **context)
90+
91+ self.assertThat(
92+ maaslog.warning, MockCalledOnceWith(
93+ 'Failed to change the boot order to PXE %s: %s' % (
94+ context['power_address'], 'maaslog error')))
95
96 def test__issue_ipmi_command_issues_catches_external_process_error(self):
97 _, _, _, _, _, _, _, context = make_parameters()

Subscribers

People subscribed via source and target branches