Merge "Use keystone session with clients"
This commit is contained in:
commit
73e07966af
@ -16,6 +16,8 @@ from heat.common.i18n import _
|
||||
from heat.engine.clients import client_plugin
|
||||
from heat.engine import constraints
|
||||
|
||||
from openstack import profile
|
||||
from openstack import session
|
||||
from senlinclient import client
|
||||
from senlinclient.common import exc
|
||||
|
||||
@ -28,16 +30,15 @@ class SenlinClientPlugin(client_plugin.ClientPlugin):
|
||||
VERSION = '1'
|
||||
|
||||
def _create(self):
|
||||
con = self.context
|
||||
args = {
|
||||
'auth_url': con.auth_url,
|
||||
'project_id': con.tenant_id,
|
||||
'token': con.keystone_session.get_token(),
|
||||
'user_id': con.user_id,
|
||||
'auth_plugin': 'token',
|
||||
|
||||
}
|
||||
return client.Client(self.VERSION, **args)
|
||||
interface = self._get_client_option(CLIENT_NAME, 'endpoint_type')
|
||||
prof = profile.Profile()
|
||||
prof.set_interface(self.CLUSTERING, interface)
|
||||
prof.set_region(self.CLUSTERING, self._get_region_name())
|
||||
keystone_session = self.context.keystone_session
|
||||
s = session.Session(session=keystone_session,
|
||||
auth=keystone_session.auth,
|
||||
profile=prof)
|
||||
return client.Client(self.VERSION, session=s)
|
||||
|
||||
def generate_spec(self, spec_type, spec_props):
|
||||
spec = {'properties': spec_props}
|
||||
|
@ -45,23 +45,13 @@ class SwiftClientPlugin(client_plugin.ClientPlugin):
|
||||
service_types = [OBJECT_STORE] = ['object-store']
|
||||
|
||||
def _create(self):
|
||||
|
||||
con = self.context
|
||||
endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type')
|
||||
args = {
|
||||
'auth_version': '2.0',
|
||||
'tenant_name': con.project_name,
|
||||
'user': con.username,
|
||||
'key': None,
|
||||
'authurl': None,
|
||||
'preauthtoken': con.keystone_session.get_token(),
|
||||
'preauthurl': self.url_for(service_type=self.OBJECT_STORE,
|
||||
endpoint_type=endpoint_type),
|
||||
'os_options': {'endpoint_type': endpoint_type},
|
||||
'cacert': self._get_client_option(CLIENT_NAME, 'ca_file'),
|
||||
'insecure': self._get_client_option(CLIENT_NAME, 'insecure')
|
||||
}
|
||||
return sc.Connection(**args)
|
||||
os_options = {'endpoint_type': endpoint_type,
|
||||
'service_type': self.OBJECT_STORE,
|
||||
'region_name': self._get_region_name()}
|
||||
return sc.Connection(auth_version=3,
|
||||
session=self.context.keystone_session,
|
||||
os_options=os_options)
|
||||
|
||||
def is_client_exception(self, ex):
|
||||
return isinstance(ex, exceptions.ClientException)
|
||||
|
@ -138,6 +138,11 @@ class SwiftTest(common.HeatTestCase):
|
||||
# Test
|
||||
container = self._create_container(stack)
|
||||
|
||||
# call this to populate the url of swiftclient. This is actually
|
||||
# set in head_container/put_container, but we're patching them in
|
||||
# this test.
|
||||
container.client().get_auth()
|
||||
|
||||
# Verify Attributes
|
||||
self.assertEqual(container_name, container.FnGetRefId())
|
||||
self.assertEqual('82', container.FnGetAtt('ObjectCount'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user