def validate(self, task): """Checks required info on 'driver_info' and validates node for 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(task) if not deploy_utils.is_node_in_use_by_ironic(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)
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)
def test_is_node_in_use_by_ironic_no_server_profile( self, mock_get_ov_client): """Node has no Server Profile. """ fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None ov_client = mock_get_ov_client.return_value ov_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: self.assertFalse( deploy_utils.is_node_in_use_by_ironic(ov_client, task.node))
def test_is_node_in_use_by_ironic_no_server_profile( self, mock_get_ov_client ): """Node has no Server Profile. """ fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None ov_client = mock_get_ov_client.return_value ov_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: self.assertFalse( deploy_utils.is_node_in_use_by_ironic(ov_client, task.node) )
def test_is_node_in_use_by_ironic(self, mock_get_ov_client): """Node has a Server Profile applied by ironic. """ fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = "same/applied_sp_uri/" ov_client = mock_get_ov_client.return_value ov_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: driver_info = task.node.driver_info driver_info['applied_server_profile_uri'] = 'same/applied_sp_uri/' task.node.driver_info = driver_info self.assertTrue( deploy_utils.is_node_in_use_by_ironic(ov_client, task.node))
def test_is_node_in_use_by_ironic(self, mock_get_ov_client): """Node has a Server Profile applied by ironic. """ fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = "same/applied_sp_uri/" ov_client = mock_get_ov_client.return_value ov_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: driver_info = task.node.driver_info driver_info['applied_server_profile_uri'] = 'same/applied_sp_uri/' task.node.driver_info = driver_info self.assertTrue( deploy_utils.is_node_in_use_by_ironic(ov_client, task.node) )