コード例 #1
0
def _message_format(msg, image_info, device, partition_uuids):
    """Helper method to get and populate different messages."""
    message = None
    result_msg = msg
    if image_info.get('image_type') == 'partition':
        root_uuid = partition_uuids.get('root uuid')
        efi_system_partition_uuid = (
            partition_uuids.get('efi system partition uuid'))
        if (image_info.get('deploy_boot_mode') == 'uefi'
                and image_info.get('boot_option') == 'local'):
            result_msg = msg + 'root_uuid={} efi_system_partition_uuid={}'
            message = result_msg.format(image_info['id'], device, root_uuid,
                                        efi_system_partition_uuid)
        else:
            result_msg = msg + 'root_uuid={}'
            message = result_msg.format(image_info['id'], device, root_uuid)
    else:
        try:
            # NOTE(TheJulia): ironic-lib disk_utils.get_disk_identifier
            # can raise OSError if hexdump is not found.
            root_uuid = disk_utils.get_disk_identifier(device)
            result_msg = msg + 'root_uuid={}'
            message = result_msg.format(image_info['id'], device, root_uuid)
        except OSError as e:
            LOG.warning(
                'Failed to call get_disk_identifier: '
                'Unable to obtain the root_uuid parameter: '
                'The hexdump tool may be missing in IPA: %s', e)
            message = result_msg.format(image_info['id'], device)
    return message
コード例 #2
0
ファイル: deploy_utils.py プロジェクト: zdj6373/ironic
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}
コード例 #3
0
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}
コード例 #4
0
def _message_format(msg, image_info, device, partition_uuids):
    """Helper method to get and populate different messages."""
    message = None
    result_msg = msg
    if image_info.get('image_type') == 'partition':
        root_uuid = partition_uuids.get('root uuid')
        efi_system_partition_uuid = (
            partition_uuids.get('efi system partition uuid'))
        if (image_info.get('deploy_boot_mode') == 'uefi'
                and image_info.get('boot_option') == 'local'):
            result_msg = msg + 'root_uuid={} efi_system_partition_uuid={}'
            message = result_msg.format(image_info['id'], device,
                                        root_uuid,
                                        efi_system_partition_uuid)
        else:
            result_msg = msg + 'root_uuid={}'
            message = result_msg.format(image_info['id'], device, root_uuid)
    else:
        try:
            # NOTE(TheJulia): ironic-lib disk_utils.get_disk_identifier
            # can raise OSError if hexdump is not found.
            root_uuid = disk_utils.get_disk_identifier(device)
            result_msg = msg + 'root_uuid={}'
            message = result_msg.format(image_info['id'], device, root_uuid)
        except OSError as e:
            LOG.warning('Failed to call get_disk_identifier: '
                        'Unable to obtain the root_uuid parameter: '
                        'The hexdump tool may be missing in IPA: %s', e)
            message = result_msg.format(image_info['id'], device)
    return message
コード例 #5
0
ファイル: deploy_utils.py プロジェクト: bharathshetty4/ironic
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}
コード例 #6
0
    def _fix_up_partition_uuids(self, image_info, device):
        if self.partition_uuids is None:
            self.partition_uuids = {}

        if image_info.get('image_type') == 'partition':
            return

        try:
            root_uuid = disk_utils.get_disk_identifier(device)
        except OSError as e:
            LOG.warning('Failed to call get_disk_identifier: '
                        'Unable to obtain the root_uuid parameter: '
                        'The hexdump tool may be missing in IPA: %s', e)
        else:
            self.partition_uuids['root uuid'] = root_uuid
コード例 #7
0
ファイル: deploy_utils.py プロジェクト: hmonika/ironic
def deploy_disk_image(address, port, iqn, lun, image_path, node_uuid):
    """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.
    :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)

    return {"disk identifier": disk_identifier}