def test_allocate_server_hardware_to_ironic_node_has_server_profile( self, mock_delete_applied_sp, mock_node_save, mock_get_ov_client ): """Tests server profile allocation when applied_server_profile_uri exists. This test consider that no Server Profile is applied on the Server Hardware but the applied_server_profile_uri remained on the node. Thus, the conductor should remove the value and apply a new server profile to use the node. """ oneview_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None oneview_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'] = 'any/applied_sp_uri/' task.node.driver_info = driver_info deploy_utils.allocate_server_hardware_to_ironic( oneview_client, task.node, 'serverProfileName' ) self.assertTrue(mock_delete_applied_sp.called)
def test_allocate_server_hardware_to_ironic(self, mock_node_save, mock_oneview_client): """Check if a Profile was created and its uri is in driver_info.""" client = mock_oneview_client() server_hardware = {'serverProfileUri': None} client.server_hardware.get.return_value = server_hardware with task_manager.acquire(self.context, self.node.uuid) as task: deploy_utils.allocate_server_hardware_to_ironic( client, task.node, 'serverProfileName') self.assertTrue(mock_node_save.called) self.assertIn('applied_server_profile_uri', task.node.driver_info)
def test_allocate_server_hardware_to_ironic(self, mock_node_save, mock_get_ov_client): """Checks if a Server Profile was created and its uri is in driver_info. """ oneview_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None oneview_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: deploy_utils.allocate_server_hardware_to_ironic( oneview_client, task.node, 'serverProfileName') self.assertTrue(oneview_client.clone_template_and_apply.called) self.assertIn('applied_server_profile_uri', task.node.driver_info)
def test_allocate_server_hardware_to_ironic( self, mock_node_save, mock_get_ov_client ): """Checks if a Server Profile was created and its uri is in driver_info. """ oneview_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None oneview_client.get_server_hardware_by_uuid.return_value = fake_sh with task_manager.acquire(self.context, self.node.uuid) as task: deploy_utils.allocate_server_hardware_to_ironic( oneview_client, task.node, 'serverProfileName' ) self.assertTrue(oneview_client.clone_template_and_apply.called) self.assertIn('applied_server_profile_uri', task.node.driver_info)
def test_allocate_server_hardware_to_ironic_node_has_server_profile( self, mock_node_save, mock_oneview_client): """Test profile allocation when applied_server_profile_uri exists. This test consider that no Server Profile is applied on the Server Hardware but the applied_server_profile_uri remained on the node. Thus, the conductor should remove the value and apply a new server profile to use the node. """ client = mock_oneview_client() server_hardware = {'serverProfileUri': None} client.server_hardware.get.return_value = server_hardware with task_manager.acquire(self.context, self.node.uuid) as task: task.node.driver_info['applied_server_profile_uri'] = ( 'any/applied_sp_uri/') deploy_utils.allocate_server_hardware_to_ironic( client, task.node, 'serverProfileName') self.assertTrue(mock_node_save.called)
def test_allocate_server_hardware_to_ironic_node_has_server_profile( self, mock_delete_applied_sp, mock_node_save, mock_get_ov_client): """Tests server profile allocation when applied_server_profile_uri exists. This test consider that no Server Profile is applied on the Server Hardware but the applied_server_profile_uri remained on the node. Thus, the conductor should remove the value and apply a new server profile to use the node. """ oneview_client = mock_get_ov_client() fake_sh = oneview_models.ServerHardware() fake_sh.server_profile_uri = None oneview_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'] = 'any/applied_sp_uri/' task.node.driver_info = driver_info deploy_utils.allocate_server_hardware_to_ironic( oneview_client, task.node, 'serverProfileName') self.assertTrue(mock_delete_applied_sp.called)
def inspect_hardware(self, task): profile_name = 'Ironic Inspecting [%s]' % task.node.uuid deploy_utils.allocate_server_hardware_to_ironic( task.node, profile_name ) return super(OneViewInspect, self).inspect_hardware(task)
def inspect_hardware(self, task): profile_name = 'Ironic Inspecting [%s]' % task.node.uuid deploy_utils.allocate_server_hardware_to_ironic( self.oneview_client, task.node, profile_name ) return super(OneViewInspect, self).inspect_hardware(task)