From 99f3822fd3341eecb4bc8d699b9721fdf59aeee8 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 4 May 2012 14:36:52 -0700 Subject: Remove instance action logging mechanism * Remove InstanceActions db model * Remove relevant db api functions * Add migration 93 which drops the instance_actions * Remove server_action_list API extension * Fixes bug 994846 Change-Id: Ibbd787183034314460f41c84b9ad152655739209 --- .../compute/contrib/test_server_action_list.py | 99 ---------------------- .../tests/api/openstack/compute/test_extensions.py | 1 - nova/tests/policy.json | 2 - nova/tests/test_compute.py | 21 ----- nova/tests/vmwareapi/db_fakes.py | 5 -- 5 files changed, 128 deletions(-) delete mode 100644 nova/tests/api/openstack/compute/contrib/test_server_action_list.py (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_server_action_list.py b/nova/tests/api/openstack/compute/contrib/test_server_action_list.py deleted file mode 100644 index 14ea2972c..000000000 --- a/nova/tests/api/openstack/compute/contrib/test_server_action_list.py +++ /dev/null @@ -1,99 +0,0 @@ -# Copyright 2011 Eldar Nugaev -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import datetime -import json -import unittest - -from lxml import etree - -from nova.api.openstack import compute -from nova.api.openstack.compute import extensions -from nova.api.openstack.compute.contrib import server_action_list -from nova.api.openstack import wsgi -import nova.compute -from nova import test -from nova.tests.api.openstack import fakes -import nova.utils - - -dt = datetime.datetime.utcnow() - - -def fake_get_actions(self, _context, instance_uuid): - return [ - {'action': 'rebuild', 'error': None, 'created_at': dt}, - {'action': 'reboot', 'error': 'Failed!', 'created_at': dt}, - ] - - -def fake_instance_get(self, _context, instance_uuid): - return {'uuid': instance_uuid} - - -class ServerActionsTest(test.TestCase): - - def setUp(self): - super(ServerActionsTest, self).setUp() - self.flags(verbose=True) - self.stubs.Set(nova.compute.API, 'get_actions', fake_get_actions) - self.stubs.Set(nova.compute.API, 'get', fake_instance_get) - - self.router = compute.APIRouter() - - def test_get_actions(self): - uuid = nova.utils.gen_uuid() - req = fakes.HTTPRequest.blank('/fake/servers/%s/actions' % uuid) - res = req.get_response(self.router) - output = json.loads(res.body) - expected = {'actions': [ - {'action': 'rebuild', 'error': None, 'created_at': str(dt)}, - {'action': 'reboot', 'error': 'Failed!', 'created_at': str(dt)}, - ]} - self.assertEqual(output, expected) - - -class TestServerActionsXMLSerializer(unittest.TestCase): - namespace = wsgi.XMLNS_V11 - - def _tag(self, elem): - tagname = elem.tag - self.assertEqual(tagname[0], '{') - tmp = tagname.partition('}') - namespace = tmp[0][1:] - self.assertEqual(namespace, self.namespace) - return tmp[2] - - def test_index_serializer(self): - serializer = server_action_list.ServerActionsTemplate() - exemplar = [dict( - created_at=datetime.datetime.now(), - action='foo', - error='quxx'), - dict( - created_at=datetime.datetime.now(), - action='bar', - error='xxuq')] - text = serializer.serialize(dict(actions=exemplar)) - - print text - tree = etree.fromstring(text) - - self.assertEqual('actions', self._tag(tree)) - self.assertEqual(len(tree), len(exemplar)) - for idx, child in enumerate(tree): - self.assertEqual('action', self._tag(child)) - for field in ('created_at', 'action', 'error'): - self.assertEqual(str(exemplar[idx][field]), child.get(field)) diff --git a/nova/tests/api/openstack/compute/test_extensions.py b/nova/tests/api/openstack/compute/test_extensions.py index 0db8c7395..4be7e9c58 100644 --- a/nova/tests/api/openstack/compute/test_extensions.py +++ b/nova/tests/api/openstack/compute/test_extensions.py @@ -180,7 +180,6 @@ class ExtensionControllerTest(ExtensionTestCase): "Rescue", "SchedulerHints", "SecurityGroups", - "ServerActionList", "ServerDiagnostics", "ServerStartStop", "SimpleTenantUsage", diff --git a/nova/tests/policy.json b/nova/tests/policy.json index 16c806690..83929d0bf 100644 --- a/nova/tests/policy.json +++ b/nova/tests/policy.json @@ -13,7 +13,6 @@ "compute:delete_instance_metadata": [], "compute:get_instance_faults": [], - "compute:get_actions": [], "compute:get_diagnostics": [], "compute:get_lock": [], @@ -104,7 +103,6 @@ "compute_extension:quota_classes": [], "compute_extension:rescue": [], "compute_extension:security_groups": [], - "compute_extension:server_action_list": [], "compute_extension:server_diagnostics": [], "compute_extension:simple_tenant_usage:show": [], "compute_extension:simple_tenant_usage:list": [], diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b6b227168..fad6ba5e1 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -3362,27 +3362,6 @@ class ComputeAPITestCase(BaseTestCase): self.compute_api.get_diagnostics(self.context, instance) self.compute_api.delete(self.context, instance) - def test_get_actions(self): - - expected = [{'id': 1, - 'instance_id': 5, - 'action': 'rebuild', - 'error': '', - }] - - def fake_get_actions(context, instance): - return expected - - self.stubs.Set(nova.db, 'instance_get_actions', - fake_get_actions) - - instance = self._create_fake_instance() - context = self.context.elevated() - actual = self.compute_api.get_actions(context, instance) - self.assertEqual(expected, actual) - - self.compute_api.delete(self.context, instance) - def test_inject_file(self): """Ensure we can write a file to an instance""" instance = self._create_fake_instance() diff --git a/nova/tests/vmwareapi/db_fakes.py b/nova/tests/vmwareapi/db_fakes.py index ab2c01580..7911d3f37 100644 --- a/nova/tests/vmwareapi/db_fakes.py +++ b/nova/tests/vmwareapi/db_fakes.py @@ -92,10 +92,6 @@ def stub_out_db_instance_api(stubs): 'vlan': 100} return FakeModel(fields) - def fake_instance_action_create(context, action): - """Stubs out the db.instance_action_create method.""" - pass - def fake_instance_type_get_all(context, inactive=0, filters=None): return INSTANCE_TYPES.values() @@ -104,6 +100,5 @@ def stub_out_db_instance_api(stubs): stubs.Set(db, 'instance_create', fake_instance_create) stubs.Set(db, 'network_get_by_instance', fake_network_get_by_instance) - stubs.Set(db, 'instance_action_create', fake_instance_action_create) stubs.Set(db, 'instance_type_get_all', fake_instance_type_get_all) stubs.Set(db, 'instance_type_get_by_name', fake_instance_type_get_by_name) -- cgit