Example #1
0
    def validate(self, task):
        """Validates the driver information needed by the redfish driver.

        :param task: a TaskManager instance containing the node to act on.
        :raises: InvalidParameterValue on malformed parameter(s)
        :raises: MissingParameterValue on missing parameter(s)
        """
        redfish_utils.parse_driver_info(task.node)
Example #2
0
    def validate(self, task):
        """Validates the driver information needed by the redfish driver.

        :param task: a TaskManager instance containing the node to act on.
        :raises: InvalidParameterValue on malformed parameter(s)
        :raises: MissingParameterValue on missing parameter(s)
        """
        redfish_utils.parse_driver_info(task.node)
Example #3
0
    def test_parse_driver_info_valid_string_value_verify_ca(self):
        for value in ('0', 'f', 'false', 'off', 'n', 'no'):
            self.node.driver_info['redfish_verify_ca'] = value
            response = redfish_utils.parse_driver_info(self.node)
            parsed_driver_info = copy.deepcopy(self.parsed_driver_info)
            parsed_driver_info['verify_ca'] = False
            self.assertEqual(parsed_driver_info, response)

        for value in ('1', 't', 'true', 'on', 'y', 'yes'):
            self.node.driver_info['redfish_verify_ca'] = value
            response = redfish_utils.parse_driver_info(self.node)
            self.assertEqual(self.parsed_driver_info, response)
Example #4
0
    def test_parse_driver_info_valid_string_value_verify_ca(self):
        for value in ('0', 'f', 'false', 'off', 'n', 'no'):
            self.node.driver_info['redfish_verify_ca'] = value
            response = redfish_utils.parse_driver_info(self.node)
            parsed_driver_info = copy.deepcopy(self.parsed_driver_info)
            parsed_driver_info['verify_ca'] = False
            self.assertEqual(parsed_driver_info, response)

        for value in ('1', 't', 'true', 'on', 'y', 'yes'):
            self.node.driver_info['redfish_verify_ca'] = value
            response = redfish_utils.parse_driver_info(self.node)
            self.assertEqual(self.parsed_driver_info, response)
Example #5
0
    def validate(self, task):
        """Validate the driver-specific Node deployment info.

        This method validates whether the 'driver_info' properties of
        the task's node contains the required information for this
        interface to function.

        This method is often executed synchronously in API requests, so it
        should not conduct long-running checks.

        :param task: A TaskManager instance containing the node to act on.
        :raises: InvalidParameterValue on malformed parameter(s)
        :raises: MissingParameterValue on missing parameter(s)
        """
        redfish_utils.parse_driver_info(task.node)
Example #6
0
    def validate(self, task):
        """Validate the driver-specific Node deployment info.

        This method validates whether the 'driver_info' properties of
        the task's node contains the required information for this
        interface to function.

        This method is often executed synchronously in API requests, so it
        should not conduct long-running checks.

        :param task: A TaskManager instance containing the node to act on.
        :raises: InvalidParameterValue on malformed parameter(s)
        :raises: MissingParameterValue on missing parameter(s)
        """
        redfish_utils.parse_driver_info(task.node)
Example #7
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

    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
Example #8
0
    def test_parse_driver_info_valid_capath(self, mock_isfile):
        mock_isfile.return_value = True
        fake_path = '/path/to/a/valid/CA.pem'
        self.node.driver_info['redfish_verify_ca'] = fake_path
        self.parsed_driver_info['verify_ca'] = fake_path

        response = redfish_utils.parse_driver_info(self.node)
        self.assertEqual(self.parsed_driver_info, response)
        mock_isfile.assert_called_once_with(fake_path)
Example #9
0
    def test_parse_driver_info_path_verify_ca(self, mock_isdir):
        mock_isdir.return_value = True
        fake_path = '/path/to/a/valid/CA'
        self.node.driver_info['redfish_verify_ca'] = fake_path
        self.parsed_driver_info['verify_ca'] = fake_path

        response = redfish_utils.parse_driver_info(self.node)
        self.assertEqual(self.parsed_driver_info, response)
        mock_isdir.assert_called_once_with(fake_path)
Example #10
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

    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
Example #11
0
 def test_parse_driver_info_default_scheme_with_port(self):
     self.node.driver_info['redfish_address'] = 'example.com:42'
     self.parsed_driver_info['address'] = 'https://example.com:42'
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #12
0
 def test_parse_driver_info_default_scheme(self):
     self.node.driver_info['redfish_address'] = 'example.com'
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #13
0
 def test_parse_driver_info(self):
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #14
0
 def test_parse_driver_info_with_root_prefix(self):
     test_redfish_address = 'https://example.com/test/redfish/v0/'
     self.node.driver_info['redfish_address'] = test_redfish_address
     self.parsed_driver_info['root_prefix'] = '/test/redfish/v0/'
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #15
0
 def test_parse_driver_info_valid_auth_type(self):
     for value in 'basic', 'session', 'auto':
         self.node.driver_info['redfish_auth_type'] = value
         response = redfish_utils.parse_driver_info(self.node)
         self.parsed_driver_info['auth_type'] = value
         self.assertEqual(self.parsed_driver_info, response)
Example #16
0
 def test_parse_driver_info_missing_system_id(self):
     self.node.driver_info.pop('redfish_system_id')
     redfish_utils.parse_driver_info(self.node)
Example #17
0
 def test_parse_driver_info_default_scheme_with_port(self):
     self.node.driver_info['redfish_address'] = 'example.com:42'
     self.parsed_driver_info['address'] = 'https://example.com:42'
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #18
0
 def test_parse_driver_info_default_scheme(self):
     self.node.driver_info['redfish_address'] = 'example.com'
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #19
0
 def test_parse_driver_info(self):
     response = redfish_utils.parse_driver_info(self.node)
     self.assertEqual(self.parsed_driver_info, response)
Example #20
0
 def test_parse_driver_info_valid_auth_type(self):
     for value in 'basic', 'session', 'auto':
         self.node.driver_info['redfish_auth_type'] = value
         response = redfish_utils.parse_driver_info(self.node)
         self.parsed_driver_info['auth_type'] = value
         self.assertEqual(self.parsed_driver_info, response)