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:
parent
61794b7822
commit
8885ce7818
|
@ -10,10 +10,11 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from heatclient.common import utils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
|
|
||||||
def Client(version, *args, **kwargs):
|
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')
|
client_class = getattr(module, 'Client')
|
||||||
return client_class(*args, **kwargs)
|
return client_class(*args, **kwargs)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import uuid
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import importutils
|
|
||||||
import prettytable
|
import prettytable
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import error
|
from six.moves.urllib import error
|
||||||
|
@ -239,13 +238,6 @@ def find_resource(manager, name_or_id):
|
||||||
raise exc.CommandError(msg)
|
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):
|
def format_parameters(params, parse_semicolon=True):
|
||||||
'''Reformat parameters into dict of format expected by the API.'''
|
'''Reformat parameters into dict of format expected by the API.'''
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,8 @@ class HeatShell(object):
|
||||||
|
|
||||||
self.subcommands = {}
|
self.subcommands = {}
|
||||||
subparsers = parser.add_subparsers(metavar='<subcommand>')
|
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, submodule)
|
||||||
self._find_actions(subparsers, self)
|
self._find_actions(subparsers, self)
|
||||||
self._add_bash_completion_subparser(subparsers)
|
self._add_bash_completion_subparser(subparsers)
|
||||||
|
|
Loading…
Reference in New Issue