diff --git a/heat/engine/clients/os/senlin.py b/heat/engine/clients/os/senlin.py index 32e51a8a03..e77eab1b29 100644 --- a/heat/engine/clients/os/senlin.py +++ b/heat/engine/clients/os/senlin.py @@ -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} diff --git a/heat/engine/clients/os/swift.py b/heat/engine/clients/os/swift.py index ce02dbf154..edddaeb18e 100644 --- a/heat/engine/clients/os/swift.py +++ b/heat/engine/clients/os/swift.py @@ -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) diff --git a/heat/tests/openstack/swift/test_container.py b/heat/tests/openstack/swift/test_container.py index 9a7eb3d1a6..fe74a7c0d2 100644 --- a/heat/tests/openstack/swift/test_container.py +++ b/heat/tests/openstack/swift/test_container.py @@ -137,6 +137,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'))