Merge "Revert "Software raid: mbr/gpt partition table alternative""
This commit is contained in:
commit
af1e32ba41
@ -1443,19 +1443,6 @@ class GenericHardwareManager(HardwareManager):
|
||||
LOG.debug("No target_raid_config found")
|
||||
return {}
|
||||
|
||||
partition_table_type = 'msdos'
|
||||
|
||||
# If explicitely specified by caller let's follow orders
|
||||
instance_info = node.get('instance_info', {})
|
||||
capabilities = instance_info.get('capabilities', {})
|
||||
specified_table_type = capabilities.get('disk_label')
|
||||
if specified_table_type:
|
||||
if specified_table_type not in ['msdos', 'gpt']:
|
||||
msg = ("Invalid disk_label capability. "
|
||||
"Should either be 'msdos' or 'gpt'")
|
||||
raise errors.SoftwareRAIDError(msg)
|
||||
partition_table_type = specified_table_type
|
||||
|
||||
# No 'software' controller: do nothing. If 'controller' is
|
||||
# set to 'software' on only one of the drives, the validation
|
||||
# code will catch it.
|
||||
@ -1488,14 +1475,15 @@ class GenericHardwareManager(HardwareManager):
|
||||
partitions)
|
||||
raise errors.SoftwareRAIDError(msg)
|
||||
|
||||
# Create an MBR or GPT partition table on each disk.
|
||||
parted_start_dict = {}
|
||||
# Create an MBR partition table on each disk.
|
||||
# TODO(arne_wiebalck): Check if GPT would work as well.
|
||||
for block_device in block_devices:
|
||||
LOG.info("Creating partition table on {}".format(
|
||||
block_device.name))
|
||||
try:
|
||||
utils.execute('parted', block_device.name, '-s', '--',
|
||||
'mklabel', partition_table_type)
|
||||
'mklabel', 'msdos')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
msg = "Failed to create partition table on {}: {}".format(
|
||||
block_device.name, e)
|
||||
|
@ -2710,29 +2710,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_create_configuration(self, mocked_execute):
|
||||
self._test_create_configuration(mocked_execute, 'msdos')
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_create_configuration_disk_label_specified(
|
||||
self, mocked_execute):
|
||||
|
||||
# Override gpt default choice with msdos
|
||||
node = {
|
||||
'uuid': 'hello',
|
||||
'instance_info': {
|
||||
'capabilities': {
|
||||
'disk_label': 'gpt'
|
||||
}
|
||||
}
|
||||
}
|
||||
self._test_create_configuration(mocked_execute, 'msdos')
|
||||
self._test_create_configuration(mocked_execute, 'gpt', node)
|
||||
|
||||
def _test_create_configuration(self, mocked_execute,
|
||||
expected_partition_table_type, node=None):
|
||||
if node is None:
|
||||
node = self.node
|
||||
|
||||
node = self.node
|
||||
raid_config = {
|
||||
"logical_disks": [
|
||||
{
|
||||
@ -2769,10 +2747,10 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
|
||||
mocked_execute.assert_has_calls([
|
||||
mock.call('parted', '/dev/sda', '-s', '--', 'mklabel',
|
||||
expected_partition_table_type),
|
||||
'msdos'),
|
||||
mock.call('sgdisk', '-F', '/dev/sda'),
|
||||
mock.call('parted', '/dev/sdb', '-s', '--', 'mklabel',
|
||||
expected_partition_table_type),
|
||||
'msdos'),
|
||||
mock.call('sgdisk', '-F', '/dev/sdb'),
|
||||
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
|
||||
'mkpart', 'primary', '42s', '10GiB'),
|
||||
@ -3031,41 +3009,6 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
self.hardware.create_configuration,
|
||||
self.node, [])
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_create_configuration_bad_disk_label(self, mocked_execute):
|
||||
|
||||
# Override gpt default choice with msdos
|
||||
node = {
|
||||
'uuid': 'hello',
|
||||
'instance_info': {
|
||||
'capabilities': {
|
||||
'disk_label': 'invalid'
|
||||
}
|
||||
}
|
||||
}
|
||||
# pass a sensible target_raid_config
|
||||
raid_config = {
|
||||
"logical_disks": [
|
||||
{
|
||||
"size_gb": "100",
|
||||
"raid_level": "1",
|
||||
"controller": "software",
|
||||
},
|
||||
{
|
||||
"size_gb": "MAX",
|
||||
"raid_level": "0",
|
||||
"controller": "software",
|
||||
},
|
||||
]
|
||||
}
|
||||
node['target_raid_config'] = raid_config
|
||||
|
||||
error_regex = \
|
||||
"Invalid disk_label capability. Should either be 'msdos' or 'gpt'"
|
||||
self.assertRaisesRegex(errors.SoftwareRAIDError, error_regex,
|
||||
self.hardware.create_configuration,
|
||||
node, [])
|
||||
|
||||
def test_create_configuration_empty_target_raid_config(self):
|
||||
self.node['target_raid_config'] = {}
|
||||
result = self.hardware.create_configuration(self.node, [])
|
||||
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
features:
|
||||
- Adds the ability to specify the partition table type when creating RAID.
|
||||
When not specified, the type is set to ``msdos`` (MBR).
|
Loading…
Reference in New Issue
Block a user