Make method import_versioned_module work

Oslo.utils 3.17 provides similar function, just use it.
For more information:
[1] http://docs.openstack.org/developer/oslo.utils/history.html

Closes-Bug: #1627313

Change-Id: Ie738e910cc72535fe97295d7e118eda2412ecd15
This commit is contained in:
shizhihui 2016-11-02 16:09:48 +08:00
parent 61794b7822
commit 8885ce7818
3 changed files with 5 additions and 11 deletions

View File

@ -10,10 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from heatclient.common import utils
from oslo_utils import importutils
def Client(version, *args, **kwargs):
module = utils.import_versioned_module(version, 'client')
module = importutils.import_versioned_module('heatclient',
version, 'client')
client_class = getattr(module, 'Client')
return client_class(*args, **kwargs)

View File

@ -21,7 +21,6 @@ import uuid
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
from oslo_utils import importutils
import prettytable
import six
from six.moves.urllib import error
@ -239,13 +238,6 @@ def find_resource(manager, name_or_id):
raise exc.CommandError(msg)
def import_versioned_module(version, submodule=None):
module = 'heatclient.v%s' % version
if submodule:
module = '.'.join((module, submodule))
return importutils.import_module(module)
def format_parameters(params, parse_semicolon=True):
'''Reformat parameters into dict of format expected by the API.'''

View File

@ -348,7 +348,8 @@ class HeatShell(object):
self.subcommands = {}
subparsers = parser.add_subparsers(metavar='<subcommand>')
submodule = utils.import_versioned_module(version, 'shell')
submodule = importutils.import_versioned_module('heatclient',
version, 'shell')
self._find_actions(subparsers, submodule)
self._find_actions(subparsers, self)
self._add_bash_completion_subparser(subparsers)