示例#1
0
def _parse_root_device_hints(node):
    """Convert string with hints to dict. """
    parsed_hints = deploy_utils.get_root_device_for_deploy(node)
    if not parsed_hints:
        return {}

    root_device_hints = {}
    advanced = {}
    for hint, value in parsed_hints.items():
        if isinstance(value, str):
            if value.startswith('== '):
                root_device_hints[hint] = int(value[3:])
            elif value.startswith('s== '):
                root_device_hints[hint] = urlparse.unquote(value[4:])
            else:
                advanced[hint] = value
        else:
            root_device_hints[hint] = value
    if advanced:
        raise exception.InvalidParameterValue(
            _('Ansible-deploy does not support advanced root device hints '
              'based on oslo.utils operators. '
              'Present advanced hints for node %(node)s are %(hints)s.') % {
                  'node': node.uuid,
                  'hints': advanced
              })
    return root_device_hints
示例#2
0
def validate(task):
    """Validates the pre-requisites for iSCSI deploy.

    Validates whether node in the task provided has some ports enrolled.
    This method validates whether conductor url is available either from CONF
    file or from keystone.

    :param task: a TaskManager instance containing the node to act on.
    :raises: InvalidParameterValue if the URL of the Ironic API service is not
             configured in config file and is not accessible via Keystone
             catalog.
    :raises: MissingParameterValue if no ports are enrolled for the given node.
    """
    # TODO(lucasagomes): Validate the format of the URL
    deploy_utils.get_ironic_api_url()
    # Validate the root device hints
    try:
        root_device = deploy_utils.get_root_device_for_deploy(task.node)
        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': task.node.uuid,
                                               'error': e})
    deploy_utils.parse_instance_info(task.node)
示例#3
0
    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)

        deploy_utils.validate_capabilities(task.node)
        # Validate the root device hints
        deploy_utils.get_root_device_for_deploy(task.node)
示例#4
0
文件: agent.py 项目: younkun/ironic
    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)
示例#5
0
文件: agent.py 项目: willliuwx/ironic
    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)

        validate_http_provisioning_configuration(node)

        check_image_size(task, image_source)
        # Validate the root device hints
        try:
            root_device = deploy_utils.get_root_device_for_deploy(node)
            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)