Fix imports in openstack compute tests
This makes imports in a number of tests consistent. There were also various places where files were being stubbed out that werent explicitly imported. This patch fixes those as well. It also moves compute api stubbing to stub the actual compute.api.API class instead of compute.API. Includes a rewrite of test_createserverext to stub the create method instead of doing a bunch of odd setup with a mock compute api. Change-Id: Id8ebb2f65228fafeac69c7ab635ff8909b79c449
This commit is contained in:
		| @@ -16,9 +16,9 @@ import datetime | ||||
|  | ||||
| import webob | ||||
|  | ||||
| from nova.api.openstack import compute as compute_api | ||||
| from nova.api.openstack import compute | ||||
| from nova.api.openstack.compute.contrib import admin_actions | ||||
| from nova import compute | ||||
| from nova.compute import api as compute_api | ||||
| from nova.compute import vm_states | ||||
| from nova import context | ||||
| from nova import exception | ||||
| @@ -87,10 +87,10 @@ class AdminActionsTest(test.TestCase): | ||||
|  | ||||
|     def setUp(self): | ||||
|         super(AdminActionsTest, self).setUp() | ||||
|         self.stubs.Set(compute.API, 'get', fake_compute_api_get) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) | ||||
|         self.UUID = utils.gen_uuid() | ||||
|         for _method in self._methods: | ||||
|             self.stubs.Set(compute.API, _method, fake_compute_api) | ||||
|             self.stubs.Set(compute_api.API, _method, fake_compute_api) | ||||
|         self.stubs.Set(scheduler_rpcapi.SchedulerAPI, | ||||
|                        'live_migration', | ||||
|                        fake_scheduler_api_live_migration) | ||||
| @@ -110,7 +110,7 @@ class AdminActionsTest(test.TestCase): | ||||
|         app = fakes.wsgi_app() | ||||
|  | ||||
|         for _action, _method in self._actions_that_check_state: | ||||
|             self.stubs.Set(compute.API, _method, | ||||
|             self.stubs.Set(compute_api.API, _method, | ||||
|                 fake_compute_api_raises_invalid_state) | ||||
|  | ||||
|             req = webob.Request.blank('/v2/fake/servers/%s/action' % | ||||
| @@ -144,7 +144,7 @@ class AdminActionsTest(test.TestCase): | ||||
|                         task_state, expected_task_state): | ||||
|             return None | ||||
|  | ||||
|         self.stubs.Set(compute.API, 'update', fake_update) | ||||
|         self.stubs.Set(compute_api.API, 'update', fake_update) | ||||
|  | ||||
|         res = req.get_response(app) | ||||
|         self.assertEqual(res.status_int, 202) | ||||
| @@ -174,9 +174,9 @@ class CreateBackupTests(test.TestCase): | ||||
|     def setUp(self): | ||||
|         super(CreateBackupTests, self).setUp() | ||||
|  | ||||
|         self.stubs.Set(compute.API, 'get', fake_compute_api_get) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) | ||||
|         self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs) | ||||
|         self.app = compute_api.APIRouter() | ||||
|         self.app = compute.APIRouter() | ||||
|         self.uuid = utils.gen_uuid() | ||||
|  | ||||
|     def _get_request(self, body): | ||||
| @@ -289,7 +289,7 @@ class CreateBackupTests(test.TestCase): | ||||
|             }, | ||||
|         } | ||||
|  | ||||
|         self.stubs.Set(compute.API, 'backup', | ||||
|         self.stubs.Set(compute_api.API, 'backup', | ||||
|                 fake_compute_api_raises_invalid_state) | ||||
|  | ||||
|         request = self._get_request(body) | ||||
| @@ -313,8 +313,8 @@ class ResetStateTests(test.TestCase): | ||||
|         def fake_update(inst, context, instance, **kwargs): | ||||
|             self.kwargs = kwargs | ||||
|  | ||||
|         self.stubs.Set(compute.API, 'get', fake_get) | ||||
|         self.stubs.Set(compute.API, 'update', fake_update) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get) | ||||
|         self.stubs.Set(compute_api.API, 'update', fake_update) | ||||
|         self.admin_api = admin_actions.AdminActionsController() | ||||
|  | ||||
|         url = '/fake/servers/%s/action' % self.uuid | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|  | ||||
| import webob | ||||
|  | ||||
| from nova import compute | ||||
| from nova.compute import api as compute_api | ||||
| from nova import exception | ||||
| from nova.openstack.common import jsonutils | ||||
| from nova import test | ||||
| @@ -47,9 +47,9 @@ class ConsoleOutputExtensionTest(test.TestCase): | ||||
|  | ||||
|     def setUp(self): | ||||
|         super(ConsoleOutputExtensionTest, self).setUp() | ||||
|         self.stubs.Set(compute.API, 'get_console_output', | ||||
|         self.stubs.Set(compute_api.API, 'get_console_output', | ||||
|                        fake_get_console_output) | ||||
|         self.stubs.Set(compute.API, 'get', fake_get) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get) | ||||
|  | ||||
|     def test_get_text_console_instance_action(self): | ||||
|         body = {'os-getConsoleOutput': {}} | ||||
| @@ -96,7 +96,7 @@ class ConsoleOutputExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 400) | ||||
|  | ||||
|     def test_get_text_console_no_instance(self): | ||||
|         self.stubs.Set(compute.API, 'get', fake_get_not_found) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get_not_found) | ||||
|         body = {'os-getConsoleOutput': {}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
|         req.method = "POST" | ||||
| @@ -107,7 +107,9 @@ class ConsoleOutputExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 404) | ||||
|  | ||||
|     def test_get_text_console_no_instance_on_get_output(self): | ||||
|         self.stubs.Set(compute.API, 'get_console_output', fake_get_not_found) | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'get_console_output', | ||||
|                        fake_get_not_found) | ||||
|         body = {'os-getConsoleOutput': {}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
|         req.method = "POST" | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|  | ||||
| import webob | ||||
|  | ||||
| from nova import compute | ||||
| from nova.compute import api as compute_api | ||||
| from nova import exception | ||||
| from nova.openstack.common import jsonutils | ||||
| from nova import test | ||||
| @@ -51,9 +51,9 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|  | ||||
|     def setUp(self): | ||||
|         super(ConsolesExtensionTest, self).setUp() | ||||
|         self.stubs.Set(compute.API, 'get_vnc_console', | ||||
|         self.stubs.Set(compute_api.API, 'get_vnc_console', | ||||
|                        fake_get_vnc_console) | ||||
|         self.stubs.Set(compute.API, 'get', fake_get) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get) | ||||
|  | ||||
|     def test_get_vnc_console(self): | ||||
|         body = {'os-getVNCConsole': {'type': 'novnc'}} | ||||
| @@ -69,7 +69,7 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|             {u'console': {u'url': u'http://fake', u'type': u'novnc'}}) | ||||
|  | ||||
|     def test_get_vnc_console_not_ready(self): | ||||
|         self.stubs.Set(compute.API, 'get_vnc_console', | ||||
|         self.stubs.Set(compute_api.API, 'get_vnc_console', | ||||
|                        fake_get_vnc_console_not_ready) | ||||
|         body = {'os-getVNCConsole': {'type': 'novnc'}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
| @@ -82,7 +82,7 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 409) | ||||
|  | ||||
|     def test_get_vnc_console_no_type(self): | ||||
|         self.stubs.Set(compute.API, 'get_vnc_console', | ||||
|         self.stubs.Set(compute_api.API, 'get_vnc_console', | ||||
|                        fake_get_vnc_console_invalid_type) | ||||
|         body = {'os-getVNCConsole': {}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
| @@ -94,7 +94,7 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 400) | ||||
|  | ||||
|     def test_get_vnc_console_no_instance(self): | ||||
|         self.stubs.Set(compute.API, 'get', fake_get_not_found) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get_not_found) | ||||
|         body = {'os-getVNCConsole': {'type': 'novnc'}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
|         req.method = "POST" | ||||
| @@ -105,7 +105,7 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 404) | ||||
|  | ||||
|     def test_get_vnc_console_no_instance_on_console_get(self): | ||||
|         self.stubs.Set(compute.API, 'get_vnc_console', | ||||
|         self.stubs.Set(compute_api.API, 'get_vnc_console', | ||||
|                        fake_get_vnc_console_not_found) | ||||
|         body = {'os-getVNCConsole': {'type': 'novnc'}} | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
| @@ -118,7 +118,7 @@ class ConsolesExtensionTest(test.TestCase): | ||||
|  | ||||
|     def test_get_vnc_console_invalid_type(self): | ||||
|         body = {'os-getVNCConsole': {'type': 'invalid'}} | ||||
|         self.stubs.Set(compute.API, 'get_vnc_console', | ||||
|         self.stubs.Set(compute_api.API, 'get_vnc_console', | ||||
|                        fake_get_vnc_console_invalid_type) | ||||
|         req = webob.Request.blank('/v2/fake/servers/1/action') | ||||
|         req.method = "POST" | ||||
|   | ||||
| @@ -20,7 +20,7 @@ from xml.dom import minidom | ||||
|  | ||||
| import webob | ||||
|  | ||||
| import nova | ||||
| from nova.compute import api as compute_api | ||||
| from nova import db | ||||
| from nova import exception | ||||
| from nova import flags | ||||
| @@ -61,57 +61,44 @@ def return_instance_add_security_group(context, instance_id, | ||||
|  | ||||
|  | ||||
| class CreateserverextTest(test.TestCase): | ||||
|     def _make_stub_method(self, canned_return): | ||||
|         def stub_method(*args, **kwargs): | ||||
|             return canned_return | ||||
|         return stub_method | ||||
|     def setUp(self): | ||||
|         super(CreateserverextTest, self).setUp() | ||||
|  | ||||
|     def _setup_mock_compute_api(self): | ||||
|         self.security_group = None | ||||
|         self.injected_files = None | ||||
|         self.networks = None | ||||
|         self.user_data = None | ||||
|  | ||||
|         class MockComputeAPI(nova.compute.API): | ||||
|  | ||||
|             def __init__(self): | ||||
|         def create(*args, **kwargs): | ||||
|             if 'security_group' in kwargs: | ||||
|                 self.security_group = kwargs['security_group'] | ||||
|             else: | ||||
|                 self.security_group = None | ||||
|             if 'injected_files' in kwargs: | ||||
|                 self.injected_files = kwargs['injected_files'] | ||||
|             else: | ||||
|                 self.injected_files = None | ||||
|  | ||||
|             if 'requested_networks' in kwargs: | ||||
|                 self.networks = kwargs['requested_networks'] | ||||
|             else: | ||||
|                 self.networks = None | ||||
|                 self.user_data = None | ||||
|                 self.db = db | ||||
|  | ||||
|             def create(self, *args, **kwargs): | ||||
|                 if 'security_group' in kwargs: | ||||
|                     self.security_group = kwargs['security_group'] | ||||
|                 else: | ||||
|                     self.security_group = None | ||||
|                 if 'injected_files' in kwargs: | ||||
|                     self.injected_files = kwargs['injected_files'] | ||||
|                 else: | ||||
|                     self.injected_files = None | ||||
|             if 'user_data' in kwargs: | ||||
|                 self.user_data = kwargs['user_data'] | ||||
|  | ||||
|                 if 'requested_networks' in kwargs: | ||||
|                     self.networks = kwargs['requested_networks'] | ||||
|                 else: | ||||
|                     self.networks = None | ||||
|             resv_id = None | ||||
|  | ||||
|                 if 'user_data' in kwargs: | ||||
|                     self.user_data = kwargs['user_data'] | ||||
|             return ([{'id': '1234', 'display_name': 'fakeinstance', | ||||
|                      'uuid': FAKE_UUID, | ||||
|                      'user_id': 'fake', | ||||
|                      'project_id': 'fake', | ||||
|                      'created_at': "", | ||||
|                      'updated_at': "", | ||||
|                      'fixed_ips': [], | ||||
|                      'progress': 0}], resv_id) | ||||
|  | ||||
|                 resv_id = None | ||||
|  | ||||
|                 return ([{'id': '1234', 'display_name': 'fakeinstance', | ||||
|                          'uuid': FAKE_UUID, | ||||
|                          'user_id': 'fake', | ||||
|                          'project_id': 'fake', | ||||
|                          'created_at': "", | ||||
|                          'updated_at': "", | ||||
|                          'fixed_ips': [], | ||||
|                          'progress': 0}], resv_id) | ||||
|  | ||||
|             def set_admin_password(self, *args, **kwargs): | ||||
|                 pass | ||||
|  | ||||
|         compute_api = MockComputeAPI() | ||||
|         self.stubs.Set(nova.compute, 'API', | ||||
|                        self._make_stub_method(compute_api)) | ||||
|         return compute_api | ||||
|         self.stubs.Set(compute_api.API, 'create', create) | ||||
|  | ||||
|     def _create_security_group_request_dict(self, security_groups): | ||||
|         server = {} | ||||
| @@ -152,11 +139,6 @@ class CreateserverextTest(test.TestCase): | ||||
|         req.body = jsonutils.dumps(body_dict) | ||||
|         return req | ||||
|  | ||||
|     def _run_create_instance_with_mock_compute_api(self, request): | ||||
|         compute_api = self._setup_mock_compute_api() | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         return compute_api, response | ||||
|  | ||||
|     def _format_xml_request_body(self, body_dict): | ||||
|         server = body_dict['server'] | ||||
|         body_parts = [] | ||||
| @@ -200,23 +182,20 @@ class CreateserverextTest(test.TestCase): | ||||
|     def _create_instance_with_networks_json(self, networks): | ||||
|         body_dict = self._create_networks_request_dict(networks) | ||||
|         request = self._get_create_request_json(body_dict) | ||||
|         _create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _create_inst(request) | ||||
|         return request, response, compute_api.networks | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         return request, response, self.networks | ||||
|  | ||||
|     def _create_instance_with_user_data_json(self, networks): | ||||
|         body_dict = self._create_user_data_request_dict(networks) | ||||
|         request = self._get_create_request_json(body_dict) | ||||
|         _create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _create_inst(request) | ||||
|         return request, response, compute_api.user_data | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         return request, response, self.user_data | ||||
|  | ||||
|     def _create_instance_with_networks_xml(self, networks): | ||||
|         body_dict = self._create_networks_request_dict(networks) | ||||
|         request = self._get_create_request_xml(body_dict) | ||||
|         _create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _create_inst(request) | ||||
|         return request, response, compute_api.networks | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         return request, response, self.networks | ||||
|  | ||||
|     def test_create_instance_with_no_networks(self): | ||||
|         _create_inst = self._create_instance_with_networks_json | ||||
| @@ -270,20 +249,18 @@ class CreateserverextTest(test.TestCase): | ||||
|         body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]]) | ||||
|         del body_dict['server']['networks'][0]['uuid'] | ||||
|         request = self._get_create_request_json(body_dict) | ||||
|         _run_create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _run_create_inst(request) | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         self.assertEquals(response.status_int, 400) | ||||
|         self.assertEquals(compute_api.networks, None) | ||||
|         self.assertEquals(self.networks, None) | ||||
|  | ||||
|     def test_create_instance_with_network_no_id_xml(self): | ||||
|         body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]]) | ||||
|         request = self._get_create_request_xml(body_dict) | ||||
|         uuid = ' uuid="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"' | ||||
|         request.body = request.body.replace(uuid, '') | ||||
|         _run_create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _run_create_inst(request) | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         self.assertEquals(response.status_int, 400) | ||||
|         self.assertEquals(compute_api.networks, None) | ||||
|         self.assertEquals(self.networks, None) | ||||
|  | ||||
|     def test_create_instance_with_network_invalid_id(self): | ||||
|         _create_inst = self._create_instance_with_networks_json | ||||
| @@ -322,20 +299,18 @@ class CreateserverextTest(test.TestCase): | ||||
|         body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]]) | ||||
|         del body_dict['server']['networks'][0]['fixed_ip'] | ||||
|         request = self._get_create_request_json(body_dict) | ||||
|         _run_create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _run_create_inst(request) | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         self.assertEquals(response.status_int, 202) | ||||
|         self.assertEquals(compute_api.networks, | ||||
|         self.assertEquals(self.networks, | ||||
|                           [('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)]) | ||||
|  | ||||
|     def test_create_instance_with_network_no_fixed_ip_xml(self): | ||||
|         body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]]) | ||||
|         request = self._get_create_request_xml(body_dict) | ||||
|         request.body = request.body.replace(' fixed_ip="10.0.1.12"', '') | ||||
|         _run_create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _run_create_inst(request) | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         self.assertEquals(response.status_int, 202) | ||||
|         self.assertEquals(compute_api.networks, | ||||
|         self.assertEquals(self.networks, | ||||
|                           [('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)]) | ||||
|  | ||||
|     def test_create_instance_with_userdata(self): | ||||
| @@ -362,19 +337,18 @@ class CreateserverextTest(test.TestCase): | ||||
|  | ||||
|     def test_create_instance_with_security_group_json(self): | ||||
|         security_groups = ['test', 'test1'] | ||||
|         self.stubs.Set(nova.db, 'security_group_get_by_name', | ||||
|         self.stubs.Set(db, 'security_group_get_by_name', | ||||
|                        return_security_group_get_by_name) | ||||
|         self.stubs.Set(nova.db, 'instance_add_security_group', | ||||
|         self.stubs.Set(db, 'instance_add_security_group', | ||||
|                        return_instance_add_security_group) | ||||
|         body_dict = self._create_security_group_request_dict(security_groups) | ||||
|         request = self._get_create_request_json(body_dict) | ||||
|         _run_create_inst = self._run_create_instance_with_mock_compute_api | ||||
|         compute_api, response = _run_create_inst(request) | ||||
|         response = request.get_response(fakes.wsgi_app()) | ||||
|         self.assertEquals(response.status_int, 202) | ||||
|         self.assertEquals(compute_api.security_group, security_groups) | ||||
|         self.assertEquals(self.security_group, security_groups) | ||||
|  | ||||
|     def test_get_server_by_id_verify_security_groups_json(self): | ||||
|         self.stubs.Set(nova.db, 'instance_get', fakes.fake_instance_get()) | ||||
|         self.stubs.Set(db, 'instance_get', fakes.fake_instance_get()) | ||||
|         req = webob.Request.blank('/v2/fake/os-create-server-ext/1') | ||||
|         req.headers['Content-Type'] = 'application/json' | ||||
|         response = req.get_response(fakes.wsgi_app()) | ||||
| @@ -385,7 +359,7 @@ class CreateserverextTest(test.TestCase): | ||||
|                           expected_security_group) | ||||
|  | ||||
|     def test_get_server_by_id_verify_security_groups_xml(self): | ||||
|         self.stubs.Set(nova.db, 'instance_get', fakes.fake_instance_get()) | ||||
|         self.stubs.Set(db, 'instance_get', fakes.fake_instance_get()) | ||||
|         req = webob.Request.blank('/v2/fake/os-create-server-ext/1') | ||||
|         req.headers['Accept'] = 'application/xml' | ||||
|         response = req.get_response(fakes.wsgi_app()) | ||||
|   | ||||
| @@ -18,8 +18,8 @@ | ||||
| import webob | ||||
|  | ||||
| from nova.api.openstack.compute.contrib import deferred_delete | ||||
| from nova import compute | ||||
| import nova.context | ||||
| from nova.compute import api as compute_api | ||||
| from nova import context | ||||
| from nova import exception | ||||
| from nova import test | ||||
|  | ||||
| @@ -35,18 +35,18 @@ class DeferredDeleteExtensionTest(test.TestCase): | ||||
|         self.extension = deferred_delete.DeferredDeleteController() | ||||
|         self.fake_input_dict = {} | ||||
|         self.fake_uuid = 'fake_uuid' | ||||
|         self.fake_context = nova.context.RequestContext('fake', 'fake') | ||||
|         self.fake_context = context.RequestContext('fake', 'fake') | ||||
|         self.fake_req = FakeRequest(self.fake_context) | ||||
|  | ||||
|     def test_force_delete(self): | ||||
|         self.mox.StubOutWithMock(compute.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute.API, 'force_delete') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'force_delete') | ||||
|  | ||||
|         fake_instance = 'fake_instance' | ||||
|  | ||||
|         compute.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|         compute_api.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|                 fake_instance) | ||||
|         compute.API.force_delete(self.fake_context, fake_instance) | ||||
|         compute_api.API.force_delete(self.fake_context, fake_instance) | ||||
|  | ||||
|         self.mox.ReplayAll() | ||||
|         res = self.extension._force_delete(self.fake_req, self.fake_uuid, | ||||
| @@ -54,14 +54,15 @@ class DeferredDeleteExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 202) | ||||
|  | ||||
|     def test_force_delete_raises_conflict_on_invalid_state(self): | ||||
|         self.mox.StubOutWithMock(compute.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute.API, 'force_delete') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'force_delete') | ||||
|  | ||||
|         fake_instance = 'fake_instance' | ||||
|  | ||||
|         compute.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|         compute_api.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|                 fake_instance) | ||||
|         compute.API.force_delete(self.fake_context, fake_instance).AndRaise( | ||||
|         compute_api.API.force_delete(self.fake_context, fake_instance)\ | ||||
|             .AndRaise( | ||||
|                 exception.InstanceInvalidState) | ||||
|  | ||||
|         self.mox.ReplayAll() | ||||
| @@ -70,14 +71,14 @@ class DeferredDeleteExtensionTest(test.TestCase): | ||||
|                 self.fake_input_dict) | ||||
|  | ||||
|     def test_restore(self): | ||||
|         self.mox.StubOutWithMock(compute.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute.API, 'restore') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'restore') | ||||
|  | ||||
|         fake_instance = 'fake_instance' | ||||
|  | ||||
|         compute.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|         compute_api.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|                 fake_instance) | ||||
|         compute.API.restore(self.fake_context, fake_instance) | ||||
|         compute_api.API.restore(self.fake_context, fake_instance) | ||||
|  | ||||
|         self.mox.ReplayAll() | ||||
|         res = self.extension._restore(self.fake_req, self.fake_uuid, | ||||
| @@ -85,14 +86,14 @@ class DeferredDeleteExtensionTest(test.TestCase): | ||||
|         self.assertEqual(res.status_int, 202) | ||||
|  | ||||
|     def test_restore_raises_conflict_on_invalid_state(self): | ||||
|         self.mox.StubOutWithMock(compute.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute.API, 'restore') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'get') | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'restore') | ||||
|  | ||||
|         fake_instance = 'fake_instance' | ||||
|  | ||||
|         compute.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|         compute_api.API.get(self.fake_context, self.fake_uuid).AndReturn( | ||||
|                 fake_instance) | ||||
|         compute.API.restore(self.fake_context, fake_instance).AndRaise( | ||||
|         compute_api.API.restore(self.fake_context, fake_instance).AndRaise( | ||||
|                 exception.InstanceInvalidState) | ||||
|  | ||||
|         self.mox.ReplayAll() | ||||
|   | ||||
| @@ -20,11 +20,10 @@ from lxml import etree | ||||
| from nova.api.openstack import compute | ||||
| from nova.api.openstack.compute.contrib import server_diagnostics | ||||
| from nova.api.openstack import wsgi | ||||
| import nova.compute | ||||
| from nova.compute import api as compute_api | ||||
| from nova.openstack.common import jsonutils | ||||
| from nova import test | ||||
| from nova.tests.api.openstack import fakes | ||||
| import nova.utils | ||||
|  | ||||
|  | ||||
| UUID = 'abc' | ||||
| @@ -45,9 +44,9 @@ class ServerDiagnosticsTest(test.TestCase): | ||||
|     def setUp(self): | ||||
|         super(ServerDiagnosticsTest, self).setUp() | ||||
|         self.flags(verbose=True) | ||||
|         self.stubs.Set(nova.compute.API, 'get_diagnostics', | ||||
|         self.stubs.Set(compute_api.API, 'get_diagnostics', | ||||
|                        fake_get_diagnostics) | ||||
|         self.stubs.Set(nova.compute.API, 'get', fake_instance_get) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_instance_get) | ||||
|  | ||||
|         self.router = compute.APIRouter() | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,7 @@ import mox | ||||
| import webob | ||||
|  | ||||
| from nova.api.openstack.compute.contrib import server_start_stop | ||||
| from nova import compute | ||||
| from nova.compute import api as compute_api | ||||
| from nova import test | ||||
| from nova.tests.api.openstack import fakes | ||||
|  | ||||
| @@ -34,9 +34,9 @@ class ServerStartStopTest(test.TestCase): | ||||
|         self.controller = server_start_stop.ServerStartStopActionController() | ||||
|  | ||||
|     def test_start(self): | ||||
|         self.stubs.Set(compute.API, 'get', fake_compute_api_get) | ||||
|         self.mox.StubOutWithMock(compute.API, 'start') | ||||
|         compute.API.start(mox.IgnoreArg(), mox.IgnoreArg()) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'start') | ||||
|         compute_api.API.start(mox.IgnoreArg(), mox.IgnoreArg()) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') | ||||
| @@ -44,9 +44,9 @@ class ServerStartStopTest(test.TestCase): | ||||
|         self.controller._start_server(req, 'test_inst', body) | ||||
|  | ||||
|     def test_stop(self): | ||||
|         self.stubs.Set(compute.API, 'get', fake_compute_api_get) | ||||
|         self.mox.StubOutWithMock(compute.API, 'stop') | ||||
|         compute.API.stop(mox.IgnoreArg(), mox.IgnoreArg()) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) | ||||
|         self.mox.StubOutWithMock(compute_api.API, 'stop') | ||||
|         compute_api.API.stop(mox.IgnoreArg(), mox.IgnoreArg()) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') | ||||
|   | ||||
| @@ -20,15 +20,16 @@ import webob | ||||
|  | ||||
| import nova | ||||
| from nova.api.openstack.compute.contrib import volumes | ||||
| from nova.compute import api as compute_api | ||||
| from nova.compute import instance_types | ||||
| from nova import context | ||||
| import nova.db | ||||
| from nova import db | ||||
| from nova import flags | ||||
| from nova.openstack.common import jsonutils | ||||
| from nova.openstack.common import timeutils | ||||
| from nova import test | ||||
| from nova.tests.api.openstack import fakes | ||||
| from nova import volume | ||||
| from nova.volume import api as volume_api | ||||
| from webob import exc | ||||
|  | ||||
|  | ||||
| @@ -100,7 +101,7 @@ class BootFromVolumeTest(test.TestCase): | ||||
|  | ||||
|     def setUp(self): | ||||
|         super(BootFromVolumeTest, self).setUp() | ||||
|         self.stubs.Set(nova.compute.API, 'create', fake_compute_api_create) | ||||
|         self.stubs.Set(compute_api.API, 'create', fake_compute_api_create) | ||||
|         fakes.stub_out_nw_api(self.stubs) | ||||
|  | ||||
|     def test_create_root_volume(self): | ||||
| @@ -140,16 +141,16 @@ class VolumeApiTest(test.TestCase): | ||||
|         super(VolumeApiTest, self).setUp() | ||||
|         fakes.stub_out_networking(self.stubs) | ||||
|         fakes.stub_out_rate_limiting(self.stubs) | ||||
|         self.stubs.Set(nova.db, 'volume_get', return_volume) | ||||
|         self.stubs.Set(db, 'volume_get', return_volume) | ||||
|  | ||||
|         self.stubs.Set(volume.api.API, "delete", fakes.stub_volume_delete) | ||||
|         self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get) | ||||
|         self.stubs.Set(volume.api.API, "get_all", fakes.stub_volume_get_all) | ||||
|         self.stubs.Set(volume_api.API, "delete", fakes.stub_volume_delete) | ||||
|         self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get) | ||||
|         self.stubs.Set(volume_api.API, "get_all", fakes.stub_volume_get_all) | ||||
|  | ||||
|         self.context = context.get_admin_context() | ||||
|  | ||||
|     def test_volume_create(self): | ||||
|         self.stubs.Set(volume.api.API, "create", fakes.stub_volume_create) | ||||
|         self.stubs.Set(volume_api.API, "create", fakes.stub_volume_create) | ||||
|  | ||||
|         vol = {"size": 100, | ||||
|                "display_name": "Volume Test Name", | ||||
| @@ -191,7 +192,7 @@ class VolumeApiTest(test.TestCase): | ||||
|         self.assertEqual(resp.status_int, 200) | ||||
|  | ||||
|     def test_volume_show_no_volume(self): | ||||
|         self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound) | ||||
|         self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get_notfound) | ||||
|  | ||||
|         req = webob.Request.blank('/v2/fake/os-volumes/456') | ||||
|         resp = req.get_response(fakes.wsgi_app()) | ||||
| @@ -204,7 +205,7 @@ class VolumeApiTest(test.TestCase): | ||||
|         self.assertEqual(resp.status_int, 202) | ||||
|  | ||||
|     def test_volume_delete_no_volume(self): | ||||
|         self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound) | ||||
|         self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get_notfound) | ||||
|  | ||||
|         req = webob.Request.blank('/v2/fake/os-volumes/456') | ||||
|         req.method = 'DELETE' | ||||
| @@ -215,10 +216,10 @@ class VolumeApiTest(test.TestCase): | ||||
| class VolumeAttachTests(test.TestCase): | ||||
|     def setUp(self): | ||||
|         super(VolumeAttachTests, self).setUp() | ||||
|         self.stubs.Set(nova.compute.API, | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'get_instance_bdms', | ||||
|                        fake_get_instance_bdms) | ||||
|         self.stubs.Set(nova.compute.API, 'get', fake_get_instance) | ||||
|         self.stubs.Set(compute_api.API, 'get', fake_get_instance) | ||||
|         self.context = context.get_admin_context() | ||||
|         self.expected_show = {'volumeAttachment': | ||||
|             {'device': '/dev/fake0', | ||||
| @@ -239,7 +240,9 @@ class VolumeAttachTests(test.TestCase): | ||||
|         self.assertEqual(self.expected_show, result) | ||||
|  | ||||
|     def test_delete(self): | ||||
|         self.stubs.Set(nova.compute.API, 'detach_volume', fake_detach_volume) | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'detach_volume', | ||||
|                        fake_detach_volume) | ||||
|         attachments = volumes.VolumeAttachmentController() | ||||
|         req = webob.Request.blank('/v2/fake/os-volumes/delete') | ||||
|         req.method = 'POST' | ||||
| @@ -251,7 +254,9 @@ class VolumeAttachTests(test.TestCase): | ||||
|         self.assertEqual('202 Accepted', result.status) | ||||
|  | ||||
|     def test_delete_vol_not_found(self): | ||||
|         self.stubs.Set(nova.compute.API, 'detach_volume', fake_detach_volume) | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'detach_volume', | ||||
|                        fake_detach_volume) | ||||
|         attachments = volumes.VolumeAttachmentController() | ||||
|         req = webob.Request.blank('/v2/fake/os-volumes/delete') | ||||
|         req.method = 'POST' | ||||
| @@ -266,7 +271,9 @@ class VolumeAttachTests(test.TestCase): | ||||
|                           FAKE_UUID_C) | ||||
|  | ||||
|     def test_attach_volume(self): | ||||
|         self.stubs.Set(nova.compute.API, 'attach_volume', fake_attach_volume) | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'attach_volume', | ||||
|                        fake_attach_volume) | ||||
|         attachments = volumes.VolumeAttachmentController() | ||||
|         body = {'volumeAttachment': {'volumeId': FAKE_UUID_A, | ||||
|                                     'device': '/dev/fake'}} | ||||
|   | ||||
| @@ -19,15 +19,17 @@ import mox | ||||
| import webob | ||||
|  | ||||
| from nova.api.openstack.compute import servers | ||||
| from nova.compute import api as compute_api | ||||
| from nova.compute import task_states | ||||
| from nova.compute import vm_states | ||||
| import nova.db | ||||
| from nova import db | ||||
| from nova import exception | ||||
| from nova import flags | ||||
| from nova.image import glance | ||||
| from nova.openstack.common import importutils | ||||
| from nova import test | ||||
| from nova.tests.api.openstack import fakes | ||||
| import nova.tests.image.fake | ||||
| from nova.tests.image import fake | ||||
| from nova import utils | ||||
|  | ||||
|  | ||||
| @@ -60,17 +62,17 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|     def setUp(self): | ||||
|         super(ServerActionsControllerTest, self).setUp() | ||||
|  | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', | ||||
|                        fakes.fake_instance_get(vm_state=vm_states.ACTIVE, | ||||
|                                                host='fake_host')) | ||||
|         self.stubs.Set(nova.db, 'instance_update_and_get_original', | ||||
|         self.stubs.Set(db, 'instance_update_and_get_original', | ||||
|                        instance_update) | ||||
|  | ||||
|         fakes.stub_out_glance(self.stubs) | ||||
|         fakes.stub_out_nw_api(self.stubs) | ||||
|         fakes.stub_out_rate_limiting(self.stubs) | ||||
|         fakes.stub_out_compute_api_snapshot(self.stubs) | ||||
|         nova.tests.image.fake.stub_out_image_service(self.stubs) | ||||
|         fake.stub_out_image_service(self.stubs) | ||||
|         service_class = 'nova.image.glance.GlanceImageService' | ||||
|         self.service = importutils.import_object(service_class) | ||||
|         self.sent_to_glance = {} | ||||
| @@ -85,7 +87,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|     def test_server_change_password(self): | ||||
|         mock_method = MockSetAdminPassword() | ||||
|         self.stubs.Set(nova.compute.api.API, 'set_admin_password', mock_method) | ||||
|         self.stubs.Set(compute_api.API, 'set_admin_password', mock_method) | ||||
|         body = {'changePassword': {'adminPass': '1234pass'}} | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
| @@ -100,7 +102,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         self.flags(enable_instance_password=False) | ||||
|  | ||||
|         mock_method = MockSetAdminPassword() | ||||
|         self.stubs.Set(nova.compute.api.API, 'set_admin_password', mock_method) | ||||
|         self.stubs.Set(compute_api.API, 'set_admin_password', mock_method) | ||||
|         body = {'changePassword': {'adminPass': '1234pass'}} | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
| @@ -126,7 +128,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|     def test_server_change_password_empty_string(self): | ||||
|         mock_method = MockSetAdminPassword() | ||||
|         self.stubs.Set(nova.compute.api.API, 'set_admin_password', mock_method) | ||||
|         self.stubs.Set(compute_api.API, 'set_admin_password', mock_method) | ||||
|         body = {'changePassword': {'adminPass': ''}} | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
| @@ -167,7 +169,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|                           req, FAKE_UUID, body) | ||||
|  | ||||
|     def test_reboot_not_found(self): | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', | ||||
|                        return_server_not_found) | ||||
|  | ||||
|         body = dict(reboot=dict(type="HARD")) | ||||
| @@ -182,7 +184,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def fake_reboot(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'reboot', fake_reboot) | ||||
|         self.stubs.Set(compute_api.API, 'reboot', fake_reboot) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         self.assertRaises(webob.exc.HTTPConflict, | ||||
| @@ -192,7 +194,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|     def test_rebuild_accepted_minimum(self): | ||||
|         return_server = fakes.fake_instance_get(image_ref='2', | ||||
|                 vm_state=vm_states.ACTIVE, host='fake_host') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', return_server) | ||||
|         self_href = 'http://localhost/v2/fake/servers/%s' % FAKE_UUID | ||||
|  | ||||
|         body = { | ||||
| @@ -217,9 +219,9 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def rebuild(self2, context, instance, image_href, *args, **kwargs): | ||||
|             info['image_href_in_call'] = image_href | ||||
|  | ||||
|         self.stubs.Set(nova.db, 'instance_get', | ||||
|         self.stubs.Set(db, 'instance_get', | ||||
|                 fakes.fake_instance_get(vm_state=vm_states.ACTIVE)) | ||||
|         self.stubs.Set(nova.compute.API, 'rebuild', rebuild) | ||||
|         self.stubs.Set(compute_api.API, 'rebuild', rebuild) | ||||
|  | ||||
|         # proper local hrefs must start with 'http://localhost/v2/' | ||||
|         image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6' | ||||
| @@ -240,9 +242,9 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def rebuild(self2, context, instance, image_href, *args, **kwargs): | ||||
|             info['image_href_in_call'] = image_href | ||||
|  | ||||
|         self.stubs.Set(nova.db, 'instance_get', | ||||
|         self.stubs.Set(db, 'instance_get', | ||||
|                 fakes.fake_instance_get(vm_state=vm_states.ACTIVE)) | ||||
|         self.stubs.Set(nova.compute.API, 'rebuild', rebuild) | ||||
|         self.stubs.Set(compute_api.API, 'rebuild', rebuild) | ||||
|  | ||||
|         # proper local hrefs must start with 'http://localhost/v2/' | ||||
|         image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6' | ||||
| @@ -264,7 +266,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|         return_server = fakes.fake_instance_get(image_ref='2', | ||||
|                 vm_state=vm_states.ACTIVE, host='fake_host') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', return_server) | ||||
|         self_href = 'http://localhost/v2/fake/servers/%s' % FAKE_UUID | ||||
|  | ||||
|         body = { | ||||
| @@ -292,7 +294,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def fake_rebuild(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'rebuild', fake_rebuild) | ||||
|         self.stubs.Set(compute_api.API, 'rebuild', fake_rebuild) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         self.assertRaises(webob.exc.HTTPConflict, | ||||
| @@ -304,7 +306,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|         return_server = fakes.fake_instance_get(metadata=metadata, | ||||
|                 vm_state=vm_states.ACTIVE, host='fake_host') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', return_server) | ||||
|  | ||||
|         body = { | ||||
|             "rebuild": { | ||||
| @@ -378,7 +380,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|     def test_rebuild_admin_pass(self): | ||||
|         return_server = fakes.fake_instance_get(image_ref='2', | ||||
|                 vm_state=vm_states.ACTIVE, host='fake_host') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', return_server) | ||||
|  | ||||
|         body = { | ||||
|             "rebuild": { | ||||
| @@ -400,7 +402,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|         return_server = fakes.fake_instance_get(image_ref='2', | ||||
|                 vm_state=vm_states.ACTIVE, host='fake_host') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', return_server) | ||||
|  | ||||
|         body = { | ||||
|             "rebuild": { | ||||
| @@ -418,7 +420,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|     def test_rebuild_server_not_found(self): | ||||
|         def server_not_found(self, instance_id): | ||||
|             raise exception.InstanceNotFound(instance_id=instance_id) | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', server_not_found) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', server_not_found) | ||||
|  | ||||
|         body = { | ||||
|             "rebuild": { | ||||
| @@ -457,7 +459,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         } | ||||
|  | ||||
|         update = self.mox.CreateMockAnything() | ||||
|         self.stubs.Set(nova.compute.API, 'update', update) | ||||
|         self.stubs.Set(compute_api.API, 'update', update) | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         context = req.environ['nova.context'] | ||||
|         update(context, mox.IgnoreArg(), | ||||
| @@ -488,8 +490,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|             return image_meta | ||||
|  | ||||
|         self.stubs.Set(nova.tests.image.fake._FakeImageService, | ||||
|                             'show', return_image_meta) | ||||
|         self.stubs.Set(fake._FakeImageService, 'show', return_image_meta) | ||||
|         body = { | ||||
|             "rebuild": { | ||||
|                 "imageRef": "155d900f-4e14-4e4c-a73d-069cbf4541e6", | ||||
| @@ -526,9 +527,8 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|             return image_meta | ||||
|  | ||||
|         self.stubs.Set(nova.tests.image.fake._FakeImageService, | ||||
|                             'show', return_image_meta) | ||||
|         self.stubs.Set(nova.compute.API, 'update', fake_show) | ||||
|         self.stubs.Set(fake._FakeImageService, 'show', return_image_meta) | ||||
|         self.stubs.Set(compute_api.API, 'update', fake_show) | ||||
|         body = { | ||||
|             "rebuild": { | ||||
|                 "imageRef": "155d900f-4e14-4e4c-a73d-069cbf4541e6", | ||||
| @@ -548,7 +548,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def resize_mock(*args): | ||||
|             self.resize_called = True | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'resize', resize_mock) | ||||
|         self.stubs.Set(compute_api.API, 'resize', resize_mock) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         body = self.controller._action_resize(req, FAKE_UUID, body) | ||||
| @@ -577,7 +577,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def fake_resize(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'resize', fake_resize) | ||||
|         self.stubs.Set(compute_api.API, 'resize', fake_resize) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         self.assertRaises(webob.exc.HTTPConflict, | ||||
| @@ -592,7 +592,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def cr_mock(*args): | ||||
|             self.confirm_resize_called = True | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'confirm_resize', cr_mock) | ||||
|         self.stubs.Set(compute_api.API, 'confirm_resize', cr_mock) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         body = self.controller._action_confirm_resize(req, FAKE_UUID, body) | ||||
| @@ -606,7 +606,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|             raise exception.MigrationNotFoundByStatus(instance_id=1, | ||||
|                                                       status='finished') | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'confirm_resize', | ||||
|                        confirm_resize_mock) | ||||
|  | ||||
| @@ -621,7 +621,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def fake_confirm_resize(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'confirm_resize', | ||||
|         self.stubs.Set(compute_api.API, 'confirm_resize', | ||||
|                 fake_confirm_resize) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
| @@ -636,7 +636,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|             raise exception.MigrationNotFoundByStatus(instance_id=1, | ||||
|                                                       status='finished') | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, | ||||
|         self.stubs.Set(compute_api.API, | ||||
|                        'revert_resize', | ||||
|                        revert_resize_mock) | ||||
|  | ||||
| @@ -653,7 +653,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def revert_mock(*args): | ||||
|             self.revert_resize_called = True | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'revert_resize', revert_mock) | ||||
|         self.stubs.Set(compute_api.API, 'revert_resize', revert_mock) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         body = self.controller._action_revert_resize(req, FAKE_UUID, body) | ||||
| @@ -666,7 +666,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         def fake_revert_resize(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|  | ||||
|         self.stubs.Set(nova.compute.api.API, 'revert_resize', | ||||
|         self.stubs.Set(compute_api.API, 'revert_resize', | ||||
|                 fake_revert_resize) | ||||
|  | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
| @@ -697,7 +697,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|         if extra_properties: | ||||
|             body['createImage']['metadata'] = extra_properties | ||||
|  | ||||
|         image_service = nova.image.glance.get_default_image_service() | ||||
|         image_service = glance.get_default_image_service() | ||||
|  | ||||
|         bdm = [dict(volume_id=_fake_id('a'), | ||||
|                     volume_size=1, | ||||
| @@ -732,13 +732,13 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|  | ||||
|             return [BDM()] | ||||
|  | ||||
|         self.stubs.Set(nova.db, 'block_device_mapping_get_all_by_instance', | ||||
|         self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', | ||||
|                        fake_block_device_mapping_get_all_by_instance) | ||||
|  | ||||
|         instance = fakes.fake_instance_get(image_ref=original_image['id'], | ||||
|                                            vm_state=vm_states.ACTIVE, | ||||
|                                            root_device_name='/dev/vda') | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', instance) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', instance) | ||||
|  | ||||
|         volume = dict(id=_fake_id('a'), | ||||
|                       size=1, | ||||
| @@ -858,7 +858,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|     def test_create_image_raises_conflict_on_invalid_state(self): | ||||
|         def snapshot(*args, **kwargs): | ||||
|             raise exception.InstanceInvalidState | ||||
|         self.stubs.Set(nova.compute.API, 'snapshot', snapshot) | ||||
|         self.stubs.Set(compute_api.API, 'snapshot', snapshot) | ||||
|  | ||||
|         body = { | ||||
|             "createImage": { | ||||
| @@ -876,7 +876,7 @@ class ServerActionsControllerTest(test.TestCase): | ||||
|             return {"name": "foo", | ||||
|                     "uuid": FAKE_UUID, | ||||
|                     "locked": True} | ||||
|         self.stubs.Set(nova.db, 'instance_get_by_uuid', fake_locked) | ||||
|         self.stubs.Set(db, 'instance_get_by_uuid', fake_locked) | ||||
|         body = dict(reboot=dict(type="HARD")) | ||||
|         req = fakes.HTTPRequest.blank(self.url) | ||||
|         self.assertRaises(webob.exc.HTTPConflict, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Vishvananda Ishaya
					Vishvananda Ishaya