Example #1
0
def _parse_instance_info(node):
    """Gets the instance specific Node deployment info.

    This method validates whether the 'instance_info' property of the
    supplied node contains the required or optional information properly
    for this driver to deploy images to the node.

    :param node: a target node of the deployment
    :returns:  the instance_info values of the node.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    """
    i_info = node.instance_info
    deploy_info = {}

    if i_info.get("irmc_boot_iso"):
        deploy_info["irmc_boot_iso"] = i_info["irmc_boot_iso"]

        if service_utils.is_image_href_ordinary_file_name(deploy_info["irmc_boot_iso"]):
            boot_iso = os.path.join(CONF.irmc.remote_image_share_root, deploy_info["irmc_boot_iso"])

            if not os.path.isfile(boot_iso):
                msg = _("Boot ISO file, %(boot_iso)s, " "not found for node: %(node)s.") % {
                    "boot_iso": boot_iso,
                    "node": node.uuid,
                }
                raise exception.InvalidParameterValue(msg)

    return deploy_info
Example #2
0
def _setup_deploy_iso(task, ramdisk_options):
    """Attaches virtual media and sets it as boot device.

    This method attaches the given deploy ISO as virtual media, prepares the
    arguments for ramdisk in virtual media floppy.

    :param task: a TaskManager instance containing the node to act on.
    :param ramdisk_options: the options to be passed to the ramdisk in virtual
        media floppy.
    :raises: ImageRefValidationFailed if no image service can handle specified
       href.
    :raises: ImageCreationFailed, if it failed while creating the floppy image.
    :raises: IRMCOperationError, if some operation on iRMC failed.
    :raises: InvalidParameterValue if the validation of the
        PowerInterface or ManagementInterface fails.
    """
    d_info = task.node.driver_info

    deploy_iso_href = d_info["irmc_deploy_iso"]
    if service_utils.is_image_href_ordinary_file_name(deploy_iso_href):
        deploy_iso_file = deploy_iso_href
    else:
        deploy_iso_file = _get_deploy_iso_name(task.node)
        deploy_iso_fullpathname = os.path.join(CONF.irmc.remote_image_share_root, deploy_iso_file)
        images.fetch(task.context, deploy_iso_href, deploy_iso_fullpathname)

    _setup_vmedia_for_boot(task, deploy_iso_file, ramdisk_options)
    manager_utils.node_set_boot_device(task, boot_devices.CDROM)
Example #3
0
def _parse_driver_info(node):
    """Gets the driver specific Node deployment info.

    This method validates whether the 'driver_info' property of the
    supplied node contains the required or optional information properly
    for this driver to deploy images to the node.

    :param node: a target node of the deployment
    :returns: the driver_info values of the node.
    :raises: MissingParameterValue, if any of the required parameters are
        missing.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    """
    d_info = node.driver_info
    deploy_info = {}

    deploy_info["irmc_deploy_iso"] = d_info.get("irmc_deploy_iso")
    error_msg = _("Error validating iRMC virtual media deploy. Some parameters" " were missing in node's driver_info")
    deploy_utils.check_for_missing_params(deploy_info, error_msg)

    if service_utils.is_image_href_ordinary_file_name(deploy_info["irmc_deploy_iso"]):
        deploy_iso = os.path.join(CONF.irmc.remote_image_share_root, deploy_info["irmc_deploy_iso"])
        if not os.path.isfile(deploy_iso):
            msg = _("Deploy ISO file, %(deploy_iso)s, " "not found for node: %(node)s.") % {
                "deploy_iso": deploy_iso,
                "node": node.uuid,
            }
            raise exception.InvalidParameterValue(msg)

    return deploy_info
Example #4
0
def _prepare_boot_iso(task, root_uuid):
    """Prepare a boot ISO to boot the node.

    :param task: a TaskManager instance containing the node to act on.
    :param root_uuid: the uuid of the root partition.
    :raises: MissingParameterValue, if any of the required parameters are
        missing.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    :raises: ImageCreationFailed, if creating boot ISO
       for BIOS boot_mode failed.
    """
    deploy_info = _parse_deploy_info(task.node)
    driver_internal_info = task.node.driver_internal_info

    # fetch boot iso
    if deploy_info.get("irmc_boot_iso"):
        boot_iso_href = deploy_info["irmc_boot_iso"]
        if service_utils.is_image_href_ordinary_file_name(boot_iso_href):
            driver_internal_info["irmc_boot_iso"] = boot_iso_href
        else:
            boot_iso_filename = _get_boot_iso_name(task.node)
            boot_iso_fullpathname = os.path.join(CONF.irmc.remote_image_share_root, boot_iso_filename)
            images.fetch(task.context, boot_iso_href, boot_iso_fullpathname)

            driver_internal_info["irmc_boot_iso"] = boot_iso_filename

    # create boot iso
    else:
        image_href = deploy_info["image_source"]
        image_props = ["kernel_id", "ramdisk_id"]
        image_properties = images.get_image_properties(task.context, image_href, image_props)
        kernel_href = task.node.instance_info.get("kernel") or image_properties["kernel_id"]
        ramdisk_href = task.node.instance_info.get("ramdisk") or image_properties["ramdisk_id"]

        deploy_iso_filename = _get_deploy_iso_name(task.node)
        deploy_iso = "file://" + os.path.join(CONF.irmc.remote_image_share_root, deploy_iso_filename)
        boot_mode = deploy_utils.get_boot_mode_for_deploy(task.node)
        kernel_params = CONF.pxe.pxe_append_params

        boot_iso_filename = _get_boot_iso_name(task.node)
        boot_iso_fullpathname = os.path.join(CONF.irmc.remote_image_share_root, boot_iso_filename)

        images.create_boot_iso(
            task.context,
            boot_iso_fullpathname,
            kernel_href,
            ramdisk_href,
            deploy_iso,
            root_uuid,
            kernel_params,
            boot_mode,
        )

        driver_internal_info["irmc_boot_iso"] = boot_iso_filename

    # save driver_internal_info['irmc_boot_iso']
    task.node.driver_internal_info = driver_internal_info
    task.node.save()
 def test_is_image_href_ordinary_file_name_false(self):
     for image in ('733d1c44-a2ea-414b-aca7-69decf20d810',
                   u'glance://\u0111eploy_iso',
                   u'http://\u0111eploy_iso',
                   u'https://\u0111eploy_iso',
                   u'file://\u0111eploy_iso',):
         result = service_utils.is_image_href_ordinary_file_name(image)
         self.assertFalse(result)
Example #6
0
def _prepare_boot_iso(task, root_uuid):
    """Prepare a boot ISO to boot the node.

    :param task: a TaskManager instance containing the node to act on.
    :param root_uuid: the uuid of the root partition.
    :raises: MissingParameterValue, if any of the required parameters are
        missing.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    :raises: ImageCreationFailed, if creating boot ISO
       for BIOS boot_mode failed.
    """
    deploy_info = _parse_deploy_info(task.node)
    driver_internal_info = task.node.driver_internal_info

    # fetch boot iso
    if deploy_info.get('irmc_boot_iso'):
        boot_iso_href = deploy_info['irmc_boot_iso']
        if service_utils.is_image_href_ordinary_file_name(boot_iso_href):
            driver_internal_info['irmc_boot_iso'] = boot_iso_href
        else:
            boot_iso_filename = _get_boot_iso_name(task.node)
            boot_iso_fullpathname = os.path.join(
                CONF.irmc.remote_image_share_root, boot_iso_filename)
            images.fetch(task.context, boot_iso_href, boot_iso_fullpathname)

            driver_internal_info['irmc_boot_iso'] = boot_iso_filename

    # create boot iso
    else:
        image_href = deploy_info['image_source']
        image_props = ['kernel_id', 'ramdisk_id']
        image_properties = images.get_image_properties(task.context,
                                                       image_href, image_props)
        kernel_href = (task.node.instance_info.get('kernel')
                       or image_properties['kernel_id'])
        ramdisk_href = (task.node.instance_info.get('ramdisk')
                        or image_properties['ramdisk_id'])

        deploy_iso_filename = _get_deploy_iso_name(task.node)
        deploy_iso = ('file://' + os.path.join(
            CONF.irmc.remote_image_share_root, deploy_iso_filename))
        boot_mode = deploy_utils.get_boot_mode_for_deploy(task.node)
        kernel_params = CONF.pxe.pxe_append_params

        boot_iso_filename = _get_boot_iso_name(task.node)
        boot_iso_fullpathname = os.path.join(CONF.irmc.remote_image_share_root,
                                             boot_iso_filename)

        images.create_boot_iso(task.context, boot_iso_fullpathname,
                               kernel_href, ramdisk_href, deploy_iso,
                               root_uuid, kernel_params, boot_mode)

        driver_internal_info['irmc_boot_iso'] = boot_iso_filename

    # save driver_internal_info['irmc_boot_iso']
    task.node.driver_internal_info = driver_internal_info
    task.node.save()
Example #7
0
 def test_is_image_href_ordinary_file_name_false(self):
     for image in (
             '733d1c44-a2ea-414b-aca7-69decf20d810',
             u'glance://\u0111eploy_iso',
             u'http://\u0111eploy_iso',
             u'https://\u0111eploy_iso',
             u'file://\u0111eploy_iso',
     ):
         result = service_utils.is_image_href_ordinary_file_name(image)
         self.assertFalse(result)
Example #8
0
def _parse_driver_info(node, mode='deploy'):
    """Gets the driver specific Node deployment info.

    This method validates whether the 'driver_info' property of the
    supplied node contains the required or optional information properly
    for this driver to deploy images to the node.

    :param node: a target node of the deployment
    :param mode: Label indicating a deploy or rescue operation being
                 carried out on the node. Supported values are
                 'deploy' and 'rescue'. Defaults to 'deploy'.
    :returns: the driver_info values of the node.
    :raises: MissingParameterValue, if any of the required parameters are
        missing.
    :raises: InvalidParameterValue, if any of the parameters have invalid
        value.
    """
    d_info = node.driver_info
    deploy_info = {}

    if mode == 'deploy':
        image_iso = d_info.get('irmc_deploy_iso')
        deploy_info['irmc_deploy_iso'] = image_iso
    else:
        image_iso = d_info.get('irmc_rescue_iso')
        deploy_info['irmc_rescue_iso'] = image_iso

    error_msg = (_("Error validating iRMC virtual media for %s. Some "
                   "parameters were missing in node's driver_info") % mode)
    deploy_utils.check_for_missing_params(deploy_info, error_msg)

    if service_utils.is_image_href_ordinary_file_name(image_iso):
        image_iso_file = os.path.join(CONF.irmc.remote_image_share_root,
                                      image_iso)
        if not os.path.isfile(image_iso_file):
            msg = (_("%(mode)s ISO file, %(iso_file)s, "
                     "not found for node: %(node)s.") % {
                         'mode': mode.capitalize(),
                         'iso_file': image_iso_file,
                         'node': node.uuid
                     })
            raise exception.InvalidParameterValue(msg)

    return deploy_info
Example #9
0
 def test_is_image_href_ordinary_file_name_true(self):
     image = u"\u0111eploy.iso"
     result = service_utils.is_image_href_ordinary_file_name(image)
     self.assertTrue(result)
 def test_is_image_href_ordinary_file_name_true(self):
     image = u"\u0111eploy.iso"
     result = service_utils.is_image_href_ordinary_file_name(image)
     self.assertTrue(result)