diff --git a/manila/compute/nova.py b/manila/compute/nova.py index 2e742f2c73..18639cdb92 100644 --- a/manila/compute/nova.py +++ b/manila/compute/nova.py @@ -201,9 +201,16 @@ class API(base.Base): try: server = utils.find_resource( novaclient(context).servers, instance_name_or_id) - except nova_exception.CommandError as e: - msg = _("Failed to get Nova VM. %s") % e - raise exception.ManilaException(msg) + except nova_exception.CommandError: + # we did not find the server in the current tenant, + # and proceed searching in all tenants + try: + server = utils.find_resource( + novaclient(context).servers, instance_name_or_id, + all_tenants=True) + except nova_exception.CommandError as e: + msg = _("Failed to get Nova VM. %s") % e + raise exception.ManilaException(msg) return _untranslate_server_summary_view(server) @translate_server_exception diff --git a/manila/tests/compute/test_nova.py b/manila/tests/compute/test_nova.py index 9a15087692..42f1b905b1 100644 --- a/manila/tests/compute/test_nova.py +++ b/manila/tests/compute/test_nova.py @@ -170,6 +170,20 @@ class NovaApiTestCase(test.TestCase): self.assertEqual(instance_id, result['id']) utils.find_resource.assert_called_once_with(mock.ANY, instance_id) + def test_server_get_by_name_or_id_failed(self): + instance_id = 'instance_id1' + server = {'id': instance_id, 'fake_key': 'fake_value'} + self.mock_object(utils, 'find_resource', + mock.Mock(return_value=server, + side_effect=nova_exception.CommandError)) + + self.assertRaises(exception.ManilaException, + self.api.server_get_by_name_or_id, + self.ctx, instance_id) + utils.find_resource.assert_any_call(mock.ANY, instance_id) + utils.find_resource.assert_called_with(mock.ANY, instance_id, + all_tenants=True) + @ddt.data( {'nova_e': nova_exception.NotFound(404), 'manila_e': exception.InstanceNotFound},