From 2ea56d5b0ec93b9b6d2ed50218245c7f8e512752 Mon Sep 17 00:00:00 2001 From: Filip Blaha Date: Wed, 17 Dec 2014 16:40:19 +0100 Subject: [PATCH] Adds congress client to client manager Implements blueprint congress-support-in-murano Change-Id: I270f48fe37cdc8cc6a6e781aa4cf1a32a69f9faa --- murano/engine/client_manager.py | 43 ++++++++++++++++++++++++++++----- requirements.txt | 1 + 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/murano/engine/client_manager.py b/murano/engine/client_manager.py index b622e4fa..43e64af7 100644 --- a/murano/engine/client_manager.py +++ b/murano/engine/client_manager.py @@ -12,23 +12,29 @@ # License for the specific language governing permissions and limitations # under the License. - from eventlet import semaphore import heatclient.client as hclient -try: - import mistralclient.api.client as mistralclient -except ImportError as mistral_import_error: - mistralclient = None - +import keystoneclient import muranoclient.v1.client as muranoclient import neutronclient.v2_0.client as nclient +from oslo.config import cfg from murano.common import config from murano.dsl import helpers from murano.engine import auth_utils from murano.engine import environment +try: + # integration with congress is optional + import congressclient.v1.client as congress_client +except ImportError as congress_client_import_error: + congress_client = None +try: + import mistralclient.api.client as mistralclient +except ImportError as mistral_import_error: + mistralclient = None + class ClientManager(object): def __init__(self): @@ -77,6 +83,31 @@ class ClientManager(object): return self._get_client(context, 'keystone', use_trusts, factory) + def get_congress_client(self, context, use_trusts=True): + """Client for congress services + + :return: initialized congress client + :raise ImportError: in case that python-congressclient + is not present on python path + """ + + if not congress_client: + # congress client was not imported + raise congress_client_import_error + if not config.CONF.engine.use_trusts: + use_trusts = False + + def factory(keystone_client, auth_token): + auth = keystoneclient.auth.identity.v2.Token( + auth_url=cfg.CONF.keystone_authtoken.auth_uri, + tenant_name=keystone_client.tenant_name, + token=auth_token) + session = keystoneclient.session.Session(auth=auth) + return congress_client.Client(session=session, + service_type='policy') + + return self._get_client(context, 'congress', use_trusts, factory) + def get_heat_client(self, context, use_trusts=True): if not config.CONF.engine.use_trusts: use_trusts = False diff --git a/requirements.txt b/requirements.txt index 2ce3858e..0a8a6e7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,6 +26,7 @@ Paste jsonschema>=2.0.0,<3.0.0 python-keystoneclient>=0.11.1 python-heatclient>=0.2.9 +python-congressclient>=1.0.2 python-neutronclient>=2.3.6,<3 oslo.db>=1.1.0 # Apache-2.0 oslo.config>=1.4.0 # Apache-2.0