def deploy_disk_image(address, port, iqn, lun, image_path, node_uuid, configdrive=None): """All-in-one function to deploy a whole disk image to a node. :param address: The iSCSI IP address. :param port: The iSCSI port number. :param iqn: The iSCSI qualified name. :param lun: The iSCSI logical unit number. :param image_path: Path for the instance's disk image. :param node_uuid: node's uuid. Used for logging. Currently not in use by this function but could be used in the future. :param configdrive: Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL. :returns: a dictionary containing the key 'disk identifier' to identify the disk which was used for deployment. """ with _iscsi_setup_and_handle_errors(address, port, iqn, lun) as dev: disk_utils.populate_image(image_path, dev) disk_identifier = disk_utils.get_disk_identifier(dev) if configdrive: disk_utils.create_config_drive_partition(node_uuid, dev, configdrive) return {'disk identifier': disk_identifier}
def deploy_disk_image(address, port, iqn, lun, image_path, node_uuid, configdrive=None, conv_flags=None): """All-in-one function to deploy a whole disk image to a node. :param address: The iSCSI IP address. :param port: The iSCSI port number. :param iqn: The iSCSI qualified name. :param lun: The iSCSI logical unit number. :param image_path: Path for the instance's disk image. :param node_uuid: node's uuid. :param configdrive: Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL. :param conv_flags: Optional. Add a flag that will modify the behaviour of the image copy to disk. :returns: a dictionary containing the key 'disk identifier' to identify the disk which was used for deployment. """ with _iscsi_setup_and_handle_errors(address, port, iqn, lun) as dev: disk_utils.populate_image(image_path, dev, conv_flags=conv_flags) if configdrive: disk_utils.create_config_drive_partition(node_uuid, dev, configdrive) disk_identifier = disk_utils.get_disk_identifier(dev) return {'disk identifier': disk_identifier}
def prepare_image(self, image_info=None, configdrive=None): """Asynchronously prepares specified image on local OS install device. In this case, 'prepare' means make local machine completely ready to reboot to the image specified by image_info. Downloads and writes an image to disk if necessary. Also writes a configdrive to disk if the configdrive parameter is specified. :param image_info: Image information dictionary. :param configdrive: A string containing the location of the config drive as a URL OR the contents (as gzip/base64) of the configdrive. Optional, defaults to None. :raises: ImageDownloadError if the image download encounters an error. :raises: ImageChecksumError if the checksum of the local image does not match the checksum as reported by glance in image_info. :raises: ImageWriteError if writing the image fails. :raises: InstanceDeployFailure if failed to create config drive. large to store on the given device. """ LOG.debug('Preparing image %s', image_info['id']) device = hardware.dispatch_to_managers('get_os_install_device') disk_format = image_info.get('disk_format') stream_raw_images = image_info.get('stream_raw_images', False) # don't write image again if already cached if self.cached_image_id != image_info['id']: if self.cached_image_id is not None: LOG.debug('Already had %s cached, overwriting', self.cached_image_id) if stream_raw_images and disk_format == 'raw': if image_info.get('image_type') == 'partition': self.partition_uuids = _write_partition_image( None, image_info, device) stream_to = self.partition_uuids['partitions']['root'] else: stream_to = device self._stream_raw_image_onto_device(image_info, stream_to) else: self._cache_and_write_image(image_info, device) # the configdrive creation is taken care by ironic-lib's # work_on_disk(). if image_info.get('image_type') != 'partition': if configdrive is not None: # Will use dummy value of 'local' for 'node_uuid', # if it is not available. This is to handle scenario # wherein new IPA is being used with older version # of Ironic that did not pass 'node_uuid' in 'image_info' node_uuid = image_info.get('node_uuid', 'local') disk_utils.create_config_drive_partition( node_uuid, device, configdrive) msg = 'image ({}) written to device {} ' result_msg = _message_format(msg, image_info, device, self.partition_uuids) LOG.info(result_msg) return result_msg
def deploy_disk_image(address, port, iqn, lun, image_path, node_uuid, configdrive=None): """All-in-one function to deploy a whole disk image to a node. :param address: The iSCSI IP address. :param port: The iSCSI port number. :param iqn: The iSCSI qualified name. :param lun: The iSCSI logical unit number. :param image_path: Path for the instance's disk image. :param node_uuid: node's uuid. Used for logging. Currently not in use by this function but could be used in the future. :param configdrive: Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL. :returns: a dictionary containing the key 'disk identifier' to identify the disk which was used for deployment. """ with _iscsi_setup_and_handle_errors(address, port, iqn, lun) as dev: disk_utils.populate_image(image_path, dev) disk_identifier = disk_utils.get_disk_identifier(dev) if configdrive: disk_utils.create_config_drive_partition(node_uuid, dev, configdrive) return {'disk identifier': disk_identifier}
def prepare_image(self, image_info=None, configdrive=None): """Asynchronously prepares specified image on local OS install device. In this case, 'prepare' means make local machine completely ready to reboot to the image specified by image_info. Downloads and writes an image to disk if necessary. Also writes a configdrive to disk if the configdrive parameter is specified. :param image_info: Image information dictionary. :param configdrive: A string containing the location of the config drive as a URL OR the contents (as gzip/base64) of the configdrive. Optional, defaults to None. :raises: ImageDownloadError if the image download encounters an error. :raises: ImageChecksumError if the checksum of the local image does not match the checksum as reported by glance in image_info. :raises: ImageWriteError if writing the image fails. :raises: InstanceDeployFailure if failed to create config drive. large to store on the given device. """ LOG.debug('Preparing image %s', image_info['id']) device = hardware.dispatch_to_managers('get_os_install_device') disk_format = image_info.get('disk_format') stream_raw_images = image_info.get('stream_raw_images', False) # don't write image again if already cached if self.cached_image_id != image_info['id']: if self.cached_image_id is not None: LOG.debug('Already had %s cached, overwriting', self.cached_image_id) if stream_raw_images and disk_format == 'raw': if image_info.get('image_type') == 'partition': self.partition_uuids = _write_partition_image(None, image_info, device) stream_to = self.partition_uuids['partitions']['root'] else: stream_to = device self._stream_raw_image_onto_device(image_info, stream_to) else: self._cache_and_write_image(image_info, device) _validate_partitioning(device) # the configdrive creation is taken care by ironic-lib's # work_on_disk(). if image_info.get('image_type') != 'partition': if configdrive is not None: # Will use dummy value of 'local' for 'node_uuid', # if it is not available. This is to handle scenario # wherein new IPA is being used with older version # of Ironic that did not pass 'node_uuid' in 'image_info' node_uuid = image_info.get('node_uuid', 'local') disk_utils.create_config_drive_partition(node_uuid, device, configdrive) msg = 'image ({}) written to device {} ' result_msg = _message_format(msg, image_info, device, self.partition_uuids) LOG.info(result_msg) return result_msg