Exemplo n.º 1
0
    def validate(self, task):
        """Checks required info on 'driver_info' and validates node with OneView

        Validates whether the 'driver_info' property of the supplied
        task's node contains the required info such as server_hardware_uri,
        server_hardware_type, server_profile_template_uri and
        enclosure_group_uri. Also, checks if the server profile of the node is
        applied, if NICs are valid for the server profile of the node, and if
        the server hardware attributes (ram, memory, vcpus count) are
        consistent with OneView.

        :param task: a task from TaskManager.
        :raises: InvalidParameterValue if parameters set are inconsistent with
                 resources in OneView
        """

        common.verify_node_info(task.node)

        try:
            common.validate_oneview_resources_compatibility(
                self.oneview_client, task)

            if not deploy_utils.is_node_in_use_by_ironic(
                self.oneview_client, task.node
            ):
                raise exception.InvalidParameterValue(
                    _("Node %s is not in use by ironic.") % task.node.uuid)
        except exception.OneViewError as oneview_exc:
            raise exception.InvalidParameterValue(oneview_exc)
Exemplo n.º 2
0
    def validate(self, task):
        """Checks required info on 'driver_info' and validates node with OneView

        Validates whether the 'oneview_info' property of the supplied
        task's node contains the required info such as server_hardware_uri,
        server_hardware_type, server_profile_template_uri and
        enclosure_group_uri. Also, checks if the server profile of the node is
        applied, if NICs are valid for the server profile of the node, and if
        the server hardware attributes (ram, memory, vcpus count) are
        consistent with OneView. It validates if the node is being used by
        Oneview.

        :param task: a task from TaskManager.
        :raises: MissingParameterValue if a required parameter is missing.
        :raises: InvalidParameterValue if parameters set are inconsistent with
                 resources in OneView
        :raises: InvalidParameterValue if the node in use by OneView.
        :raises: OneViewError if not possible to get OneView's information
                 for the given node, if not possible to retrieve Server
                 Hardware from OneView.
        """
        common.verify_node_info(task.node)

        try:
            common.validate_oneview_resources_compatibility(task)
            if deploy_utils.is_node_in_use_by_oneview(task.node):
                raise exception.InvalidParameterValue(
                    _("Node %s is in use by OneView.") % task.node.uuid)
        except exception.OneViewError as oneview_exc:
            raise exception.InvalidParameterValue(oneview_exc)
Exemplo n.º 3
0
    def test_deprecated_spt_in_driver_info(self, log_mock):
        # the current model has server_profile_template_uri in
        # properties/capabilities instead of driver_info

        driver_info = db_utils.get_test_oneview_driver_info()
        driver_info['server_profile_template_uri'] = 'fake_spt_uri'

        properties = db_utils.get_test_oneview_properties()
        properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri,"
                                      "enclosure_group_uri:fake_eg_uri")

        self.node.driver_info = driver_info
        self.node.properties = properties

        deprecated_node = self.node
        expected_node_info = {
            'server_hardware_uri': 'fake_sh_uri',
            'server_hardware_type_uri': 'fake_sht_uri',
            'enclosure_group_uri': 'fake_eg_uri',
            'server_profile_template_uri': 'fake_spt_uri',
        }

        self.assertEqual(expected_node_info,
                         common.get_oneview_info(deprecated_node))

        # must be valid
        common.verify_node_info(deprecated_node)

        log_mock.warning.assert_called_once_with(
            "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.", self.node.uuid)
Exemplo n.º 4
0
    def validate(self, task):
        """Checks required info on 'driver_info' and validates node with OneView

        Validates whether the 'driver_info' property of the supplied
        task's node contains the required info such as server_hardware_uri,
        server_hardware_type, server_profile_template_uri and
        enclosure_group_uri. Also, checks if the server profile of the node is
        applied, if NICs are valid for the server profile of the node, and if
        the server hardware attributes (ram, memory, vcpus count) are
        consistent with OneView.

        :param task: a task from TaskManager.
        :raises: InvalidParameterValue if parameters set are inconsistent with
                 resources in OneView
        """

        common.verify_node_info(task.node)

        try:
            common.validate_oneview_resources_compatibility(
                self.oneview_client, task)

            if not deploy_utils.is_node_in_use_by_ironic(
                    self.oneview_client, task.node):
                raise exception.InvalidParameterValue(
                    _("Node %s is not in use by ironic.") % task.node.uuid)
        except exception.OneViewError as oneview_exc:
            raise exception.InvalidParameterValue(oneview_exc)
Exemplo n.º 5
0
 def validate(self, task):
     common.verify_node_info(task.node)
     try:
         common.validate_oneview_resources_compatibility(task)
     except exception.OneViewError as oneview_exc:
         raise exception.InvalidParameterValue(oneview_exc)
     super(OneViewAgentDeploy, self).validate(task)
Exemplo n.º 6
0
 def validate(self, task):
     common.verify_node_info(task.node)
     try:
         common.validate_oneview_resources_compatibility(
             self.oneview_client, task)
     except exception.OneViewError as oneview_exc:
         raise exception.InvalidParameterValue(oneview_exc)
     super(OneViewAgentDeploy, self).validate(task)
Exemplo n.º 7
0
    def test_verify_node_info_missing_spt(self):
        properties = db_utils.get_test_oneview_properties()
        properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri,"
                                      "enclosure_group_uri:fake_eg_uri")

        self.node.properties = properties
        with self.assertRaisesRegex(exception.MissingParameterValue,
                                    "server_profile_template_uri"):
            common.verify_node_info(self.node)
Exemplo n.º 8
0
    def test_verify_node_info_missing_spt(self):
        properties = db_utils.get_test_oneview_properties()
        properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri,"
                                      "enclosure_group_uri:fake_eg_uri")

        self.node.properties = properties
        with self.assertRaisesRegex(exception.MissingParameterValue,
                                    "server_profile_template_uri"):
            common.verify_node_info(self.node)
Exemplo n.º 9
0
 def test_verify_node_info_missing_node_properties(self):
     self.node.properties = {
         "cpu_arch": "x86_64",
         "cpus": "8",
         "local_gb": "10",
         "memory_mb": "4096",
         "capabilities": ("enclosure_group_uri:fake_eg_uri,"
                          "server_profile_template_uri:fake_spt_uri")
     }
     with self.assertRaisesRegex(exception.MissingParameterValue,
                                 "server_hardware_type_uri"):
         common.verify_node_info(self.node)
Exemplo n.º 10
0
 def test_verify_node_info_missing_node_properties(self):
     self.node.properties = {
         "cpu_arch": "x86_64",
         "cpus": "8",
         "local_gb": "10",
         "memory_mb": "4096",
         "capabilities": ("enclosure_group_uri:fake_eg_uri,"
                          "server_profile_template_uri:fake_spt_uri")
     }
     with self.assertRaisesRegex(exception.MissingParameterValue,
                                 "server_hardware_type_uri"):
         common.verify_node_info(self.node)
Exemplo n.º 11
0
    def validate(self, task):
        """Check required info on 'driver_info' and validates node with OneView.

        Validates whether the 'driver_info' property of the supplied
        task's node contains the required info such as server_hardware_uri,
        server_hardware_type, server_profile_template_uri and
        enclosure_group_uri. Also, checks if the server profile of the node is
        applied, if NICs are valid for the server profile of the node.

        :param task: a task from TaskManager.
        :raises: InvalidParameterValue if parameters set are inconsistent with
                 resources in OneView
        """
        common.verify_node_info(task.node)

        try:
            common.validate_oneview_resources_compatibility(task)
        except exception.OneViewError as oneview_exc:
            raise exception.InvalidParameterValue(oneview_exc)
Exemplo n.º 12
0
    def test_deprecated_spt_in_driver_info_and_in_capabilites(self):
        # information in capabilities precedes driver_info
        driver_info = db_utils.get_test_oneview_driver_info()
        driver_info['server_profile_template_uri'] = 'unused_fake_spt_uri'

        self.node.driver_info = driver_info

        deprecated_node = self.node
        expected_node_info = {
            'server_hardware_uri': 'fake_sh_uri',
            'server_hardware_type_uri': 'fake_sht_uri',
            'enclosure_group_uri': 'fake_eg_uri',
            'server_profile_template_uri': 'fake_spt_uri',
        }

        self.assertEqual(expected_node_info,
                         common.get_oneview_info(deprecated_node))

        # must be valid
        common.verify_node_info(deprecated_node)
Exemplo n.º 13
0
    def validate(self, task):
        """Checks required info on 'driver_info' and validates node with OneView

        Validates whether the 'driver_info' property of the supplied
        task's node contains the required info such as server_hardware_uri,
        server_hardware_type, server_profile_template_uri and
        enclosure_group_uri. Also, checks if the server profile of the node is
        applied, if NICs are valid for the server profile of the node.

        :param task: a task from TaskManager.
        :raises: InvalidParameterValue if parameters set are inconsistent with
                 resources in OneView
        """

        common.verify_node_info(task.node)

        try:
            common.validate_oneview_resources_compatibility(
                self.oneview_client, task)
        except exception.OneViewError as oneview_exc:
            raise exception.InvalidParameterValue(oneview_exc)
Exemplo n.º 14
0
    def test_deprecated_spt_in_driver_info_and_in_capabilites(self):
        # information in capabilities precedes driver_info
        driver_info = db_utils.get_test_oneview_driver_info()
        driver_info['server_profile_template_uri'] = 'unused_fake_spt_uri'

        self.node.driver_info = driver_info

        deprecated_node = self.node
        expected_node_info = {
            'server_hardware_uri': 'fake_sh_uri',
            'server_hardware_type_uri': 'fake_sht_uri',
            'enclosure_group_uri': 'fake_eg_uri',
            'server_profile_template_uri': 'fake_spt_uri',
        }

        self.assertEqual(
            expected_node_info,
            common.get_oneview_info(deprecated_node)
        )

        # must be valid
        common.verify_node_info(deprecated_node)
Exemplo n.º 15
0
    def test_deprecated_spt_in_driver_info(self, log_mock):
        # the current model has server_profile_template_uri in
        # properties/capabilities instead of driver_info

        driver_info = db_utils.get_test_oneview_driver_info()
        driver_info['server_profile_template_uri'] = 'fake_spt_uri'

        properties = db_utils.get_test_oneview_properties()
        properties["capabilities"] = ("server_hardware_type_uri:fake_sht_uri,"
                                      "enclosure_group_uri:fake_eg_uri")

        self.node.driver_info = driver_info
        self.node.properties = properties

        deprecated_node = self.node
        expected_node_info = {
            'server_hardware_uri': 'fake_sh_uri',
            'server_hardware_type_uri': 'fake_sht_uri',
            'enclosure_group_uri': 'fake_eg_uri',
            'server_profile_template_uri': 'fake_spt_uri',
        }

        self.assertEqual(
            expected_node_info,
            common.get_oneview_info(deprecated_node)
        )

        # must be valid
        common.verify_node_info(deprecated_node)

        log_mock.warning.assert_called_once_with(
            "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.",
            self.node.uuid
        )
Exemplo n.º 16
0
 def test_verify_node_info(self):
     common.verify_node_info(self.node)
Exemplo n.º 17
0
    def test_verify_node_info_missing_node_driver_info(self):
        self.node.driver_info = {}

        with self.assertRaisesRegex(exception.MissingParameterValue,
                                    "server_hardware_uri"):
            common.verify_node_info(self.node)
Exemplo n.º 18
0
 def test_verify_node_info(self):
     common.verify_node_info(self.node)
Exemplo n.º 19
0
    def test_verify_node_info_missing_node_driver_info(self):
        self.node.driver_info = {}

        with self.assertRaisesRegex(exception.MissingParameterValue,
                                    "server_hardware_uri"):
            common.verify_node_info(self.node)