Example #1
0
    def test_capabilities_to_dict(self):
        capabilities_more_than_one_item = "a:b,c:d"
        capabilities_exactly_one_item = "e:f"

        # Testing empty capabilities
        self.assertEqual({}, driver_utils.capabilities_to_dict(""))
        self.assertEqual({"e": "f"}, driver_utils.capabilities_to_dict(capabilities_exactly_one_item))
        self.assertEqual({"a": "b", "c": "d"}, driver_utils.capabilities_to_dict(capabilities_more_than_one_item))
Example #2
0
    def test_capabilities_to_dict(self):
        capabilities_more_than_one_item = 'a:b,c:d'
        capabilities_exactly_one_item = 'e:f'

        # Testing empty capabilities
        self.assertEqual({}, driver_utils.capabilities_to_dict(''))
        self.assertEqual(
            {'e': 'f'},
            driver_utils.capabilities_to_dict(capabilities_exactly_one_item))
        self.assertEqual({
            'a': 'b',
            'c': 'd'
        }, driver_utils.capabilities_to_dict(capabilities_more_than_one_item))
Example #3
0
def get_oneview_info(node):
    """Gets OneView information from the node.

    :param: node: node object to get information from
    :returns: a dictionary containing:
        :server_hardware_uri: the uri of the server hardware in OneView
        :server_hardware_type_uri: the uri of the server hardware type in
            OneView
        :enclosure_group_uri: the uri of the enclosure group in OneView
        :server_profile_template_uri: the uri of the server profile template in
            OneView
    :raises InvalidParameterValue if node capabilities are malformed
    """

    capabilities_dict = utils.capabilities_to_dict(
        node.properties.get('capabilities', '')
    )

    driver_info = node.driver_info

    oneview_info = {
        'server_hardware_uri':
            driver_info.get('server_hardware_uri'),
        'server_hardware_type_uri':
            capabilities_dict.get('server_hardware_type_uri'),
        'enclosure_group_uri':
            capabilities_dict.get('enclosure_group_uri'),
        'server_profile_template_uri':
            capabilities_dict.get('server_profile_template_uri') or
            driver_info.get('server_profile_template_uri'),
    }

    return oneview_info
Example #4
0
def get_oneview_info(node):
    """Gets OneView information from the node.

    :param: node: node object to get information from
    :returns: a dictionary containing:
        :server_hardware_uri: the uri of the server hardware in OneView
        :server_hardware_type_uri: the uri of the server hardware type in
            OneView
        :enclosure_group_uri: the uri of the enclosure group in OneView
        :server_profile_template_uri: the uri of the server profile template in
            OneView
    :raises InvalidParameterValue if node capabilities are malformed
    """

    capabilities_dict = utils.capabilities_to_dict(
        node.properties.get('capabilities', ''))

    driver_info = node.driver_info

    oneview_info = {
        'server_hardware_uri':
        driver_info.get('server_hardware_uri'),
        'server_hardware_type_uri':
        capabilities_dict.get('server_hardware_type_uri'),
        'enclosure_group_uri':
        capabilities_dict.get('enclosure_group_uri'),
        'server_profile_template_uri':
        capabilities_dict.get('server_profile_template_uri')
        or driver_info.get('server_profile_template_uri'),
    }

    return oneview_info
Example #5
0
    def test_capabilities_to_dict(self):
        capabilities_more_than_one_item = 'a:b,c:d'
        capabilities_exactly_one_item = 'e:f'

        # Testing empty capabilities
        self.assertEqual(
            {},
            driver_utils.capabilities_to_dict('')
        )
        self.assertEqual(
            {'e': 'f'},
            driver_utils.capabilities_to_dict(capabilities_exactly_one_item)
        )
        self.assertEqual(
            {'a': 'b', 'c': 'd'},
            driver_utils.capabilities_to_dict(capabilities_more_than_one_item)
        )
Example #6
0
def populate_storage_driver_internal_info(task):
    """Set node driver_internal_info for boot from volume parameters.

    :param task: a TaskManager object containing the node.
    :raises: StorageError when a node has an iSCSI or FibreChannel boot volume
             defined but is not capable to support it.
    """
    node = task.node
    boot_volume = get_remote_boot_volume(task)
    if not boot_volume:
        return
    vol_type = str(boot_volume.volume_type).lower()
    node_caps = driver_utils.capabilities_to_dict(
        node.properties.get('capabilities'))
    if vol_type == 'iscsi' and 'iscsi_boot' not in node_caps:
        # TODO(TheJulia): In order to support the FCoE and HBA boot cases,
        # some additional logic will be needed here to ensure we align.
        # The deployment, in theory, should never reach this point
        # if the interfaces all validated, but we shouldn't use that
        # as the only guard against bad configurations.
        raise exception.StorageError(
            _('Node %(node)s has an iSCSI boot '
              'volume defined and no iSCSI boot '
              'support available.') % {'node': node.uuid})
    if vol_type == 'fibre_channel' and 'fibre_channel_boot' not in node_caps:
        raise exception.StorageError(
            _('Node %(node)s has a Fibre Channel '
              'boot volume defined and no Fibre '
              'Channel boot support available.') % {'node': node.uuid})
    boot_capability = ("%s_volume_boot" % vol_type)
    deploy_capability = ("%s_volume_deploy" % vol_type)
    vol_uuid = boot_volume['uuid']
    driver_internal_info = node.driver_internal_info
    if check_interface_capability(task.driver.boot, boot_capability):
        driver_internal_info['boot_from_volume'] = vol_uuid
    # NOTE(TheJulia): This would be a convenient place to check
    # if we need to know about deploying the volume.
    if (check_interface_capability(task.driver.deploy, deploy_capability)
            and task.driver.storage.should_write_image(task)):
        driver_internal_info['boot_from_volume_deploy'] = vol_uuid
        # NOTE(TheJulia): This is also a useful place to include a
        # root device hint since we should/might/be able to obtain
        # and supply that information to IPA if it needs to write
        # the image to the volume.
    node.driver_internal_info = driver_internal_info
    node.save()
Example #7
0
def verify_node_info(node):
    """Verifies if fields and namespaces of a node are valid.

    Verifies if the 'driver_info' field and the 'properties/capabilities'
    namespace exist and are not empty.

    :param: node: node object to be verified
    :raises: InvalidParameterValue if required node capabilities and/or
             driver_info are malformed or missing
    :raises: MissingParameterValue if required node capabilities and/or
             driver_info are missing
    """
    capabilities_dict = utils.capabilities_to_dict(node.properties.get("capabilities", ""))
    driver_info = node.driver_info

    _verify_node_info("properties/capabilities", capabilities_dict, REQUIRED_ON_PROPERTIES)
    _verify_node_info("driver_info", driver_info, REQUIRED_ON_DRIVER_INFO)
Example #8
0
def verify_node_info(node):
    """Verifies if fields and namespaces of a node are valid.

    Verifies if the 'driver_info' field and the 'properties/capabilities'
    namespace exist and are not empty.

    :param: node: node object to be verified
    :raises: InvalidParameterValue if required node capabilities and/or
             driver_info are malformed or missing
    :raises: MissingParameterValue if required node capabilities and/or
             driver_info are missing
    """
    capabilities_dict = utils.capabilities_to_dict(
        node.properties.get('capabilities', '')
    )
    driver_info = node.driver_info

    _verify_node_info('properties/capabilities', capabilities_dict,
                      REQUIRED_ON_PROPERTIES)

    # TODO(gabriel-bezerra): Remove this after Mitaka
    try:
        _verify_node_info('properties/capabilities', capabilities_dict,
                          ['server_profile_template_uri'])

    except exception.MissingParameterValue:
        try:
            _verify_node_info('driver_info', driver_info,
                              ['server_profile_template_uri'])

            LOG.warning(
                _LW("Using 'server_profile_template_uri' in driver_info is "
                    "now deprecated and will be ignored in future releases. "
                    "Node %s should have it in its properties/capabilities "
                    "instead."),
                node.uuid
            )
        except exception.MissingParameterValue:
            raise exception.MissingParameterValue(
                _("Missing 'server_profile_template_uri' parameter value in "
                  "properties/capabilities")
            )
    # end
    _verify_node_info('driver_info', driver_info,
                      REQUIRED_ON_DRIVER_INFO)
Example #9
0
def verify_node_info(node):
    """Verifies if fields and namespaces of a node are valid.

    Verifies if the 'driver_info' field and the 'properties/capabilities'
    namespace exist and are not empty.

    :param: node: node object to be verified
    :raises: InvalidParameterValue if required node capabilities and/or
             driver_info are malformed or missing
    :raises: MissingParameterValue if required node capabilities and/or
             driver_info are missing
    """
    capabilities_dict = utils.capabilities_to_dict(
        node.properties.get('capabilities', ''))
    driver_info = node.driver_info

    _verify_node_info('properties/capabilities', capabilities_dict,
                      REQUIRED_ON_PROPERTIES)

    _verify_node_info('driver_info', driver_info, REQUIRED_ON_DRIVER_INFO)
Example #10
0
def verify_node_info(node):
    """Verifies if fields and namespaces of a node are valid.

    Verifies if the 'driver_info' field and the 'properties/capabilities'
    namespace exist and are not empty.

    :param: node: node object to be verified
    :raises: InvalidParameterValue if required node capabilities and/or
             driver_info are malformed or missing
    :raises: MissingParameterValue if required node capabilities and/or
             driver_info are missing
    """
    capabilities_dict = utils.capabilities_to_dict(
        node.properties.get('capabilities', ''))
    driver_info = node.driver_info

    _verify_node_info('properties/capabilities', capabilities_dict,
                      REQUIRED_ON_PROPERTIES)

    # TODO(gabriel-bezerra): Remove this after Mitaka
    try:
        _verify_node_info('properties/capabilities', capabilities_dict,
                          ['server_profile_template_uri'])

    except exception.MissingParameterValue:
        try:
            _verify_node_info('driver_info', driver_info,
                              ['server_profile_template_uri'])

            LOG.warning(
                _LW("Using 'server_profile_template_uri' in driver_info is "
                    "now deprecated and will be ignored in future releases. "
                    "Node %s should have it in its properties/capabilities "
                    "instead."), node.uuid)
        except exception.MissingParameterValue:
            raise exception.MissingParameterValue(
                _("Missing 'server_profile_template_uri' parameter value in "
                  "properties/capabilities"))
    # end
    _verify_node_info('driver_info', driver_info, REQUIRED_ON_DRIVER_INFO)
Example #11
0
def get_oneview_info(node):
    """Get OneView information from the node.

    :param: node: node object to get information from
    :returns: a dictionary containing:
        :server_hardware_uri: the uri of the server hardware in OneView
        :server_hardware_type_uri: the uri of the server hardware type in
            OneView
        :enclosure_group_uri: the uri of the enclosure group in OneView
        :server_profile_template_uri: the uri of the server profile template in
            OneView
    :raises OneViewInvalidNodeParameter: if node capabilities are malformed
    """
    try:
        capabilities_dict = utils.capabilities_to_dict(
            node.properties.get('capabilities', '')
        )
    except exception.InvalidParameterValue as e:
        raise exception.OneViewInvalidNodeParameter(node_uuid=node.uuid,
                                                    error=e)

    driver_info = node.driver_info

    oneview_info = {
        'server_hardware_uri':
            driver_info.get('server_hardware_uri'),
        'server_hardware_type_uri':
            capabilities_dict.get('server_hardware_type_uri'),
        'enclosure_group_uri':
            capabilities_dict.get('enclosure_group_uri'),
        'server_profile_template_uri':
            capabilities_dict.get('server_profile_template_uri'),
        'applied_server_profile_uri':
            driver_info.get('applied_server_profile_uri'),
    }

    return oneview_info