Move glanceclient to new common interface

This is awesome, because it means glance is aligning.

Except that timeout and endpoint_type are divergent. We'll add
timeout to glanceclient. We need to sweep the other libs and see
if they can accept interface.

But for now, this works.

Change-Id: I755af46a5621983a04c4e07787fd6d10333b7cc4
This commit is contained in:
Monty Taylor 2015-08-31 15:49:49 -04:00
parent 80093002f1
commit ceb6a1d36e
3 changed files with 23 additions and 25 deletions

View File

@ -8,7 +8,7 @@ six
python-novaclient>=2.21.0
python-keystoneclient>=0.11.0
python-glanceclient
python-glanceclient>=1.0.0
python-cinderclient<1.2
python-neutronclient>=2.3.10
python-troveclient

View File

@ -598,29 +598,27 @@ class OpenStackCloud(object):
@property
def glance_client(self):
# Note that glanceclient doesn't use keystoneclient sessions
# which means that it won't make a new token if the old one has
# expired. Work around that by always making a new glanceclient here
# which may create a new token if the current one is close to
# expiration.
token = self.auth_token
endpoint = self.get_session_endpoint('image')
kwargs = dict()
if self.api_timeout is not None:
kwargs['timeout'] = self.api_timeout
service_key = 'image'
try:
# trigger exception on lack of service
self.get_session_endpoint(service_key)
self._glance_client = glanceclient.Client(
self.cloud_config.get_api_version('image'),
endpoint, token=token,
session=self.keystone_session, insecure=not self.verify,
cacert=self.cert, **kwargs)
except Exception as e:
self.log.debug("glance unknown issue", exc_info=True)
version=self.cloud_config.get_api_version(service_key),
session=self.keystone_session,
service_name=self.cloud_config.get_service_name(service_key),
service_type=self.cloud_config.get_service_type(service_key),
interface=self.cloud_config.get_interface(service_key),
region_name=self.region_name)
except Exception:
self.log.debug(
"Couldn't construct {service} object".format(
service=service_key), exc_info=True)
raise
if self._glance_client is None:
raise OpenStackCloudException(
"Error in connecting to glance: %s" % str(e))
if not self._glance_client:
raise OpenStackCloudException("Error connecting to glance")
"Failed to instantiate {service} client."
" This could mean that your credentials are wrong.".format(
service=service_key))
return self._glance_client
@property

View File

@ -119,13 +119,13 @@ class TestShade(base.TestCase):
@mock.patch.object(shade.OpenStackCloud, 'keystone_session')
@mock.patch.object(glanceclient, 'Client')
def test_glance_ssl_args(self, mock_client, mock_keystone_session):
def test_glance_args(self, mock_client, mock_keystone_session):
mock_keystone_session.return_value = None
self.cloud.glance_client
mock_client.assert_called_with(
'1', mock.ANY, token=mock.ANY, session=mock.ANY,
insecure=False,
cacert=None,
version='1', region_name='', service_name=None,
interface='public',
service_type='image', session=mock.ANY,
)
@mock.patch.object(shade.OpenStackCloud, 'search_subnets')