Exemplo n.º 1
0
 def test_status_ok(self, mock_get):
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 2
0
 def test_not_finished(self, mock_get):
     mock_get.return_value = {}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 3
0
 def test_not_finished(self, mock_get):
     mock_get.return_value = {}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 4
0
 def test_exception_ignored(self, mock_get):
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 5
0
 def test_status_error(self, mock_client):
     mock_get = mock_client.return_value.get_status
     mock_get.return_value = {'error': 'boom'}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 6
0
 def test_status_error(self, mock_get):
     mock_get.return_value = {'error': 'boom'}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 7
0
 def test_status_ok(self, mock_get):
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 8
0
 def test_exception_ignored(self, mock_get):
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 9
0
 def test_exception_ignored(self, mock_init, mock_get):
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(session=mock.sentinel.session,
                                       api_version=self.api_version,
                                       inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 10
0
 def test_status_ok(self, mock_init, mock_get):
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(session=mock.sentinel.session,
                                       api_version=self.api_version,
                                       inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 11
0
 def test_not_standalone(self, mock_get):
     self.config(auth_strategy='keystone')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 12
0
 def test_service_url(self, mock_get):
     self.config(service_url='meow', group='inspector')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      auth_token='the token',
                                      base_url='meow')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 13
0
 def test_not_standalone(self, mock_get):
     self.config(auth_strategy='keystone')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 14
0
 def test_service_url(self, mock_get):
     self.config(service_url='meow', group='inspector')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      auth_token='the token',
                                      base_url='meow')
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 15
0
 def test_status_ok(self, mock_client):
     mock_get = mock_client.return_value.get_introspection
     mock_get.return_value = mock.Mock(is_finished=True,
                                       error=None,
                                       spec=['is_finished', 'error'])
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 16
0
 def test_status_error(self, mock_get):
     mock_get.return_value = {'error': 'boom'}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid,
                                      api_version=self.api_version,
                                      auth_token='the token')
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 17
0
 def test_is_standalone(self, mock_init, mock_get):
     self.config(auth_strategy='noauth')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(session=None,
                                       api_version=self.api_version,
                                       inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 18
0
 def test_exception_ignored(self, mock_init, mock_get):
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(
         session=mock.sentinel.session,
         api_version=self.api_version,
         inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 19
0
 def test_status_ok(self, mock_init, mock_get):
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(
         session=mock.sentinel.session,
         api_version=self.api_version,
         inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 20
0
 def test_service_url(self, mock_init, mock_get):
     self.config(service_url='meow', group='inspector')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(session=mock.sentinel.session,
                                       api_version=self.api_version,
                                       inspector_url='meow')
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 21
0
 def test_status_error(self, mock_init, mock_get):
     mock_get.return_value = {'error': 'boom'}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(session=mock.sentinel.session,
                                       api_version=self.api_version,
                                       inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 22
0
 def test_status_error(self, mock_init, mock_get):
     mock_get.return_value = {'error': 'boom'}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(
         session=mock.sentinel.session,
         api_version=self.api_version,
         inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 23
0
 def test_service_url(self, mock_init, mock_get):
     self.config(service_url='meow', group='inspector')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(
         session=mock.sentinel.session,
         api_version=self.api_version,
         inspector_url='meow')
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 24
0
 def test_is_standalone(self, mock_init, mock_get):
     self.config(auth_strategy='noauth')
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_init.assert_called_once_with(
         session=None,
         api_version=self.api_version,
         inspector_url=None)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 25
0
 def test_status_ok(self, mock_client):
     mock_get = mock_client.return_value.get_introspection
     mock_get.return_value = mock.Mock(is_finished=True,
                                       error=None,
                                       spec=['is_finished', 'error'])
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
     self.assertFalse(self.driver.network.remove_inspection_network.called)
     self.assertFalse(self.driver.boot.clean_up_ramdisk.called)
     self.assertFalse(self.driver.power.set_power_state.called)
Exemplo n.º 26
0
 def _test_status_clean_up_failed(self, mock_client):
     utils.set_node_nested_field(self.node, 'driver_internal_info',
                                 'inspector_manage_boot', True)
     self.node.save()
     mock_get = mock_client.return_value.get_introspection
     mock_get.return_value = mock.Mock(is_finished=True,
                                       error=None,
                                       spec=['is_finished', 'error'])
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
Exemplo n.º 27
0
 def test_status_ok_managed_no_power_off(self, mock_client):
     CONF.set_override('power_off', False, group='inspector')
     utils.set_node_nested_field(self.node, 'driver_internal_info',
                                 'inspector_manage_boot', True)
     self.node.save()
     mock_get = mock_client.return_value.get_introspection
     mock_get.return_value = mock.Mock(is_finished=True,
                                       error=None,
                                       spec=['is_finished', 'error'])
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
     self.driver.network.remove_inspection_network.assert_called_once_with(
         self.task)
     self.driver.boot.clean_up_ramdisk.assert_called_once_with(self.task)
     self.assertFalse(self.driver.power.set_power_state.called)
Exemplo n.º 28
0
 def test_status_error_managed(self, mock_client):
     utils.set_node_nested_field(self.node, 'driver_internal_info',
                                 'inspector_manage_boot', True)
     self.node.save()
     mock_get = mock_client.return_value.get_introspection
     mock_get.return_value = mock.Mock(is_finished=True,
                                       error='boom',
                                       spec=['is_finished', 'error'])
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('fail')
     self.assertIn('boom', self.node.last_error)
     self.driver.network.remove_inspection_network.assert_called_once_with(
         self.task)
     self.driver.boot.clean_up_ramdisk.assert_called_once_with(self.task)
     self.driver.power.set_power_state.assert_called_once_with(
         self.task, 'power off', timeout=None)
Exemplo n.º 29
0
    def _check_status(self, task):
        state_before = task.node.provision_state
        result = inspector._check_status(task)
        state_after = task.node.provision_state

        # inspection finished
        if (state_before == states.INSPECTING and
            state_after in [states.MANAGEABLE, states.INSPECTFAIL]):
            deploy_utils.deallocate_server_hardware_from_ironic(task.node)

        return result
Exemplo n.º 30
0
    def _check_status(self, task):
        state_before = task.node.provision_state
        result = inspector._check_status(task)
        state_after = task.node.provision_state

        # inspection finished
        if (
            state_before == states.INSPECTING and state_after in [
                states.MANAGEABLE, states.INSPECTFAIL
            ]
        ):
            deploy_utils.deallocate_server_hardware_from_ironic(
                self.oneview_client, task.node)

        return result
Exemplo n.º 31
0
 def test_status_ok(self, mock_client):
     mock_get = mock_client.return_value.get_status
     mock_get.return_value = {'finished': True}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.task.process_event.assert_called_once_with('done')
Exemplo n.º 32
0
 def test_not_inspecting(self, mock_client):
     mock_get = mock_client.return_value.get_status
     self.node.provision_state = states.MANAGEABLE
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 33
0
 def test_not_check_inspecting(self, mock_client):
     mock_get = mock_client.return_value.get_status
     self.node.provision_state = states.INSPECTING
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 34
0
 def test_not_inspector(self, mock_client):
     mock_get = mock_client.return_value.get_status
     self.task.driver.inspect = object()
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 35
0
 def test_not_inspector(self, mock_get):
     self.task.driver.inspect = object()
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 36
0
 def test_not_inspecting(self, mock_get):
     self.node.provision_state = states.MANAGEABLE
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 37
0
 def test_not_finished(self, mock_client):
     mock_get = mock_client.return_value.get_status
     mock_get.return_value = {}
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 38
0
 def test_exception_ignored(self, mock_client):
     mock_get = mock_client.return_value.get_introspection
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 39
0
 def test_not_inspector(self, mock_client):
     mock_get = mock_client.return_value.get_introspection
     self.task.driver.inspect = object()
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 40
0
 def test_not_check_inspecting(self, mock_client):
     mock_get = mock_client.return_value.get_introspection
     self.node.provision_state = states.INSPECTING
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 41
0
 def test_exception_ignored(self, mock_client):
     mock_get = mock_client.return_value.get_status
     mock_get.side_effect = RuntimeError('boom')
     inspector._check_status(self.task)
     mock_get.assert_called_once_with(self.node.uuid)
     self.assertFalse(self.task.process_event.called)
Exemplo n.º 42
0
 def test_not_inspecting(self, mock_get):
     self.node.provision_state = states.MANAGEABLE
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)
Exemplo n.º 43
0
 def test_not_inspector(self, mock_get):
     self.task.driver.inspect = object()
     inspector._check_status(self.task)
     self.assertFalse(mock_get.called)