Revert Id905d47600bda9923cebae617749c8286552ec94

Change-Id: I185145e5738bb5251d7c50bd04255f0045fd82f8
This commit is contained in:
Tom Barron 2018-02-07 17:13:52 -05:00
parent 7bf8148fdf
commit b70b85386a
8 changed files with 11 additions and 237 deletions

View File

@ -1,33 +0,0 @@
# 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 oslo_config.cfg
import oslo_utils.importutils
_glance_opts = [
oslo_config.cfg.StrOpt('image_api_class',
default='manila.image.glance.API',
help='The full class name of the '
'Glance API class to use.'),
]
oslo_config.cfg.CONF.register_opts(_glance_opts)
def API():
importutils = oslo_utils.importutils
glance_api_class = oslo_config.cfg.CONF.image_api_class
cls = importutils.import_class(glance_api_class)
return cls()

View File

@ -1,71 +0,0 @@
# 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.
"""
Handles all requests to Glance.
"""
from glanceclient import client as glance_client
from glanceclient import exc as glance_exception
from keystoneauth1 import loading as ks_loading
from oslo_config import cfg
from manila.common import client_auth
from manila.common.config import core_opts
from manila.db import base
GLANCE_GROUP = 'glance'
AUTH_OBJ = None
glance_opts = [
cfg.StrOpt('api_microversion',
default='2',
help='Version of Glance API to be used.'),
cfg.StrOpt('region_name',
default='RegionOne',
help='Region name for connecting to glance.'),
]
CONF = cfg.CONF
CONF.register_opts(core_opts)
CONF.register_opts(glance_opts, GLANCE_GROUP)
ks_loading.register_session_conf_options(CONF, GLANCE_GROUP)
ks_loading.register_auth_conf_options(CONF, GLANCE_GROUP)
def list_opts():
return client_auth.AuthClientLoader.list_opts(GLANCE_GROUP)
def glanceclient(context):
global AUTH_OBJ
if not AUTH_OBJ:
AUTH_OBJ = client_auth.AuthClientLoader(
client_class=glance_client.Client,
exception_module=glance_exception,
cfg_group=GLANCE_GROUP)
return AUTH_OBJ.get_client(context,
version=CONF[GLANCE_GROUP].api_microversion,
region_name=CONF[GLANCE_GROUP].region_name)
class API(base.Base):
"""API for interacting with glanceclient."""
def image_list(self, context):
client = glanceclient(context)
if hasattr(client, 'images'):
return client.images.list()
return client.glance.list()

View File

@ -33,7 +33,6 @@ from manila import compute
from manila import context
from manila import exception
from manila.i18n import _
from manila import image
from manila.network.linux import ip_lib
from manila.network.neutron import api as neutron
from manila import utils
@ -208,7 +207,6 @@ class ServiceInstanceManager(object):
self.admin_context = context.get_admin_context()
self._execute = utils.execute
self.image_api = image.API()
self.compute_api = compute.API()
self.path_to_private_key = self.get_config_option(
@ -484,7 +482,7 @@ class ServiceInstanceManager(object):
def _get_service_image(self, context):
"""Returns ID of service image for service vm creating."""
service_image_name = self.get_config_option("service_image_name")
images = [image.id for image in self.image_api.image_list(context)
images = [image.id for image in self.compute_api.image_list(context)
if image.name == service_image_name
and image.status == 'active']
if len(images) == 1:

View File

@ -1,125 +0,0 @@
# 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 mock
from manila import context
from manila.image import glance
from manila import test
from manila.tests import utils as test_utils
class FakeGlanceClient(object):
class Image(object):
def list(self, *args, **kwargs):
return [{'id': 'id1'}, {'id': 'id2'}]
def __getattr__(self, item):
return None
def __init__(self):
self.image = self.Image()
def get_fake_auth_obj():
return type('FakeAuthObj', (object, ), {'get_client': mock.Mock()})
class GlanceClientTestCase(test.TestCase):
@mock.patch('manila.image.glance.AUTH_OBJ', None)
def test_no_auth_obj(self):
mock_client_loader = self.mock_object(
glance.client_auth, 'AuthClientLoader')
fake_context = 'fake_context'
data = {
'glance': {
'api_microversion': 'foo_api_microversion',
'region_name': 'foo_region_name'
}
}
with test_utils.create_temp_config_with_opts(data):
glance.glanceclient(fake_context)
mock_client_loader.return_value.get_client.assert_called_once_with(
fake_context,
version=data['glance']['api_microversion'],
region_name=data['glance']['region_name']
)
@mock.patch('manila.image.glance.AUTH_OBJ', get_fake_auth_obj())
def test_with_auth_obj(self):
fake_context = 'fake_context'
data = {
'glance': {
'api_microversion': 'foo_api_microversion',
'region_name': 'foo_region_name'
}
}
with test_utils.create_temp_config_with_opts(data):
glance.glanceclient(fake_context)
glance.AUTH_OBJ.get_client.assert_called_once_with(
fake_context,
version=data['glance']['api_microversion'],
region_name=data['glance']['region_name']
)
class GlanceApiTestCase(test.TestCase):
def setUp(self):
super(GlanceApiTestCase, self).setUp()
self.api = glance.API()
self.glanceclient = FakeGlanceClient()
self.ctx = context.get_admin_context()
self.mock_object(glance, 'glanceclient',
mock.Mock(return_value=self.glanceclient))
def test_image_list_glanceclient_has_no_proxy(self):
image_list = ['fake', 'image', 'list']
class FakeGlanceClient(object):
def list(self):
return image_list
self.glanceclient.glance = FakeGlanceClient()
result = self.api.image_list(self.ctx)
self.assertEqual(image_list, result)
def test_image_list_glanceclient_has_proxy(self):
image_list1 = ['fake', 'image', 'list1']
image_list2 = ['fake', 'image', 'list2']
class FakeImagesClient(object):
def list(self):
return image_list1
class FakeGlanceClient(object):
def list(self):
return image_list2
self.glanceclient.images = FakeImagesClient()
self.glanceclient.glance = FakeGlanceClient()
result = self.api.image_list(self.ctx)
self.assertEqual(image_list1, result)

View File

@ -678,7 +678,7 @@ class ServiceInstanceManagerTestCase(test.TestCase):
fake_image3 = fake_compute.FakeImage(
name='another-image',
status='active')
self.mock_object(self._manager.image_api, 'image_list',
self.mock_object(self._manager.compute_api, 'image_list',
mock.Mock(return_value=[fake_image1,
fake_image2,
fake_image3]))
@ -687,7 +687,7 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self.assertEqual(fake_image1.id, result)
def test_get_service_image_not_found(self):
self.mock_object(self._manager.image_api, 'image_list',
self.mock_object(self._manager.compute_api, 'image_list',
mock.Mock(return_value=[]))
self.assertRaises(
exception.ServiceInstanceException,
@ -696,7 +696,7 @@ class ServiceInstanceManagerTestCase(test.TestCase):
fake_error_image = fake_compute.FakeImage(
name='service_image_name',
status='error')
self.mock_object(self._manager.image_api, 'image_list',
self.mock_object(self._manager.compute_api, 'image_list',
mock.Mock(return_value=[fake_error_image]))
self.assertRaises(
exception.ServiceInstanceException,
@ -707,7 +707,7 @@ class ServiceInstanceManagerTestCase(test.TestCase):
name=fake_get_config_option('service_image_name'),
status='active')
fake_images = [fake_image, fake_image]
self.mock_object(self._manager.image_api, 'image_list',
self.mock_object(self._manager.compute_api, 'image_list',
mock.Mock(return_value=fake_images))
self.assertRaises(
exception.ServiceInstanceException,

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Change Id905d47600bda9923cebae617749c8286552ec94 is causing gate failures
with the generic driver so we need to revert it for now and revisit after
rc.

View File

@ -42,5 +42,4 @@ stevedore>=1.20.0 # Apache-2.0
tooz>=1.58.0 # Apache-2.0
python-cinderclient>=3.3.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0
python-glanceclient>=2.8.0 # Apache-2.0
WebOb>=1.7.1 # MIT