From 8dd4afab50a1f71620537ab7f79d61465fb5c4fa Mon Sep 17 00:00:00 2001 From: tengqm Date: Tue, 30 Jan 2018 22:37:35 -0500 Subject: [PATCH] Add back client module The removal of the Client module breaks downstream consumers such as heat. This patch adds it back. Change-Id: I422bd6e9ab0cbb985380f1b898435344f1dd8ac9 --- senlinclient/client.py | 23 +++++++++++++++++++++++ senlinclient/common/utils.py | 8 ++++++++ 2 files changed, 31 insertions(+) create mode 100644 senlinclient/client.py diff --git a/senlinclient/client.py b/senlinclient/client.py new file mode 100644 index 00000000..3d9c751f --- /dev/null +++ b/senlinclient/client.py @@ -0,0 +1,23 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from senlinclient.common import utils + + +def Client(api_ver, *args, **kwargs): + """Import versioned client module. + + :param api_ver: API version required. + """ + module = utils.import_versioned_module(api_ver, 'client') + cls = getattr(module, 'Client') + return cls(*args, **kwargs) diff --git a/senlinclient/common/utils.py b/senlinclient/common/utils.py index 5f51661d..407848e4 100644 --- a/senlinclient/common/utils.py +++ b/senlinclient/common/utils.py @@ -15,6 +15,7 @@ from __future__ import print_function from heatclient.common import template_utils from oslo_serialization import jsonutils +from oslo_utils import importutils import prettytable import six import yaml @@ -23,6 +24,13 @@ from senlinclient.common import exc from senlinclient.common.i18n import _ +def import_versioned_module(version, submodule=None): + module = 'senlinclient.v%s' % version + if submodule: + module = '.'.join((module, submodule)) + return importutils.import_module(module) + + def format_nested_dict(d, fields, column_names): if d is None: return ''