Merge ~andreserl/maas:2.3_chassis_config_on_power_on into maas:2.3

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: 8c67adcd2e62acc9cc8b5f55d17c29e57070d35d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~andreserl/maas:2.3_chassis_config_on_power_on
Merge into: maas:2.3
Diff against target: 116 lines (+10/-30)
2 files modified
src/provisioningserver/drivers/power/ipmi.py (+7/-7)
src/provisioningserver/drivers/power/tests/test_ipmi.py (+3/-23)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+343189@code.launchpad.net

Commit message

Backport 93d713cfaca91e27f9b72171cf3f3d057dbd95b0 from master.

Only issue ipmi_chassis_config on power on.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

selfie!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/drivers/power/ipmi.py b/src/provisioningserver/drivers/power/ipmi.py
2index 99b3e6e..219ee26 100644
3--- a/src/provisioningserver/drivers/power/ipmi.py
4+++ b/src/provisioningserver/drivers/power/ipmi.py
5@@ -302,19 +302,19 @@ class IPMIPowerDriver(PowerDriver):
6 common_args.extend(("-u", power_user))
7 common_args.extend(('-p', power_pass))
8
9- # Update the chassis config and power commands.
10- ipmi_chassis_config_command.extend(common_args)
11- ipmi_chassis_config_command.append('--commit')
12+ # Update the power commands with common args.
13 ipmipower_command.extend(common_args)
14
15- # Before changing state run the chassis config command.
16- if power_change in ("on", "off"):
17+ # Additional arguments for the power command.
18+ if power_change == 'on':
19+ # Update the chassis config commands and call it just when
20+ # powering on the machine.
21+ ipmi_chassis_config_command.extend(common_args)
22+ ipmi_chassis_config_command.append('--commit')
23 self._issue_ipmi_chassis_config_command(
24 ipmi_chassis_config_command, power_change, power_address,
25 power_boot_type)
26
27- # Additional arguments for the power command.
28- if power_change == 'on':
29 ipmipower_command.append('--cycle')
30 ipmipower_command.append('--on-if-off')
31 elif power_change == 'off':
32diff --git a/src/provisioningserver/drivers/power/tests/test_ipmi.py b/src/provisioningserver/drivers/power/tests/test_ipmi.py
33index 2172704..db1a855 100644
34--- a/src/provisioningserver/drivers/power/tests/test_ipmi.py
35+++ b/src/provisioningserver/drivers/power/tests/test_ipmi.py
36@@ -103,21 +103,9 @@ class TestIPMIPowerDriver(MAASTestCase):
37 context['mac_address'] = factory.make_mac_address()
38 context['power_address'] = random.choice((None, "", " "))
39
40- self.patch_autospec(driver, "_issue_ipmi_chassis_config_command")
41 self.patch_autospec(driver, "_issue_ipmipower_command")
42 driver._issue_ipmi_command(power_change, **context)
43
44- # The IP address is passed to _issue_ipmi_chassis_config_command.
45- self.assertThat(
46- driver._issue_ipmi_chassis_config_command,
47- MockCalledOnceWith(
48- ANY, power_change, ip_address,
49- power_boot_type=None))
50- # The IP address is also within the command passed to
51- # _issue_ipmi_chassis_config_command.
52- self.assertThat(
53- driver._issue_ipmi_chassis_config_command.call_args[0],
54- Contains(ip_address))
55 # The IP address is passed to _issue_ipmipower_command.
56 self.assertThat(
57 driver._issue_ipmipower_command,
58@@ -233,23 +221,19 @@ class TestIPMIPowerDriver(MAASTestCase):
59
60 def test__issue_ipmi_command_issues_power_off(self):
61 context = make_context()
62- ipmi_chassis_config_command = make_ipmi_chassis_config_command(
63- **context, tmp_config_name=ANY)
64 ipmipower_command = make_ipmipower_command(**context)
65 ipmipower_command += ('--off', )
66 ipmi_power_driver = IPMIPowerDriver()
67 env = select_c_utf8_locale()
68 popen_mock = self.patch(ipmi_module, 'Popen')
69 process = popen_mock.return_value
70- process.communicate.side_effect = [(b'', b''), (b'off', b'')]
71+ process.communicate.side_effect = [(b'off', b'')]
72 process.returncode = 0
73
74 result = ipmi_power_driver._issue_ipmi_command('off', **context)
75
76 self.expectThat(
77 popen_mock, MockCallsMatch(
78- call(ipmi_chassis_config_command, stdout=PIPE,
79- stderr=PIPE, env=env),
80 call(ipmipower_command, stdout=PIPE,
81 stderr=PIPE, env=env)))
82 self.expectThat(result, Equals('off'))
83@@ -257,23 +241,19 @@ class TestIPMIPowerDriver(MAASTestCase):
84 def test__issue_ipmi_command_issues_power_off_soft_mode(self):
85 context = make_context()
86 context['power_off_mode'] = 'soft'
87- ipmi_chassis_config_command = make_ipmi_chassis_config_command(
88- **context, tmp_config_name=ANY)
89 ipmipower_command = make_ipmipower_command(**context)
90 ipmipower_command += ('--soft', )
91 ipmi_power_driver = IPMIPowerDriver()
92 env = select_c_utf8_locale()
93 popen_mock = self.patch(ipmi_module, 'Popen')
94 process = popen_mock.return_value
95- process.communicate.side_effect = [(b'', b''), (b'off', b'')]
96+ process.communicate.side_effect = [(b'off', b'')]
97 process.returncode = 0
98
99 result = ipmi_power_driver._issue_ipmi_command('off', **context)
100
101 self.expectThat(
102 popen_mock, MockCallsMatch(
103- call(ipmi_chassis_config_command, stdout=PIPE,
104- stderr=PIPE, env=env),
105 call(ipmipower_command, stdout=PIPE,
106 stderr=PIPE, env=env)))
107 self.expectThat(result, Equals('off'))
108@@ -336,7 +316,7 @@ class TestIPMIPowerDriver(MAASTestCase):
109 ip_address = factory.make_ipv4_address()
110 find_ip_via_arp = self.patch(ipmi_module, 'find_ip_via_arp')
111 find_ip_via_arp.return_value = ip_address
112- power_change = random.choice(("on", "off"))
113+ power_change = "on"
114
115 context['mac_address'] = factory.make_mac_address()
116 context['power_address'] = random.choice((None, "", " "))

Subscribers

People subscribed via source and target branches