Merge "Check GPT table with sgdisk insread of partprobe"
This commit is contained in:
commit
1562dcf9de
|
@ -741,12 +741,10 @@ def _fix_gpt_structs(device, node_uuid):
|
||||||
commands fail.
|
commands fail.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
output, err = utils.execute('partprobe', device,
|
output, _err = utils.execute('sgdisk', '-v', device, run_as_root=True)
|
||||||
use_standard_locale=True,
|
|
||||||
run_as_root=True)
|
|
||||||
|
|
||||||
search_str = "fix the GPT to use all of the space"
|
search_str = "it doesn't reside\nat the end of the disk"
|
||||||
if search_str in err:
|
if search_str in output:
|
||||||
utils.execute('sgdisk', '-e', device, run_as_root=True)
|
utils.execute('sgdisk', '-e', device, run_as_root=True)
|
||||||
except (processutils.UnknownArgumentError,
|
except (processutils.UnknownArgumentError,
|
||||||
processutils.ProcessExecutionError, OSError) as e:
|
processutils.ProcessExecutionError, OSError) as e:
|
||||||
|
|
|
@ -1038,18 +1038,17 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
|
||||||
self.assertEqual(1, mock_log.call_count)
|
self.assertEqual(1, mock_log.call_count)
|
||||||
|
|
||||||
def test_fix_gpt_structs_fix_required(self, mock_execute):
|
def test_fix_gpt_structs_fix_required(self, mock_execute):
|
||||||
partprobe_err = """
|
sgdisk_v_output = """
|
||||||
Error: The backup GPT table is not at the end of the disk, as it should be.
|
Problem: The secondary header's self-pointer indicates that it doesn't reside
|
||||||
This might mean that another operating system believes the disk is smaller.
|
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
|
||||||
Fix, by moving the backup to the end (and removing the old backup)?
|
option on the experts' menu to adjust the secondary header's and partition
|
||||||
Warning: Not all of the space available to /dev/sdb appears to be used,
|
table's locations.
|
||||||
you can fix the GPT to use all of the space (an extra 581456476 blocks)
|
|
||||||
or continue with the current setting?
|
Identified 1 problems!
|
||||||
"""
|
"""
|
||||||
mock_execute.return_value = ('', partprobe_err)
|
mock_execute.return_value = (sgdisk_v_output, '')
|
||||||
execute_calls = [
|
execute_calls = [
|
||||||
mock.call('partprobe', '/dev/fake', use_standard_locale=True,
|
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
||||||
run_as_root=True),
|
|
||||||
mock.call('sgdisk', '-e', '/dev/fake', run_as_root=True)
|
mock.call('sgdisk', '-e', '/dev/fake', run_as_root=True)
|
||||||
]
|
]
|
||||||
disk_utils._fix_gpt_structs('/dev/fake', self.node_uuid)
|
disk_utils._fix_gpt_structs('/dev/fake', self.node_uuid)
|
||||||
|
@ -1059,8 +1058,7 @@ or continue with the current setting?
|
||||||
mock_execute.return_value = ('', '')
|
mock_execute.return_value = ('', '')
|
||||||
|
|
||||||
disk_utils._fix_gpt_structs('/dev/fake', self.node_uuid)
|
disk_utils._fix_gpt_structs('/dev/fake', self.node_uuid)
|
||||||
mock_execute.assert_called_once_with('partprobe', '/dev/fake',
|
mock_execute.assert_called_once_with('sgdisk', '-v', '/dev/fake',
|
||||||
use_standard_locale=True,
|
|
||||||
run_as_root=True)
|
run_as_root=True)
|
||||||
|
|
||||||
@mock.patch.object(disk_utils.LOG, 'error', autospec=True)
|
@mock.patch.object(disk_utils.LOG, 'error', autospec=True)
|
||||||
|
@ -1070,8 +1068,7 @@ or continue with the current setting?
|
||||||
'Failed to fix GPT data structures on disk',
|
'Failed to fix GPT data structures on disk',
|
||||||
disk_utils._fix_gpt_structs,
|
disk_utils._fix_gpt_structs,
|
||||||
self.dev, self.node_uuid)
|
self.dev, self.node_uuid)
|
||||||
mock_execute.assert_called_once_with('partprobe', '/dev/fake',
|
mock_execute.assert_called_once_with('sgdisk', '-v', '/dev/fake',
|
||||||
use_standard_locale=True,
|
|
||||||
run_as_root=True)
|
run_as_root=True)
|
||||||
self.assertEqual(1, mock_log.call_count)
|
self.assertEqual(1, mock_log.call_count)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue