diff --git a/openstackclient/common/commandmanager.py b/openstackclient/common/commandmanager.py index 08710c7735..9901ea2089 100644 --- a/openstackclient/common/commandmanager.py +++ b/openstackclient/common/commandmanager.py @@ -16,7 +16,6 @@ """Modify cliff.CommandManager""" import logging -import pkg_resources import cliff.commandmanager @@ -35,23 +34,14 @@ class CommandManager(cliff.commandmanager.CommandManager): self.group_list = [] super(CommandManager, self).__init__(namespace, convert_underscores) - def _load_commands(self, group=None): - if not group: - group = self.namespace - self.group_list.append(group) - for ep in pkg_resources.iter_entry_points(group): - cmd_name = ( - ep.name.replace('_', ' ') - if self.convert_underscores - else ep.name - ) - self.commands[cmd_name] = ep - return + def load_commands(self, namespace): + self.group_list.append(namespace) + return super(CommandManager, self).load_commands(namespace) def add_command_group(self, group=None): """Adds another group of command entrypoints""" if group: - self._load_commands(group) + self.load_commands(group) def get_command_groups(self): """Returns a list of the loaded command groups""" diff --git a/openstackclient/tests/common/test_commandmanager.py b/openstackclient/tests/common/test_commandmanager.py index 088ea21ea8..ca9ee9a70e 100644 --- a/openstackclient/tests/common/test_commandmanager.py +++ b/openstackclient/tests/common/test_commandmanager.py @@ -36,15 +36,15 @@ FAKE_CMD_BETA = FakeCommand class FakeCommandManager(commandmanager.CommandManager): commands = {} - def _load_commands(self, group=None): - if not group: + def load_commands(self, namespace): + if namespace == 'test': self.commands['one'] = FAKE_CMD_ONE self.commands['two'] = FAKE_CMD_TWO - self.group_list.append(self.namespace) - else: + self.group_list.append(namespace) + elif namespace == 'greek': self.commands['alpha'] = FAKE_CMD_ALPHA self.commands['beta'] = FAKE_CMD_BETA - self.group_list.append(group) + self.group_list.append(namespace) class TestCommandManager(utils.TestCase): @@ -62,7 +62,7 @@ class TestCommandManager(utils.TestCase): self.assertEqual(cmd_one, FAKE_CMD_ONE) # Load another command group - mgr.add_command_group('latin') + mgr.add_command_group('greek') # Find a new command cmd_alpha, name, args = mgr.find_command(['alpha']) @@ -82,7 +82,7 @@ class TestCommandManager(utils.TestCase): self.assertEqual(cmd_mock, mock_cmd_one) # Load another command group - mgr.add_command_group('latin') + mgr.add_command_group('greek') gl = mgr.get_command_groups() - self.assertEqual(['test', 'latin'], gl) + self.assertEqual(['test', 'greek'], gl)