Merge "Do not use inner class of glanceclient"

This commit is contained in:
Jenkins 2016-01-17 00:15:22 +00:00 committed by Gerrit Code Review
commit b2f57f9606
3 changed files with 14 additions and 4 deletions

View File

@ -661,6 +661,9 @@
# communication with the OpenStack service. (string value)
#endpoint_type = publicURL
# Version of Glance API to use in glanceclient. (string value)
#api_version = 2
[heat_client]

View File

@ -13,7 +13,7 @@
# under the License.
from barbicanclient import client as barbicanclient
from glanceclient.v2 import client as glanceclient
from glanceclient import client as glanceclient
from heatclient import client as heatclient
from neutronclient.v2_0 import client as neutronclient
from novaclient import client as novaclient
@ -66,7 +66,10 @@ glance_client_opts = [
default='publicURL',
help=_(
'Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.'))]
'for communication with the OpenStack service.')),
cfg.StrOpt('api_version',
default='2',
help=_('Version of Glance API to use in glanceclient.'))]
barbican_client_opts = [
cfg.StrOpt('region_name',
@ -183,6 +186,7 @@ class OpenStackClients(object):
endpoint_type = self._get_client_option('glance', 'endpoint_type')
region_name = self._get_client_option('glance', 'region_name')
glanceclient_version = self._get_client_option('glance', 'api_version')
endpoint = self.url_for(service_type='image',
endpoint_type=endpoint_type,
region_name=region_name)
@ -193,7 +197,7 @@ class OpenStackClients(object):
'username': None,
'password': None,
}
self._glance = glanceclient.Client(**args)
self._glance = glanceclient.Client(glanceclient_version, **args)
return self._glance

View File

@ -11,7 +11,7 @@
# under the License.
from barbicanclient import client as barbicanclient
from glanceclient.v2 import client as glanceclient
from glanceclient import client as glanceclient
from heatclient import client as heatclient
import mock
from neutronclient.v2_0 import client as neutronclient
@ -34,6 +34,8 @@ class ClientsTest(base.BaseTestCase):
group='nova_client')
cfg.CONF.import_opt('api_version', 'magnum.common.clients',
group='heat_client')
cfg.CONF.import_opt('api_version', 'magnum.common.clients',
group='glance_client')
@mock.patch.object(clients.OpenStackClients, 'keystone')
def test_url_for(self, mock_keystone):
@ -131,6 +133,7 @@ class ClientsTest(base.BaseTestCase):
obj._glance = None
obj.glance()
mock_call.assert_called_once_with(
cfg.CONF.glance_client.api_version,
endpoint='url_from_keystone', username=None,
token='3bcc3d3a03f44e3d8377f9247b0ad155',
auth_url='keystone_url',