Make method import_versioned_module work

Oslo.utils 3.17 provides similar function, just use it.
For more information:

Closes-Bug: #1627313

Change-Id: Ie738e910cc72535fe97295d7e118eda2412ecd15
shizhihui 6 years ago
parent 61794b7822
commit 8885ce7818

@ -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)

@ -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.'''

@ -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)