diff --git a/ironic/common/disk_partitioner.py b/ironic/common/disk_partitioner.py index f6b2e6b538..91f1c66c41 100644 --- a/ironic/common/disk_partitioner.py +++ b/ironic/common/disk_partitioner.py @@ -94,6 +94,9 @@ class DiskPartitioner(object): :returns: The partition number. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please + # also do the same modification in ironic-lib self._partitions.append({'size': size, 'type': part_type, 'fs_type': fs_type, @@ -107,10 +110,16 @@ class DiskPartitioner(object): partition layout. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please + # also do the same modification in ironic-lib return enumerate(self._partitions, 1) def _wait_for_disk_to_become_available(self, retries, max_retries, pids, stderr): + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please + # also do the same modification in ironic-lib retries[0] += 1 if retries[0] > max_retries: raise loopingcall.LoopingCallDone() @@ -135,6 +144,9 @@ class DiskPartitioner(object): def commit(self): """Write to the disk.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please + # also do the same modification in ironic-lib LOG.debug("Committing partitions to disk.") cmd_args = ['mklabel', self._disk_label] # NOTE(lucasagomes): Lead in with 1MiB to allow room for the @@ -187,6 +199,9 @@ def list_partitions(device): :returns: list of dictionaries (one per partition) with keys: number, start, end, size (in MiB), filesystem, flags """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib output = utils.execute( 'parted', '-s', '-m', device, 'unit', 'MiB', 'print', use_standard_locale=True, run_as_root=True)[0] diff --git a/ironic/common/images.py b/ironic/common/images.py index 5b00e659a8..2898f0913b 100644 --- a/ironic/common/images.py +++ b/ironic/common/images.py @@ -314,6 +314,9 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk, def qemu_img_info(path): """Return an object containing the parsed output from qemu-img info.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib if not os.path.exists(path): return imageutils.QemuImgInfo() @@ -324,6 +327,9 @@ def qemu_img_info(path): def convert_image(source, dest, out_format, run_as_root=False): """Convert image to other format.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib cmd = ('qemu-img', 'convert', '-O', out_format, source, dest) utils.execute(*cmd, run_as_root=run_as_root) diff --git a/ironic/common/utils.py b/ironic/common/utils.py index 8df146ec44..2775e14e5a 100644 --- a/ironic/common/utils.py +++ b/ironic/common/utils.py @@ -61,6 +61,9 @@ LOG = logging.getLogger(__name__) def _get_root_helper(): + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please + # also do the same modification in ironic-lib return 'sudo ironic-rootwrap %s' % CONF.rootwrap_config @@ -431,6 +434,9 @@ def mkfs(fs, path, label=None): :param path: Path to file or block device to format :param label: Volume label to use """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib if fs == 'swap': args = ['mkswap'] else: @@ -461,6 +467,9 @@ def mkfs(fs, path, label=None): def unlink_without_raise(path): + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib try: os.unlink(path) except OSError as e: @@ -550,12 +559,18 @@ def dd(src, dst, *args): :raises: processutils.ProcessExecutionError if it failed to run the process. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib LOG.debug("Starting dd process.") execute('dd', 'if=%s' % src, 'of=%s' % dst, *args, use_standard_locale=True, run_as_root=True, check_exit_code=[0]) def is_http_url(url): + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib url = url.lower() return url.startswith('http://') or url.startswith('https://') diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 840ec65aa8..0ab811e4c5 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -241,6 +241,9 @@ def get_disk_identifier(dev): :param dev: Path for the already populated disk device. :returns The Disk Identifier. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib disk_identifier = utils.execute('hexdump', '-s', '440', '-n', '4', '-e', '''\"0x%08x\"''', dev, @@ -275,6 +278,9 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb, path as Value for the partitions created by this method. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib LOG.debug("Starting to partition the disk device: %(dev)s " "for node %(node)s", {'dev': dev, 'node': node_uuid}) @@ -329,6 +335,9 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb, def is_block_device(dev): """Check whether a device is block or not.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib attempts = CONF.deploy.iscsi_verify_attempts for attempt in range(attempts): try: @@ -349,10 +358,16 @@ def is_block_device(dev): def dd(src, dst): """Execute dd from src to dst.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib utils.dd(src, dst, 'bs=%s' % CONF.deploy.dd_block_size, 'oflag=direct') def populate_image(src, dst): + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib data = images.qemu_img_info(src) if data.file_format == 'raw': dd(src, dst) @@ -362,6 +377,9 @@ def populate_image(src, dst): def block_uuid(dev): """Get UUID of a block device.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib out, _err = utils.execute('blkid', '-s', 'UUID', '-o', 'value', dev, run_as_root=True, check_exit_code=[0]) @@ -450,6 +468,9 @@ def get_dev(address, port, iqn, lun): def get_image_mb(image_path, virtual_size=True): """Get size of an image in Megabyte.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib mb = 1024 * 1024 if not virtual_size: image_byte = os.path.getsize(image_path) @@ -462,6 +483,9 @@ def get_image_mb(image_path, virtual_size=True): def get_dev_block_size(dev): """Get the device size in 512 byte sectors.""" + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib block_sz, cmderr = utils.execute('blockdev', '--getsz', dev, run_as_root=True, check_exit_code=[0]) return int(block_sz) @@ -476,6 +500,10 @@ def destroy_disk_metadata(dev, node_uuid): - the last 18KiB to clear GPT and other metadata like: LVM, veritas, MDADM, DMRAID, ... """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib + # NOTE(NobodyCam): This is needed to work around bug: # https://bugs.launchpad.net/ironic/+bug/1317647 LOG.debug("Start destroy disk metadata for node %(node)s.", @@ -530,6 +558,9 @@ def _get_configdrive(configdrive, node_uuid): configdrive file. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib # Check if the configdrive option is a HTTP URL or the content directly is_url = utils.is_http_url(configdrive) if is_url: @@ -606,6 +637,10 @@ def work_on_disk(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format, NOTE: If key exists but value is None, it means partition doesn't exist. """ + # NOTE(jlvillal): This function has been moved to ironic-lib. And is + # planned to be deleted here. If need to modify this function, please also + # do the same modification in ironic-lib + # the only way for preserve_ephemeral to be set to true is if we are # rebuilding an instance with --preserve_ephemeral. commit = not preserve_ephemeral