def test_specified_partition_table_type_disk_label_ignored_with_uefi( self, mock_boot_mode): # In case of invalid boot mode specified we fallback to ramdisk boot # mode node = {'instance_info': {'capabilities': 'disk_label:msdos'}} label = utils.get_partition_table_type_from_specs(node) self.assertEqual('gpt', label) mock_boot_mode.assert_has_calls([])
def test_specified_partition_table_type_with_disk_label(self, mock_boot_mode): node = { 'properties': { 'capabilities': 'disk_label:gpt' } } label = utils.get_partition_table_type_from_specs(node) self.assertEqual('gpt', label) mock_boot_mode.assert_has_calls([])
def _write_partition_image(image, image_info, device): """Call disk_util to create partition and write the partition image. :param image: Local path to image file to be written to the partition. If ``None``, the image is not populated. :param image_info: Image information dictionary. :param device: The device name, as a string, on which to store the image. Example: '/dev/sda' :raises: InvalidCommandParamsError if the partition is too small for the provided image. :raises: ImageWriteError if writing the image to disk encounters any error. """ # Retrieve the cached node as it has the latest information # and allows us to also sanity check the deployment so we don't end # up writing MBR when we're in UEFI mode. cached_node = hardware.get_cached_node() node_uuid = image_info.get('node_uuid') preserve_ep = image_info['preserve_ephemeral'] configdrive = image_info['configdrive'] boot_option = image_info.get('boot_option', 'local') boot_mode = utils.get_node_boot_mode(cached_node) disk_label = utils.get_partition_table_type_from_specs(cached_node) root_mb = image_info['root_mb'] cpu_arch = hardware.dispatch_to_managers('get_cpus').architecture if image is not None: image_mb = disk_utils.get_image_mb(image) if image_mb > int(root_mb): msg = ('Root partition is too small for requested image. Image ' 'virtual size: {} MB, Root size: {} MB').format( image_mb, root_mb) raise errors.InvalidCommandParamsError(msg) try: return disk_utils.work_on_disk(device, root_mb, image_info['swap_mb'], image_info['ephemeral_mb'], image_info['ephemeral_format'], image, node_uuid, preserve_ephemeral=preserve_ep, configdrive=configdrive, boot_option=boot_option, boot_mode=boot_mode, disk_label=disk_label, cpu_arch=cpu_arch) except processutils.ProcessExecutionError as e: raise errors.ImageWriteError(device, e.exit_code, e.stdout, e.stderr)
def test_specified_partition_table_type_gpt(self, mock_boot_mode): node = {} label = utils.get_partition_table_type_from_specs(node) self.assertEqual('gpt', label) mock_boot_mode.assert_called_once_with(node)