summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorJulia Kreger <juliaashleykreger@gmail.com>2020-11-12 07:48:18 -0800
committerJulia Kreger <juliaashleykreger@gmail.com>2020-11-18 03:10:27 +0000
commited4abbd51929c8c847181af357e912c3ffe83d56 (patch)
treec78605682111562425d1334604380f342a581e6f /ironic
parente85c04ba3ea0d99683bd41b03b1b19757d93ffbb (diff)
downloadironic-ed4abbd51929c8c847181af357e912c3ffe83d56.tar.gz
Fix disk label to account for UEFI
Previously disk labels would not be populated if not explicitly set by an API user, which lead to a dangerous possible case, which sometimes could work, but was ultimately wrong to setup a UEFI booting machine with a BIOS MBR partition table. Not all systems support this, but UEFI systems are supposed to support GPT partition tables. We now fallback if no explicit override is set and assume GPT if the machine is set to UEFI mode. Change-Id: I001d8c6ee3b1d6c466c71ea5179bdbca9bdd692d
Diffstat (limited to 'ironic')
-rw-r--r--ironic/drivers/modules/deploy_utils.py8
-rw-r--r--ironic/tests/unit/drivers/modules/test_deploy_utils.py14
2 files changed, 21 insertions, 1 deletions
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index ae576c608..3c5465e3e 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -356,7 +356,13 @@ def get_disk_label(node):
:returns: the disk label or None if no disk label was specified.
"""
capabilities = utils.parse_instance_info_capabilities(node)
- return capabilities.get('disk_label')
+ label = capabilities.get('disk_label')
+ # NOTE(TheJulia): If the node is UEFI based, we should likely just default
+ # the table type to gpt as otherwise we rely upon the user to supply the
+ # right information, and for UEFI mode bios may work, but is wrong.
+ if label is None and boot_mode_utils.get_boot_mode(node) == 'uefi':
+ label = 'gpt'
+ return label
def get_pxe_boot_file(node):
diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
index f0b0e9621..41cb502ee 100644
--- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py
+++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
@@ -1039,6 +1039,20 @@ class ParseInstanceInfoCapabilitiesTestCase(tests_base.TestCase):
result = utils.get_disk_label(self.node)
self.assertEqual('gpt', result)
+ def test_get_disk_label_nothing_set(self):
+ inst_info = {'capabilities': {'cat': 'meows'}}
+ self.node.instance_info = inst_info
+ result = utils.get_disk_label(self.node)
+ self.assertIsNone(result)
+
+ def test_get_disk_label_uefi_mode(self):
+ inst_info = {'capabilities': {'cat': 'meows'}}
+ properties = {'capabilities': 'boot_mode:uefi'}
+ self.node.instance_info = inst_info
+ self.node.properties = properties
+ result = utils.get_disk_label(self.node)
+ self.assertEqual('gpt', result)
+
class TrySetBootDeviceTestCase(db_base.DbTestCase):