def action_start(cls, context, instance_uuid, action_name, want_result=True): values = compute_utils.pack_action_start(context, instance_uuid, action_name) db_action = db.action_start(context, values) if want_result: return cls._from_db_object(context, cls(), db_action)
def test_action_start_no_result(self, mock_start): expected_packed_values = compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action') mock_start.return_value = fake_action action = instance_action.InstanceAction.action_start( self.context, 'fake-uuid', 'fake-action', want_result=False) mock_start.assert_called_once_with(self.context, expected_packed_values) self.assertIsNone(action)
def test_action_start_no_result(self): self.mox.StubOutWithMock(db, 'action_start') db.action_start(self.context, compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action')).AndReturn( fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start( self.context, 'fake-uuid', 'fake-action', want_result=False) self.assertEqual(None, action)
def test_action_start(self): self.mox.StubOutWithMock(db, 'action_start') db.action_start(self.context, compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action')).AndReturn( fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start( self.context, 'fake-uuid', 'fake-action') self.assertEqual(fake_action['id'], action.id)
def test_action_start_no_result(self, mock_start): expected_packed_values = compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action') mock_start.return_value = fake_action action = instance_action.InstanceAction.action_start(self.context, 'fake-uuid', 'fake-action', want_result=False) mock_start.assert_called_once_with(self.context, expected_packed_values) self.assertIsNone(action)
def test_action_start(self): self.mox.StubOutWithMock(db, 'action_start') db.action_start( self.context, compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action')).AndReturn(fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start( self.context, 'fake-uuid', 'fake-action') self.assertEqual(fake_action['id'], action.id)
def test_action_start_no_result(self): self.mox.StubOutWithMock(db, 'action_start') db.action_start( self.context, compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action')).AndReturn(fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start(self.context, 'fake-uuid', 'fake-action', want_result=False) self.assertEqual(None, action)
def test_finish(self): timeutils.set_time_override() self.mox.StubOutWithMock(db, 'action_start') self.mox.StubOutWithMock(db, 'action_finish') db.action_start(self.context, compute_utils.pack_action_start( self.context, 'fake-uuid', 'fake-action')).AndReturn( fake_action) db.action_finish(self.context, compute_utils.pack_action_finish( self.context, 'fake-uuid')).AndReturn(fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start( self.context, 'fake-uuid', 'fake-action') action.finish()
def test_finish(self): timeutils.set_time_override() ctxt = context.get_admin_context() self.mox.StubOutWithMock(db, 'action_start') self.mox.StubOutWithMock(db, 'action_finish') db.action_start( ctxt, compute_utils.pack_action_start( ctxt, 'fake-uuid', 'fake-action')).AndReturn(fake_action) db.action_finish(ctxt, compute_utils.pack_action_finish( ctxt, 'fake-uuid')).AndReturn(fake_action) self.mox.ReplayAll() action = instance_action.InstanceAction.action_start( ctxt, 'fake-uuid', 'fake-action') action.finish()
def _create_action_here(self, ctxt, instance_uuids): for instance_uuid in instance_uuids: action = compute_utils.pack_action_start(ctxt, instance_uuid, instance_actions.CREATE) self.db.action_start(ctxt, action)
def _record_action_start(self, context, instance, action): act = compute_utils.pack_action_start(context, instance['uuid'], action) self.db.action_start(context, act)