Merge ~andreserl/maas:ipmi_boot_type_2 into maas:master

Proposed by Andres Rodriguez
Status: Superseded
Proposed branch: ~andreserl/maas:ipmi_boot_type_2
Merge into: maas:master
Prerequisite: ~andreserl/maas:ipmi_boot_type
Diff against target: 116 lines (+21/-11)
5 files modified
src/maasserver/api/tests/test_enlistment.py (+1/-1)
src/metadataserver/user_data/templates/snippets/maas_ipmi_autodetect.py (+2/-2)
src/metadataserver/user_data/templates/snippets/tests/test_maas_ipmi_autodetect.py (+2/-2)
src/provisioningserver/drivers/power/ipmi.py (+13/-5)
src/provisioningserver/drivers/power/tests/test_ipmi.py (+3/-1)
Reviewer Review Type Date Requested Status
MAAS Lander Needs Fixing
Newell Jensen (community) Approve
Review via email: mp+342119@code.launchpad.net

This proposal supersedes a proposal from 2018-03-26.

Commit message

Change the IPMI_BOOT_TYPE options to be more user friendly.

This allows to specify the boot type with generalized options instead of forcing the user of freeipmi-tools terminology.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Looks good. One inline comment.

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

UNIT TESTS
-b ipmi_boot_type_2 lp:~andreserl/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/2081/console
COMMIT: 7d9a04fb65d162db82df511cd70fdd1064911a08

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

Unmerged commits

7d9a04f... by Andres Rodriguez

Change the options for power_boot_type so that API users can specify them by using auto|legacy|efi instead of freeipmi-tools specific <null>|EFI|PC-COMPATIBLE

f5180d0... by Andres Rodriguez

Fix lint

87fc9dd... by Andres Rodriguez

Add missing tests

8a1cb40... by Andres Rodriguez

Fix tests

e9ffd06... by Andres Rodriguez

Fix tests

bf35c2f... by Andres Rodriguez

LP: #1750622 - Add ability to force the BIOS boot method, and auto discover it during enlistment/commissioning

2b2a439... by Andres Rodriguez

Fix lint

07d5287... by Andres Rodriguez

Fix review comments

36cdc4b... by Andres Rodriguez

Fix test

9e45488... by Andres Rodriguez

Add/fix tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/api/tests/test_enlistment.py b/src/maasserver/api/tests/test_enlistment.py
index 5b636fb..2f03848 100644
--- a/src/maasserver/api/tests/test_enlistment.py
+++ b/src/maasserver/api/tests/test_enlistment.py
@@ -115,7 +115,7 @@ class EnlistmentAPITest(APITestCase.ForAnonymousAndUserAndAdmin):
115 # Add the default values.115 # Add the default values.
116 power_parameters['power_driver'] = 'LAN_2_0'116 power_parameters['power_driver'] = 'LAN_2_0'
117 power_parameters['mac_address'] = ''117 power_parameters['mac_address'] = ''
118 power_parameters['power_boot_type'] = ''118 power_parameters['power_boot_type'] = 'auto'
119 self.assertEqual(http.client.OK, response.status_code)119 self.assertEqual(http.client.OK, response.status_code)
120 [machine] = Machine.objects.filter(hostname=hostname)120 [machine] = Machine.objects.filter(hostname=hostname)
121 self.assertEqual(power_parameters, machine.power_parameters)121 self.assertEqual(power_parameters, machine.power_parameters)
diff --git a/src/metadataserver/user_data/templates/snippets/maas_ipmi_autodetect.py b/src/metadataserver/user_data/templates/snippets/maas_ipmi_autodetect.py
index a2caa8e..72e2496 100644
--- a/src/metadataserver/user_data/templates/snippets/maas_ipmi_autodetect.py
+++ b/src/metadataserver/user_data/templates/snippets/maas_ipmi_autodetect.py
@@ -321,8 +321,8 @@ def bmc_supports_lan2_0():
321def get_system_boot_type():321def get_system_boot_type():
322 """Detect if the system has boot EFI."""322 """Detect if the system has boot EFI."""
323 if os.path.isdir('/sys/firmware/efi'):323 if os.path.isdir('/sys/firmware/efi'):
324 return 'EFI'324 return 'efi'
325 return ''325 return 'auto'
326326
327327
328def main():328def main():
diff --git a/src/metadataserver/user_data/templates/snippets/tests/test_maas_ipmi_autodetect.py b/src/metadataserver/user_data/templates/snippets/tests/test_maas_ipmi_autodetect.py
index 37f52b6..86803eb 100644
--- a/src/metadataserver/user_data/templates/snippets/tests/test_maas_ipmi_autodetect.py
+++ b/src/metadataserver/user_data/templates/snippets/tests/test_maas_ipmi_autodetect.py
@@ -726,7 +726,7 @@ class TestGetSystemBootType(MAASTestCase):
726726
727 def test_get_system_boot_type_efi(self):727 def test_get_system_boot_type_efi(self):
728 """Test that returns ."""728 """Test that returns ."""
729 boot_type = 'EFI'729 boot_type = 'efi'
730 # path os.path.isdir to return True to simulate730 # path os.path.isdir to return True to simulate
731 # that /sys/firmware/efi exists.731 # that /sys/firmware/efi exists.
732 self.patch(os.path, "isdir").return_value = True732 self.patch(os.path, "isdir").return_value = True
@@ -735,7 +735,7 @@ class TestGetSystemBootType(MAASTestCase):
735735
736 def test_get_system_boot_type_non_efi(self):736 def test_get_system_boot_type_non_efi(self):
737 """Test """737 """Test """
738 boot_type = ''738 boot_type = 'auto'
739 # path os.path.isdir to return False to simulate739 # path os.path.isdir to return False to simulate
740 # that /sys/firmware/efi doesn't exist.740 # that /sys/firmware/efi doesn't exist.
741 self.patch(os.path, "isdir").return_value = False741 self.patch(os.path, "isdir").return_value = False
diff --git a/src/provisioningserver/drivers/power/ipmi.py b/src/provisioningserver/drivers/power/ipmi.py
index 84835e1..ee5b413 100644
--- a/src/provisioningserver/drivers/power/ipmi.py
+++ b/src/provisioningserver/drivers/power/ipmi.py
@@ -169,9 +169,9 @@ IPMI_DRIVER_CHOICES = [
169169
170class IPMI_BOOT_TYPE:170class IPMI_BOOT_TYPE:
171 # DEFAULT used to provide backwards compatibility171 # DEFAULT used to provide backwards compatibility
172 DEFAULT = ''172 DEFAULT = 'auto'
173 LEGACY = 'PC-COMPATIBLE'173 LEGACY = 'legacy'
174 EFI = 'EFI'174 EFI = 'efi'
175175
176176
177IPMI_BOOT_TYPE_CHOICES = [177IPMI_BOOT_TYPE_CHOICES = [
@@ -180,6 +180,11 @@ IPMI_BOOT_TYPE_CHOICES = [
180 [IPMI_BOOT_TYPE.EFI, "EFI boot"]180 [IPMI_BOOT_TYPE.EFI, "EFI boot"]
181 ]181 ]
182182
183IPMI_BOOT_TYPE_MAPPING = {
184 IPMI_BOOT_TYPE.EFI: 'EFI',
185 IPMI_BOOT_TYPE.LEGACY: 'PC-COMPATIBLE',
186 }
187
183188
184class IPMIPowerDriver(PowerDriver):189class IPMIPowerDriver(PowerDriver):
185190
@@ -216,10 +221,13 @@ class IPMIPowerDriver(PowerDriver):
216 env = shell.get_env_with_locale()221 env = shell.get_env_with_locale()
217 with NamedTemporaryFile("w+", encoding="utf-8") as tmp_config:222 with NamedTemporaryFile("w+", encoding="utf-8") as tmp_config:
218 # Write out the chassis configuration.223 # Write out the chassis configuration.
219 if power_boot_type is None or power_boot_type == '':224 if (power_boot_type is None
225 or power_boot_type == IPMI_BOOT_TYPE.DEFAULT):
220 tmp_config.write(IPMI_CONFIG)226 tmp_config.write(IPMI_CONFIG)
221 else:227 else:
222 tmp_config.write(IPMI_CONFIG_WITH_BOOT_TYPE % power_boot_type)228 tmp_config.write(
229 IPMI_CONFIG_WITH_BOOT_TYPE %
230 IPMI_BOOT_TYPE_MAPPING[power_boot_type])
223 tmp_config.flush()231 tmp_config.flush()
224 # Use it when running the chassis config command.232 # Use it when running the chassis config command.
225 # XXX: Not using call_and_check here because we233 # XXX: Not using call_and_check here because we
diff --git a/src/provisioningserver/drivers/power/tests/test_ipmi.py b/src/provisioningserver/drivers/power/tests/test_ipmi.py
index 6e7a4b9..548846e 100644
--- a/src/provisioningserver/drivers/power/tests/test_ipmi.py
+++ b/src/provisioningserver/drivers/power/tests/test_ipmi.py
@@ -26,6 +26,7 @@ from provisioningserver.drivers.power import (
26)26)
27from provisioningserver.drivers.power.ipmi import (27from provisioningserver.drivers.power.ipmi import (
28 IPMI_BOOT_TYPE,28 IPMI_BOOT_TYPE,
29 IPMI_BOOT_TYPE_MAPPING,
29 IPMI_CONFIG,30 IPMI_CONFIG,
30 IPMI_CONFIG_WITH_BOOT_TYPE,31 IPMI_CONFIG_WITH_BOOT_TYPE,
31 IPMI_ERRORS,32 IPMI_ERRORS,
@@ -379,6 +380,7 @@ class TestIPMIPowerDriver(MAASTestCase):
379 self.assertThat(380 self.assertThat(
380 tmpfile.write,381 tmpfile.write,
381 MockCalledOnceWith(382 MockCalledOnceWith(
382 IPMI_CONFIG_WITH_BOOT_TYPE % IPMI_BOOT_TYPE.EFI))383 IPMI_CONFIG_WITH_BOOT_TYPE % IPMI_BOOT_TYPE_MAPPING[
384 IPMI_BOOT_TYPE.EFI]))
383 self.assertThat(tmpfile.flush, MockCalledOnceWith())385 self.assertThat(tmpfile.flush, MockCalledOnceWith())
384 self.assertThat(tmpfile.__exit__, MockCalledOnceWith(None, None, None))386 self.assertThat(tmpfile.__exit__, MockCalledOnceWith(None, None, None))

Subscribers

People subscribed via source and target branches