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
def _parse_instance_info(node): """Gets the instance and driver specific Node deployment info. This method validates whether the 'instance_info' and 'driver_info' property of the supplied node contains the required information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info and driver_info values. :raises: MissingParameterValue, image_source is missing in node's instance_info. Also raises same exception if kernel/ramdisk is missing in instance_info for non-glance images. """ info = {} info['image_source'] = node.instance_info.get('image_source') is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image') if not is_whole_disk_image: if not service_utils.is_glance_image(info['image_source']): info['kernel'] = node.instance_info.get('kernel') info['ramdisk'] = node.instance_info.get('ramdisk') error_msg = _("Cannot validate PXE bootloader. Some parameters were " "missing in node's instance_info.") deploy_utils.check_for_missing_params(info, error_msg) return info
def validate_pass_bootloader_info_input(task, input_params): """Validates the input sent with bootloader install info passthru. This method validates the input sent with bootloader install info passthru. :param task: A TaskManager object. :param input_params: A dictionary of params sent as input to passthru. :raises: InvalidParameterValue, if deploy key passed doesn't match the one stored in instance_info. :raises: MissingParameterValue, if some input is missing. """ params = { 'address': input_params.get('address'), 'key': input_params.get('key'), 'status': input_params.get('status') } msg = _("Some mandatory input missing in 'pass_bootloader_info' " "vendor passthru from ramdisk.") deploy_utils.check_for_missing_params(params, msg) deploy_key = task.node.instance_info['deploy_key'] if deploy_key != input_params.get('key'): raise exception.InvalidParameterValue( _("Deploy key %(key_sent)s does not match " "with %(expected_key)s") % { 'key_sent': input_params.get('key'), 'expected_key': deploy_key })
def validate_pass_bootloader_info_input(task, input_params): """Validates the input sent with bootloader install info passthru. This method validates the input sent with bootloader install info passthru. :param task: A TaskManager object. :param input_params: A dictionary of params sent as input to passthru. :raises: InvalidParameterValue, if deploy key passed doesn't match the one stored in instance_info. :raises: MissingParameterValue, if some input is missing. """ params = { "address": input_params.get("address"), "key": input_params.get("key"), "status": input_params.get("status"), } msg = _("Some mandatory input missing in 'pass_bootloader_info' " "vendor passthru from ramdisk.") deploy_utils.check_for_missing_params(params, msg) deploy_key = task.node.instance_info["deploy_key"] if deploy_key != input_params.get("key"): raise exception.InvalidParameterValue( _("Deploy key %(key_sent)s does not match " "with %(expected_key)s") % {"key_sent": input_params.get("key"), "expected_key": deploy_key} )
def _parse_instance_info(node): """Gets the instance and driver specific Node deployment info. This method validates whether the 'instance_info' and 'driver_info' property of the supplied node contains the required information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info and driver_info values. :raises: MissingParameterValue, image_source is missing in node's instance_info. Also raises same exception if kernel/ramdisk is missing in instance_info for non-glance images. """ info = {} info['image_source'] = node.instance_info.get('image_source') is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image') if not is_whole_disk_image: if not service_utils.is_glance_image(info['image_source']): info['kernel'] = node.instance_info.get('kernel') info['ramdisk'] = node.instance_info.get('ramdisk') error_msg = _("Cannot validate PXE bootloader. Some parameters were " "missing in node's instance_info.") deploy_utils.check_for_missing_params(info, error_msg) return info
def validate_http_provisioning_configuration(node): """Validate configuration options required to perform HTTP provisioning. :param node: an ironic node object :raises: MissingParameterValue if required option(s) is not set. """ image_source = node.instance_info.get('image_source') image_download_source = deploy_utils.get_image_download_source(node) if image_download_source not in ('swift', 'http', 'local'): raise exception.InvalidParameterValue( _('Invalid value for image_download_source: "%s". Valid values ' 'are swift, http or local.') % image_download_source) # NOTE(dtantsur): local HTTP configuration is required in two cases: # 1. Glance images with image_download_source == http # 2. File images (since we need to serve them to IPA) if (not image_source.startswith('file://') and image_download_source != 'local' and (not service_utils.is_glance_image(image_source) or image_download_source == 'swift')): return params = { '[deploy]http_url': CONF.deploy.http_url, '[deploy]http_root': CONF.deploy.http_root, '[deploy]http_image_subdir': CONF.deploy.http_image_subdir } error_msg = _('Node %s failed to validate http provisoning. Some ' 'configuration options were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
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 information for this driver to deploy images to, or rescue, the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info params_to_check = KERNEL_RAMDISK_LABELS[mode] d_info = {k: info.get(k) for k in params_to_check} if not any(d_info.values()): # NOTE(dtantsur): avoid situation when e.g. deploy_kernel comes from # driver_info but deploy_ramdisk comes from configuration, since it's # a sign of a potential operator's mistake. d_info = {k: getattr(CONF.conductor, k) for k in params_to_check} error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info and configuration") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} if mode == 'rescue': d_info['ilo_rescue_iso'] = info.get('ilo_rescue_iso') else: d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') error_msg = (_("Error validating iLO virtual media for %s. Some " "parameters were missing in node's driver_info") % mode) deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = node.instance_info i_info = {} i_info["image_source"] = info.get("image_source") is_whole_disk_image = node.driver_internal_info.get("is_whole_disk_image") if not is_whole_disk_image: if i_info["image_source"] and not glance_service_utils.is_glance_image(i_info["image_source"]): i_info["kernel"] = info.get("kernel") i_info["ramdisk"] = info.get("ramdisk") i_info["root_gb"] = info.get("root_gb") error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing" " in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) # Internal use only i_info["deploy_key"] = info.get("deploy_key") i_info["swap_mb"] = info.get("swap_mb", 0) i_info["ephemeral_gb"] = info.get("ephemeral_gb", 0) err_msg_invalid = _( "Cannot validate parameter for iSCSI deploy. " "Invalid parameter %(param)s. Reason: %(reason)s" ) for param in ("root_gb", "swap_mb", "ephemeral_gb"): try: int(i_info[param]) except ValueError: reason = _("%s is not an integer value.") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % {"param": param, "reason": reason}) if is_whole_disk_image: if int(i_info["swap_mb"]) > 0 or int(i_info["ephemeral_gb"]) > 0: err_msg_invalid = _("Cannot deploy whole disk image with " "swap or ephemeral size set") raise exception.InvalidParameterValue(err_msg_invalid) return i_info i_info["ephemeral_format"] = info.get("ephemeral_format") i_info["configdrive"] = info.get("configdrive") if i_info["ephemeral_gb"] and not i_info["ephemeral_format"]: i_info["ephemeral_format"] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get("preserve_ephemeral", False) try: i_info["preserve_ephemeral"] = strutils.bool_from_string(preserve_ephemeral, strict=True) except ValueError as e: raise exception.InvalidParameterValue(err_msg_invalid % {"param": "preserve_ephemeral", "reason": e}) return i_info
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
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 information for this driver to deploy images to the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} if mode == 'rescue': d_info['ilo_rescue_iso'] = info.get('ilo_rescue_iso') else: d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') error_msg = (_("Error validating iLO virtual media for %s. Some " "parameters were missing in node's driver_info") % mode) deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node # Validate node capabilities deploy_utils.validate_capabilities(node) if not task.driver.storage.should_write_image(task): # NOTE(TheJulia): There is no reason to validate # image properties if we will not be writing an image # in a boot from volume case. As such, return to the caller. LOG.debug( 'Skipping complete deployment interface validation ' 'for node %s as it is set to boot from a remote ' 'volume.', node.uuid) return params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue( _("image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) check_image_size(task, image_source) # Validate the root device hints try: root_device = node.properties.get('root_device') il_utils.parse_root_device_hints(root_device) except ValueError as e: raise exception.InvalidParameterValue( _('Failed to validate the root device hints for node ' '%(node)s. Error: %(error)s') % { 'node': node.uuid, 'error': e }) validate_image_proxies(node)
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 mode = deploy_utils.rescue_or_deploy_mode(node) iso_param = 'redfish_%s_iso' % mode iso_ref = d_info.get(iso_param) if iso_ref is not None: deploy_info = {iso_param: iso_ref} else: params_to_check = KERNEL_RAMDISK_LABELS[mode] deploy_info = { option: d_info.get(option) for option in params_to_check } if not any(deploy_info.values()): # NOTE(dtantsur): avoid situation when e.g. deploy_kernel comes # from driver_info but deploy_ramdisk comes from configuration, # since it's a sign of a potential operator's mistake. deploy_info = { k: getattr(CONF.conductor, k) for k in params_to_check } error_msg = _("Error validating Redfish virtual media. Some " "parameters were missing in node's driver_info") deploy_utils.check_for_missing_params(deploy_info, error_msg) deploy_info.update({ option: d_info.get(option, getattr(CONF.conductor, option, None)) for option in OPTIONAL_PROPERTIES }) if (d_info.get('config_via_removable') is None and d_info.get('config_via_floppy') is not None): LOG.warning( 'The config_via_floppy driver_info option is deprecated, ' 'use config_via_removable for node %s', node.uuid) deploy_info['config_via_removable'] = d_info['config_via_floppy'] deploy_info.update(redfish_utils.parse_driver_info(node)) return deploy_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = node.instance_info i_info = {} i_info['image_source'] = info.get('image_source') i_info['root_gb'] = info.get('root_gb') error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing" " in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) # Internal use only i_info['deploy_key'] = info.get('deploy_key') i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) i_info['ephemeral_format'] = info.get('ephemeral_format') i_info['configdrive'] = info.get('configdrive') err_msg_invalid = _("Cannot validate parameter for iSCSI deploy. " "Invalid parameter %(param)s. Reason: %(reason)s") for param in ('root_gb', 'swap_mb', 'ephemeral_gb'): try: int(i_info[param]) except ValueError: reason = _("'%s' is not an integer value.") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % { 'param': param, 'reason': reason }) if i_info['ephemeral_gb'] and not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = strutils.bool_from_string( preserve_ephemeral, strict=True) except ValueError as e: raise exception.InvalidParameterValue(err_msg_invalid % { 'param': 'preserve_ephemeral', 'reason': e }) return i_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node # Validate node capabilities deploy_utils.validate_capabilities(node) if not task.driver.storage.should_write_image(task): # NOTE(TheJulia): There is no reason to validate # image properties if we will not be writing an image # in a boot from volume case. As such, return to the caller. LOG.debug('Skipping complete deployment interface validation ' 'for node %s as it is set to boot from a remote ' 'volume.', node.uuid) return params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue(_( "image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) check_image_size(task, image_source) # Validate the root device hints try: root_device = node.properties.get('root_device') il_utils.parse_root_device_hints(root_device) except ValueError as e: raise exception.InvalidParameterValue( _('Failed to validate the root device hints for node ' '%(node)s. Error: %(error)s') % {'node': node.uuid, 'error': e}) validate_image_proxies(node)
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 mode = deploy_utils.rescue_or_deploy_mode(node) iso_param = f'{mode}_iso' iso_ref = driver_utils.get_agent_iso(node, deprecated_prefix='redfish', mode=mode) if iso_ref is not None: deploy_info = {iso_param: iso_ref} can_config = False else: # There was never a deprecated prefix for kernel/ramdisk deploy_info = driver_utils.get_agent_kernel_ramdisk(node, mode) error_msg = _("Error validating Redfish virtual media. Some " "parameters were missing in node's driver_info") deploy_utils.check_for_missing_params(deploy_info, error_msg) can_config = True deploy_info.update({ option: d_info.get(option, getattr(CONF.conductor, option, None)) for option in OPTIONAL_PROPERTIES }) if (d_info.get('config_via_removable') is None and d_info.get('config_via_floppy') is not None): LOG.warning( 'The config_via_floppy driver_info option is deprecated, ' 'use config_via_removable for node %s', node.uuid) deploy_info['config_via_removable'] = d_info['config_via_floppy'] deploy_info.update(redfish_utils.parse_driver_info(node)) # Configuration can be provided in one of two cases: # 1) A removable disk is requested. # 2) An ISO is built from a kernel/initramfs pair. deploy_info['can_provide_config'] = \ deploy_info.get('config_via_removable') or can_config return deploy_info
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 _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) kernel_params = driver_utils.get_kernel_append_params( node, default=CONF.irmc.kernel_append_params) if kernel_params is None: LOG.warning('Relying on [pxe]kernel_append_params in the iRMC ' 'hardware type is deprecated, please set ' '[irmc]kernel_append_params') kernel_params = CONF.pxe.kernel_append_params deploy_info['kernel_append_params'] = kernel_params return deploy_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = node.instance_info i_info = {} i_info['image_source'] = info.get('image_source') i_info['root_gb'] = info.get('root_gb') error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing" " in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) # Internal use only i_info['deploy_key'] = info.get('deploy_key') i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) i_info['ephemeral_format'] = info.get('ephemeral_format') err_msg_invalid = _("Cannot validate parameter for iSCSI deploy. " "Invalid parameter %(param)s. Reason: %(reason)s") for param in ('root_gb', 'swap_mb', 'ephemeral_gb'): try: int(i_info[param]) except ValueError: reason = _("'%s' is not an integer value.") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % {'param': param, 'reason': reason}) if i_info['ephemeral_gb'] and not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = strutils.bool_from_string( preserve_ephemeral, strict=True) except ValueError as e: raise exception.InvalidParameterValue(err_msg_invalid % {'param': 'preserve_ephemeral', 'reason': e}) return i_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue( _("image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) check_image_size(task, image_source) is_whole_disk_image = node.driver_internal_info.get( 'is_whole_disk_image') # TODO(sirushtim): Remove once IPA has support for partition images. if is_whole_disk_image is False: raise exception.InvalidParameterValue( _("Node %(node)s is configured to use the %(driver)s driver " "which currently does not support deploying partition " "images.") % { 'node': node.uuid, 'driver': node.driver }) # Validate the root device hints deploy_utils.parse_root_device_hints(node) # Validate node capabilities deploy_utils.validate_capabilities(node) validate_image_proxies(node)
def parse_driver_info(node): """Parses and creates Cisco driver info :param node: An Ironic node object. :returns: dictonary that contains node.driver_info parameter/values. :raises: MissingParameterValue if any required parameters are missing. """ info = {} for param in REQUIRED_PROPERTIES: info[param] = node.driver_info.get(param) error_msg = _("cisco driver requries these parameter to be set.") deploy_utils.check_for_missing_params(info, error_msg) return info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node params = {} image_source = node.instance_info.get("image_source") params["instance_info.image_source"] = image_source error_msg = _("Node %s failed to validate deploy image info. Some " "parameters were missing") % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get("image_checksum"): raise exception.MissingParameterValue( _("image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid ) check_image_size(task, image_source) is_whole_disk_image = node.driver_internal_info.get("is_whole_disk_image") # TODO(sirushtim): Remove once IPA has support for partition images. if is_whole_disk_image is False: raise exception.InvalidParameterValue( _( "Node %(node)s is configured to use the %(driver)s driver " "which currently does not support deploying partition " "images." ) % {"node": node.uuid, "driver": node.driver} ) # Validate the root device hints deploy_utils.parse_root_device_hints(node) # Validate node capabilities deploy_utils.validate_capabilities(node) validate_image_proxies(node)
def parse_driver_info(node): """Parses and creates Cisco driver info. :param node: An Ironic node object. :returns: dictionary that contains node.driver_info parameter/values. :raises: MissingParameterValue if any required parameters are missing. """ info = {} for param in REQUIRED_PROPERTIES: info[param] = node.driver_info.get(param) error_msg = (_("%s driver requires these parameters to be set in the " "node's driver_info.") % node.driver) deploy_utils.check_for_missing_params(info, error_msg) return info
def _validate_boot_into_iso(self, task, kwargs): """Validates if attach_iso can be called and if inputs are proper.""" if not (task.node.provision_state == states.MANAGEABLE or task.node.maintenance is True): msg = _( "The requested action 'boot_into_iso' can be performed " "only when node %(node_uuid)s is in %(state)s state or " "in 'maintenance' mode" ) % {"node_uuid": task.node.uuid, "state": states.MANAGEABLE} raise exception.InvalidStateRequested(msg) d_info = {"boot_iso_href": kwargs.get("boot_iso_href")} error_msg = _( "Error validating input for boot_into_iso vendor " "passthru. Some parameters were not provided: " ) deploy_utils.check_for_missing_params(d_info, error_msg) deploy_utils.validate_image_properties(task.context, {"image_source": kwargs.get("boot_iso_href")}, [])
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 information for this driver to deploy images to the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} if mode == 'rescue' and info.get('ilo_rescue_iso'): d_info['ilo_rescue_iso'] = info.get('ilo_rescue_iso') elif mode == 'deploy' and info.get('ilo_deploy_iso'): d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') else: params_to_check = KERNEL_RAMDISK_LABELS[mode] d_info = {option: info.get(option) for option in params_to_check} if not any(d_info.values()): # NOTE(dtantsur): avoid situation when e.g. deploy_kernel comes # from driver_info but deploy_ramdisk comes from configuration, # since it's a sign of a potential operator's mistake. d_info = {k: getattr(CONF.conductor, k) for k in params_to_check} error_msg = (_("Error validating iLO virtual media for %(mode)s. " "Either 'ilo_%(mode)s_iso' is missing or " "DEPLOY_RAMDISK_PROPERTIES or RESCUE_RAMDISK_PROPERTIES " "were missing in node's driver_info.") % { 'mode': mode }) deploy_utils.check_for_missing_params(d_info, error_msg) d_info.update({ option: info.get(option, getattr(CONF.conductor, option, None)) for option in OPTIONAL_PROPERTIES }) return d_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue( _("image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) check_image_size(task, image_source) # Validate the root device hints try: root_device = node.properties.get('root_device') il_utils.parse_root_device_hints(root_device) except ValueError as e: raise exception.InvalidParameterValue( _('Failed to validate the root device hints for node ' '%(node)s. Error: %(error)s') % { 'node': node.uuid, 'error': e }) # Validate node capabilities deploy_utils.validate_capabilities(node) validate_image_proxies(node)
def _validate_boot_into_iso(self, task, kwargs): """Validates if attach_iso can be called and if inputs are proper.""" if not (task.node.provision_state == states.MANAGEABLE or task.node.maintenance is True): msg = (_("The requested action 'boot_into_iso' can be performed " "only when node %(node_uuid)s is in %(state)s state or " "in 'maintenance' mode") % {'node_uuid': task.node.uuid, 'state': states.MANAGEABLE}) raise exception.InvalidStateRequested(msg) d_info = {'boot_iso_href': kwargs.get('boot_iso_href')} error_msg = _("Error validating input for boot_into_iso vendor " "passthru. Some parameters were not provided: ") deploy_utils.check_for_missing_params(d_info, error_msg) deploy_utils.validate_image_properties( task.context, {'image_source': kwargs.get('boot_iso_href')}, [])
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info d_info = {k: info.get(k) for k in ("deploy_kernel", "deploy_ramdisk")} error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
def _parse_driver_info(self, node, mode='deploy'): """Gets the node specific deploy/rescue info. This method validates whether the 'driver_info' property of the supplied node contains the required information for this driver to deploy images to the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info if mode == 'rescue': params_to_check = RESCUE_PROPERTIES_UEFI_HTTPS_BOOT.keys() else: params_to_check = REQUIRED_PROPERTIES_UEFI_HTTPS_BOOT.keys() deploy_info = {option: info.get(option) for option in params_to_check} if not any(deploy_info.values()): # NOTE(dtantsur): avoid situation when e.g. deploy_kernel comes # from driver_info but deploy_ramdisk comes from configuration, # since it's a sign of a potential operator's mistake. deploy_info = {k: getattr(CONF.conductor, k.replace('ilo_', '')) for k in params_to_check} deploy_info.update( {k: info.get(k, getattr(CONF.conductor, k.replace('ilo_', ''), None)) for k in OPTIONAL_PROPERTIES}) self._validate_hrefs(deploy_info) error_msg = (_("Error validating %s for iLO UEFI HTTPS boot. Some " "parameters were missing in node's driver_info") % mode) deploy_utils.check_for_missing_params(deploy_info, error_msg) deploy_info.update(ilo_common.parse_driver_info(node)) return deploy_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue(_( "image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) check_image_size(task, image_source) # Validate the root device hints try: root_device = node.properties.get('root_device') il_utils.parse_root_device_hints(root_device) except ValueError as e: raise exception.InvalidParameterValue( _('Failed to validate the root device hints for node ' '%(node)s. Error: %(error)s') % {'node': node.uuid, 'error': e}) # Validate node capabilities deploy_utils.validate_capabilities(node) validate_image_proxies(node)
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue """ node = task.node params = _get_boot_files(node) error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) _parse_driver_info(node)
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue """ node = task.node params = {} params["driver_info.deploy_kernel"] = node.driver_info.get("deploy_kernel") params["driver_info.deploy_ramdisk"] = node.driver_info.get("deploy_ramdisk") params["instance_info.image_source"] = node.instance_info.get("image_source") error_msg = _("Node %s failed to validate deploy image info. Some " "parameters were missing") % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info d_info = {k: info.get(k) for k in ('deploy_kernel', 'deploy_ramdisk')} error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue """ node = task.node params = _get_boot_files(node) error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) _parse_driver_info(node)
def validate(self, task): """Validate the driver-specific Node deployment info.""" task.driver.boot.validate(task) node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if not iwdi and deploy_utils.get_boot_option(node) == "netboot": raise exception.InvalidParameterValue(_( "Node %(node)s is configured to use the %(driver)s driver " "which does not support netboot.") % {'node': node.uuid, 'driver': node.driver}) params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
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 _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
def validate_http_provisioning_configuration(node): """Validate configuration options required to perform HTTP provisioning. :param node: an ironic node object :raises: MissingParameterValue if required option(s) is not set. """ image_source = node.instance_info.get('image_source') if (not service_utils.is_glance_image(image_source) or CONF.agent.image_download_source != 'http'): return params = { '[deploy]http_url': CONF.deploy.http_url, '[deploy]http_root': CONF.deploy.http_root, '[deploy]http_image_subdir': CONF.deploy.http_image_subdir } error_msg = _('Node %s failed to validate http provisoning. Some ' 'configuration options were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info d_info = {} d_info['deploy_kernel'] = info.get('pxe_deploy_kernel') d_info['deploy_ramdisk'] = info.get('pxe_deploy_ramdisk') error_msg = _("Cannot validate PXE bootloader") deploy_utils.check_for_missing_params(d_info, error_msg, 'pxe_') return d_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') error_msg = _("Error validating iLO virtual media deploy") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue, if any of the required parameters are missing. """ info = node.driver_info d_info = {} d_info['ilo_deploy_iso'] = info.get('ilo_deploy_iso') error_msg = _("Error validating iLO virtual media deploy") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
def validate(self, task): """Validate the driver-specific Node deployment info.""" task.driver.boot.validate(task) node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if not iwdi and deploy_utils.get_boot_option(node) == "netboot": raise exception.InvalidParameterValue( _("Node %(node)s is configured to use the %(driver)s driver " "which does not support netboot.") % { 'node': node.uuid, 'driver': node.driver }) params = {} image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue """ node = task.node params = {} params['driver_info.deploy_kernel'] = node.driver_info.get( 'deploy_kernel') params['driver_info.deploy_ramdisk'] = node.driver_info.get( 'deploy_ramdisk') params['instance_info.image_source'] = node.instance_info.get( 'image_source') error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg)
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue """ node = task.node params = {} if CONF.agent.manage_tftp: params['driver_info.deploy_kernel'] = node.driver_info.get( 'deploy_kernel') params['driver_info.deploy_ramdisk'] = node.driver_info.get( 'deploy_ramdisk') image_source = node.instance_info.get('image_source') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): if not node.instance_info.get('image_checksum'): raise exception.MissingParameterValue(_( "image_source's image_checksum must be provided in " "instance_info for node %s") % node.uuid) is_whole_disk_image = node.driver_internal_info.get( 'is_whole_disk_image') # TODO(sirushtim): Remove once IPA has support for partition images. if is_whole_disk_image is False: raise exception.InvalidParameterValue(_( "Node %(node)s is configured to use the %(driver)s driver " "which currently does not support deploying partition " "images.") % {'node': node.uuid, 'driver': node.driver}) # Validate the root device hints deploy_utils.parse_root_device_hints(node)
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info d_info = {} # NOTE(lucasagomes): For backwards compatibility let's keep accepting # pxe_deploy_{kernel, ramdisk}, should be removed in Liberty. deprecated_msg = _LW('The "%(old_param)s" parameter is deprecated. ' 'Please update the node %(node)s to use ' '"%(new_param)s" instead.') for parameter in ('deploy_kernel', 'deploy_ramdisk'): value = info.get(parameter) if not value: old_parameter = 'pxe_' + parameter value = info.get(old_parameter) if value: LOG.warning( deprecated_msg, { 'old_param': old_parameter, 'new_param': parameter, 'node': node.uuid }) d_info[parameter] = value error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to, or rescue, the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info params_to_check = pxe_utils.KERNEL_RAMDISK_LABELS[mode] d_info = {k: info.get(k) for k in params_to_check} error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to, or rescue, the node. :param node: a single Node. :param mode: Label indicating a deploy or rescue operation being carried out on the node. Supported values are 'deploy' and 'rescue'. Defaults to 'deploy', indicating deploy operation is being carried out. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info params_to_check = KERNEL_RAMDISK_LABELS[mode] d_info = {k: info.get(k) for k in params_to_check} error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the driver_info values. :raises: MissingParameterValue """ info = node.driver_info d_info = {} # NOTE(lucasagomes): For backwards compatibility let's keep accepting # pxe_deploy_{kernel, ramdisk}, should be removed in Liberty. deprecated_msg = _LW('The "%(old_param)s" parameter is deprecated. ' 'Please update the node %(node)s to use ' '"%(new_param)s" instead.') for parameter in ('deploy_kernel', 'deploy_ramdisk'): value = info.get(parameter) if not value: old_parameter = 'pxe_' + parameter value = info.get(old_parameter) if value: LOG.warning(deprecated_msg, {'old_param': old_parameter, 'new_param': parameter, 'node': node.uuid}) d_info[parameter] = value error_msg = _("Cannot validate PXE bootloader. Some parameters were" " missing in node's driver_info") deploy_utils.check_for_missing_params(d_info, error_msg) return d_info
def _parse_partitioning_info(node): info = node.instance_info i_info = {} i_info['root_gb'] = info.get('root_gb') error_msg = _("'root_gb' is missing in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) err_msg_invalid = _("Cannot validate parameter for deploy. Invalid " "parameter %(param)s. Reason: %(reason)s") for param in DISK_LAYOUT_PARAMS: try: i_info[param] = int(i_info[param]) except ValueError: reason = _("%s is not an integer value") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % {'param': param, 'reason': reason}) # convert to sizes expected by 'parted' Ansible module root_mib = 1024 * i_info.pop('root_gb') swap_mib = i_info.pop('swap_mb') ephemeral_mib = 1024 * i_info.pop('ephemeral_gb') partitions = [] root_partition = {'name': 'root', 'size_mib': root_mib, 'boot': 'yes', 'swap': 'no'} partitions.append(root_partition) if swap_mib: swap_partition = {'name': 'swap', 'size_mib': swap_mib, 'boot': 'no', 'swap': 'yes'} partitions.append(swap_partition) if ephemeral_mib: ephemeral_partition = {'name': 'ephemeral', 'size_mib': ephemeral_mib, 'boot': 'no', 'swap': 'no'} partitions.append(ephemeral_partition) i_info['ephemeral_format'] = info.get('ephemeral_format') if not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = ( strutils.bool_from_string(preserve_ephemeral, strict=True)) except ValueError as e: raise exception.InvalidParameterValue( err_msg_invalid % {'param': 'preserve_ephemeral', 'reason': e}) i_info['preserve_ephemeral'] = ( 'yes' if i_info['preserve_ephemeral'] else 'no') i_info['ironic_partitions'] = partitions return i_info
def validate(self, task): """Validate the driver-specific Node deployment info. This method validates whether the properties of the supplied node contain the required information for this driver to deploy images to the node. :param task: a TaskManager instance :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ if CONF.agent.manage_agent_boot: task.driver.boot.validate(task) node = task.node # Validate node capabilities deploy_utils.validate_capabilities(node) if not task.driver.storage.should_write_image(task): # NOTE(TheJulia): There is no reason to validate # image properties if we will not be writing an image # in a boot from volume case. As such, return to the caller. LOG.debug( 'Skipping complete deployment interface validation ' 'for node %s as it is set to boot from a remote ' 'volume.', node.uuid) return params = {} image_source = node.instance_info.get('image_source') image_checksum = node.instance_info.get('image_checksum') image_disk_format = node.instance_info.get('image_disk_format') os_hash_algo = node.instance_info.get('image_os_hash_algo') os_hash_value = node.instance_info.get('image_os_hash_value') params['instance_info.image_source'] = image_source error_msg = _('Node %s failed to validate deploy image info. Some ' 'parameters were missing') % node.uuid deploy_utils.check_for_missing_params(params, error_msg) if not service_utils.is_glance_image(image_source): def _raise_missing_checksum_exception(node): raise exception.MissingParameterValue( _('image_source\'s "image_checksum", or ' '"image_os_hash_algo" and "image_os_hash_value" ' 'must be provided in instance_info for ' 'node %s') % node.uuid) if os_hash_value and not os_hash_algo: # We are missing a piece of information, # so we still need to raise an error. _raise_missing_checksum_exception(node) elif not os_hash_value and os_hash_algo: # We have the hash setting, but not the hash. _raise_missing_checksum_exception(node) elif not os_hash_value and not image_checksum: # We are lacking the original image_checksum, # so we raise the error. _raise_missing_checksum_exception(node) validate_http_provisioning_configuration(node) check_image_size(task, image_source, image_disk_format) # Validate the root device hints deploy_utils.get_root_device_for_deploy(node) validate_image_proxies(node)
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = node.instance_info i_info = {} i_info['image_source'] = info.get('image_source') is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image') if not is_whole_disk_image: if (i_info['image_source'] and not glance_service_utils.is_glance_image(i_info['image_source'])): i_info['kernel'] = info.get('kernel') i_info['ramdisk'] = info.get('ramdisk') i_info['root_gb'] = info.get('root_gb') error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing" " in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) # Internal use only i_info['deploy_key'] = info.get('deploy_key') i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) err_msg_invalid = _("Cannot validate parameter for iSCSI deploy. " "Invalid parameter %(param)s. Reason: %(reason)s") for param in ('root_gb', 'swap_mb', 'ephemeral_gb'): try: int(i_info[param]) except ValueError: reason = _("%s is not an integer value.") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % {'param': param, 'reason': reason}) if is_whole_disk_image: if int(i_info['swap_mb']) > 0 or int(i_info['ephemeral_gb']) > 0: err_msg_invalid = _("Cannot deploy whole disk image with " "swap or ephemeral size set") raise exception.InvalidParameterValue(err_msg_invalid) return i_info i_info['ephemeral_format'] = info.get('ephemeral_format') i_info['configdrive'] = info.get('configdrive') if i_info['ephemeral_gb'] and not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = ( strutils.bool_from_string(preserve_ephemeral, strict=True)) except ValueError as e: raise exception.InvalidParameterValue( err_msg_invalid % {'param': 'preserve_ephemeral', 'reason': e}) # Note(Zhenguo) Add disk layout check here, in case of rebuild with # preserve_ephemeral option. if i_info['preserve_ephemeral']: _check_disk_layout(node, i_info) else: _save_disk_layout(node, i_info) return i_info
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 information for this driver to deploy images to the node. :param node: a single Node. :returns: A dict with the instance_info values. :raises: MissingParameterValue, if any of the required parameters are missing. :raises: InvalidParameterValue, if any of the parameters have invalid value. """ info = node.instance_info i_info = {} i_info['image_source'] = info.get('image_source') is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image') if not is_whole_disk_image: if (i_info['image_source'] and not glance_service_utils.is_glance_image( i_info['image_source'])): i_info['kernel'] = info.get('kernel') i_info['ramdisk'] = info.get('ramdisk') i_info['root_gb'] = info.get('root_gb') error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing" " in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) # Internal use only i_info['deploy_key'] = info.get('deploy_key') i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) err_msg_invalid = _("Cannot validate parameter for iSCSI deploy. " "Invalid parameter %(param)s. Reason: %(reason)s") for param in DISK_LAYOUT_PARAMS: try: int(i_info[param]) except ValueError: reason = _("%s is not an integer value.") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % {'param': param, 'reason': reason}) if is_whole_disk_image: if int(i_info['swap_mb']) > 0 or int(i_info['ephemeral_gb']) > 0: err_msg_invalid = _("Cannot deploy whole disk image with " "swap or ephemeral size set") raise exception.InvalidParameterValue(err_msg_invalid) return i_info i_info['ephemeral_format'] = info.get('ephemeral_format') i_info['configdrive'] = info.get('configdrive') if i_info['ephemeral_gb'] and not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = ( strutils.bool_from_string(preserve_ephemeral, strict=True)) except ValueError as e: raise exception.InvalidParameterValue( err_msg_invalid % {'param': 'preserve_ephemeral', 'reason': e}) # NOTE(Zhenguo): If rebuilding with preserve_ephemeral option, check # that the disk layout is unchanged. if i_info['preserve_ephemeral']: _check_disk_layout_unchanged(node, i_info) return i_info
def _parse_partitioning_info(node): info = node.instance_info i_info = {} i_info['root_gb'] = info.get('root_gb') error_msg = _("'root_gb' is missing in node's instance_info") deploy_utils.check_for_missing_params(i_info, error_msg) i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) err_msg_invalid = _("Cannot validate parameter for deploy. Invalid " "parameter %(param)s. Reason: %(reason)s") for param in DISK_LAYOUT_PARAMS: try: i_info[param] = int(i_info[param]) except ValueError: reason = _("%s is not an integer value") % i_info[param] raise exception.InvalidParameterValue(err_msg_invalid % { 'param': param, 'reason': reason }) # convert to sizes expected by 'parted' Ansible module root_mib = 1024 * i_info.pop('root_gb') swap_mib = i_info.pop('swap_mb') ephemeral_mib = 1024 * i_info.pop('ephemeral_gb') partitions = [] root_partition = { 'name': 'root', 'size_mib': root_mib, 'boot': 'yes', 'swap': 'no' } partitions.append(root_partition) if swap_mib: swap_partition = { 'name': 'swap', 'size_mib': swap_mib, 'boot': 'no', 'swap': 'yes' } partitions.append(swap_partition) if ephemeral_mib: ephemeral_partition = { 'name': 'ephemeral', 'size_mib': ephemeral_mib, 'boot': 'no', 'swap': 'no' } partitions.append(ephemeral_partition) i_info['ephemeral_format'] = info.get('ephemeral_format') if not i_info['ephemeral_format']: i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format preserve_ephemeral = info.get('preserve_ephemeral', False) try: i_info['preserve_ephemeral'] = (strutils.bool_from_string( preserve_ephemeral, strict=True)) except ValueError as e: raise exception.InvalidParameterValue(err_msg_invalid % { 'param': 'preserve_ephemeral', 'reason': e }) i_info['preserve_ephemeral'] = ('yes' if i_info['preserve_ephemeral'] else 'no') i_info['ironic_partitions'] = partitions return i_info