def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue, if config option has invalid value. :raises: IRMCSharedFileSystemNotMounted, if shared file system is not mounted. :raises: InvalidParameterValue, if some information is invalid. :raises: MissingParameterValue if 'kernel_id' and 'ramdisk_id' are missing in the Glance image, or if 'kernel' and 'ramdisk' are missing in the Non Glance image. """ _check_share_fs_mounted() iscsi_deploy.validate(task) d_info = _parse_deploy_info(task.node) if task.node.driver_internal_info.get('is_whole_disk_image'): props = [] elif service_utils.is_glance_image(d_info['image_source']): props = ['kernel_id', 'ramdisk_id'] else: props = ['kernel', 'ramdisk'] deploy_utils.validate_image_properties(task.context, d_info, props) deploy_utils.validate_capabilities(task.node)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ # Check the boot_mode capability parameter value. driver_utils.validate_boot_mode_capability(task.node) if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue( _("iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.")) # iPXE and UEFI should not be configured together. if driver_utils.get_node_capability(task.node, 'boot_mode') == 'uefi': LOG.error( _LE("UEFI boot mode is not supported with " "iPXE boot enabled.")) raise exception.InvalidParameterValue( _("Conflict: iPXE is enabled, but cannot be used with node" "%(node_uuid)s configured to use UEFI boot") % {'node_uuid': task.node.uuid}) d_info = _parse_deploy_info(task.node) iscsi_deploy.validate(task) props = ['kernel_id', 'ramdisk_id'] iscsi_deploy.validate_glance_image_properties(task.context, d_info, props)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ # Check the boot_mode capability parameter value. driver_utils.validate_boot_mode_capability(task.node) if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue(_( "iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.")) # iPXE and UEFI should not be configured together. if driver_utils.get_node_capability(task.node, 'boot_mode') == 'uefi': LOG.error(_LE("UEFI boot mode is not supported with " "iPXE boot enabled.")) raise exception.InvalidParameterValue(_( "Conflict: iPXE is enabled, but cannot be used with node" "%(node_uuid)s configured to use UEFI boot") % {'node_uuid': task.node.uuid}) d_info = _parse_deploy_info(task.node) iscsi_deploy.validate(task) props = ['kernel_id', 'ramdisk_id'] iscsi_deploy.validate_glance_image_properties(task.context, d_info, props)
def test_validate_good_api_url_from_config_file(self, mock_ks): # not present in the keystone catalog mock_ks.side_effect = exception.KeystoneFailure self.config(group='conductor', api_url='http://foo') with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: iscsi_deploy.validate(task) self.assertFalse(mock_ks.called)
def test_validate_good_api_url_from_keystone(self, mock_ks): # present in the keystone catalog mock_ks.return_value = 'http://127.0.0.1:1234' # not present in the config file self.config(group='conductor', api_url=None) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: iscsi_deploy.validate(task) mock_ks.assert_called_once_with()
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ node = task.node # Check the boot_mode and boot_option capabilities values. deploy_utils.validate_capabilities(node) boot_mode = deploy_utils.get_boot_mode_for_deploy(task.node) if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue( _("iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.") ) # iPXE and UEFI should not be configured together. if boot_mode == "uefi": LOG.error(_LE("UEFI boot mode is not supported with " "iPXE boot enabled.")) raise exception.InvalidParameterValue( _( "Conflict: iPXE is enabled, but cannot be used with node" "%(node_uuid)s configured to use UEFI boot" ) % {"node_uuid": node.uuid} ) # Check if 'boot_option' is compatible with 'boot_mode' of uefi and # image being deployed if boot_mode == "uefi": validate_boot_option_for_uefi(task.node) if deploy_utils.is_trusted_boot_requested(task.node): # Check if 'boot_option' and boot mode is compatible with # trusted boot. validate_boot_parameters_for_trusted_boot(task.node) d_info = _parse_deploy_info(node) iscsi_deploy.validate(task) if node.driver_internal_info.get("is_whole_disk_image"): props = [] elif service_utils.is_glance_image(d_info["image_source"]): props = ["kernel_id", "ramdisk_id"] else: props = ["kernel", "ramdisk"] iscsi_deploy.validate_image_properties(task.context, d_info, props)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ node = task.node # Check the boot_mode and boot_option capabilities values. deploy_utils.validate_capabilities(node) boot_mode = deploy_utils.get_boot_mode_for_deploy(task.node) if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue( _("iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.")) # iPXE and UEFI should not be configured together. if boot_mode == 'uefi': LOG.error( _LE("UEFI boot mode is not supported with " "iPXE boot enabled.")) raise exception.InvalidParameterValue( _("Conflict: iPXE is enabled, but cannot be used with node" "%(node_uuid)s configured to use UEFI boot") % {'node_uuid': node.uuid}) # Check if 'boot_option' is compatible with 'boot_mode' of uefi and # image being deployed if boot_mode == 'uefi': validate_boot_option_for_uefi(task.node) if deploy_utils.is_trusted_boot_requested(task.node): # Check if 'boot_option' and boot mode is compatible with # trusted boot. validate_boot_parameters_for_trusted_boot(task.node) d_info = _parse_deploy_info(node) iscsi_deploy.validate(task) if node.driver_internal_info.get('is_whole_disk_image'): props = [] elif service_utils.is_glance_image(d_info['image_source']): props = ['kernel_id', 'ramdisk_id'] else: props = ['kernel', 'ramdisk'] iscsi_deploy.validate_image_properties(task.context, d_info, props)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue, if some information is invalid. :raises: MissingParameterValue if 'kernel_id' and 'ramdisk_id' are missing in the Glance image. """ iscsi_deploy.validate(task) props = ['kernel_id', 'ramdisk_id'] d_info = _parse_deploy_info(task.node) iscsi_deploy.validate_glance_image_properties(task.context, d_info, props) driver_utils.validate_boot_mode_capability(task.node)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ node = task.node # Check the boot_mode and boot_option capabilities values. driver_utils.validate_boot_mode_capability(node) driver_utils.validate_boot_option_capability(node) boot_mode = driver_utils.get_node_capability(node, 'boot_mode') boot_option = driver_utils.get_node_capability(node, 'boot_option') # NOTE(lucasagomes): We don't support UEFI + localboot because # we do not support creating an EFI boot partition, including the # EFI modules and managing the bootloader variables via efibootmgr. if boot_mode == 'uefi' and boot_option == 'local': error_msg = (_("Local boot is requested, but can't be " "used with node %s because it's configured " "to use UEFI boot") % node.uuid) LOG.error(error_msg) raise exception.InvalidParameterValue(error_msg) if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue(_( "iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.")) # iPXE and UEFI should not be configured together. if boot_mode == 'uefi': LOG.error(_LE("UEFI boot mode is not supported with " "iPXE boot enabled.")) raise exception.InvalidParameterValue(_( "Conflict: iPXE is enabled, but cannot be used with node" "%(node_uuid)s configured to use UEFI boot") % {'node_uuid': node.uuid}) d_info = _parse_deploy_info(node) iscsi_deploy.validate(task) props = ['kernel_id', 'ramdisk_id'] iscsi_deploy.validate_glance_image_properties(task.context, d_info, props)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue. :raises: MissingParameterValue """ if CONF.pxe.ipxe_enabled: if not CONF.pxe.http_url or not CONF.pxe.http_root: raise exception.MissingParameterValue(_( "iPXE boot is enabled but no HTTP URL or HTTP " "root was specified.")) d_info = _parse_deploy_info(task.node) iscsi_deploy.validate(task) props = ['kernel_id', 'ramdisk_id'] iscsi_deploy.validate_glance_image_properties(task.context, d_info, props)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue, if some information is invalid. :raises: MissingParameterValue if 'kernel_id' and 'ramdisk_id' are missing in the Glance image or 'kernel' and 'ramdisk' not provided in instance_info for non-Glance image. """ iscsi_deploy.validate(task) node = task.node d_info = _parse_deploy_info(node) if node.driver_internal_info.get('is_whole_disk_image'): props = [] elif service_utils.is_glance_image(d_info['image_source']): props = ['kernel_id', 'ramdisk_id'] else: props = ['kernel', 'ramdisk'] deploy_utils.validate_image_properties(task.context, d_info, props) deploy_utils.validate_capabilities(node)
def validate(self, task): """Validate the deployment information for the task's node. :param task: a TaskManager instance containing the node to act on. :raises: InvalidParameterValue, if some information is invalid. :raises: MissingParameterValue if 'kernel_id' and 'ramdisk_id' are missing in the Glance image or 'kernel' and 'ramdisk' not provided in instance_info for non-Glance image. """ iscsi_deploy.validate(task) node = task.node d_info = _parse_deploy_info(node) if node.driver_internal_info.get('is_whole_disk_image'): props = [] elif service_utils.is_glance_image(d_info['image_source']): props = ['kernel_id', 'ramdisk_id'] else: props = ['kernel', 'ramdisk'] iscsi_deploy.validate_image_properties(task.context, d_info, props) deploy_utils.validate_capabilities(node)
def test_validate_good_api_url(self, mock_get_url): mock_get_url.return_value = 'http://127.0.0.1:1234' with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: iscsi_deploy.validate(task) mock_get_url.assert_called_once_with()