Merge "Use function import_versioned_module from oslo.utils"
This commit is contained in:
commit
14963b863d
@ -11,9 +11,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from keystoneauth1 import loading as kaloading
|
from keystoneauth1 import loading as kaloading
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from ironicclient.common.i18n import _
|
from ironicclient.common.i18n import _
|
||||||
from ironicclient.common import utils
|
|
||||||
from ironicclient import exc
|
from ironicclient import exc
|
||||||
|
|
||||||
|
|
||||||
@ -146,6 +146,7 @@ def get_client(api_version, os_auth_token=None, ironic_url=None,
|
|||||||
|
|
||||||
|
|
||||||
def Client(version, *args, **kwargs):
|
def Client(version, *args, **kwargs):
|
||||||
module = utils.import_versioned_module(version, 'client')
|
module = importutils.import_versioned_module('ironicclient',
|
||||||
|
version, 'client')
|
||||||
client_class = getattr(module, 'Client')
|
client_class = getattr(module, 'Client')
|
||||||
return client_class(*args, **kwargs)
|
return client_class(*args, **kwargs)
|
||||||
|
@ -26,7 +26,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from oslo_utils import importutils
|
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
|
|
||||||
from ironicclient.common.i18n import _
|
from ironicclient.common.i18n import _
|
||||||
@ -73,13 +72,6 @@ def define_commands_from_module(subparsers, command_module, cmd_mapper):
|
|||||||
define_command(subparsers, command, callback, cmd_mapper)
|
define_command(subparsers, command, callback, cmd_mapper)
|
||||||
|
|
||||||
|
|
||||||
def import_versioned_module(version, submodule=None):
|
|
||||||
module = 'ironicclient.v%s' % version
|
|
||||||
if submodule:
|
|
||||||
module = '.'.join((module, submodule))
|
|
||||||
return importutils.import_module(module)
|
|
||||||
|
|
||||||
|
|
||||||
def split_and_deserialize(string):
|
def split_and_deserialize(string):
|
||||||
"""Split and try to JSON deserialize a string.
|
"""Split and try to JSON deserialize a string.
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import sys
|
|||||||
|
|
||||||
from keystoneauth1.loading import session as kasession
|
from keystoneauth1.loading import session as kasession
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
|
from oslo_utils import importutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
import ironicclient
|
import ironicclient
|
||||||
@ -240,7 +241,8 @@ class IronicShell(object):
|
|||||||
self.subcommands = {}
|
self.subcommands = {}
|
||||||
subparsers = parser.add_subparsers(metavar='<subcommand>',
|
subparsers = parser.add_subparsers(metavar='<subcommand>',
|
||||||
dest='subparser_name')
|
dest='subparser_name')
|
||||||
submodule = utils.import_versioned_module(version, 'shell')
|
submodule = importutils.import_versioned_module('ironicclient',
|
||||||
|
version, 'shell')
|
||||||
submodule.enhance_parser(parser, subparsers, self.subcommands)
|
submodule.enhance_parser(parser, subparsers, self.subcommands)
|
||||||
utils.define_commands_from_module(subparsers, self, self.subcommands)
|
utils.define_commands_from_module(subparsers, self, self.subcommands)
|
||||||
return parser
|
return parser
|
||||||
|
Loading…
x
Reference in New Issue
Block a user