Beispiel #1
0
    def __init__(self):

        super(OpenStackShell, self).__init__(
            description=__doc__.strip(),
            version=openstackclient.__version__,
            command_manager=commandmanager.CommandManager('openstack.cli'),
            deferred_help=True)

        self.api_version = {}

        # Assume TLS host certificate verification is enabled
        self.verify = True
Beispiel #2
0
 def test_get_command_names(self):
     mock_cmd_one = mock.Mock()
     mock_cmd_one.name = 'one'
     mock_cmd_two = mock.Mock()
     mock_cmd_two.name = 'cmd two'
     mock_pkg_resources = mock.Mock(
         return_value=[mock_cmd_one, mock_cmd_two], )
     with mock.patch(
             'pkg_resources.iter_entry_points',
             mock_pkg_resources,
     ) as iter_entry_points:
         mgr = commandmanager.CommandManager('test')
         iter_entry_points.assert_called_once_with('test')
         cmds = mgr.get_command_names('test')
         self.assertEqual(['one', 'cmd two'], cmds)
Beispiel #3
0
    def __init__(
        self,
        description=None,
        version=None,
        command_manager=None,
        stdin=None,
        stdout=None,
        stderr=None,
        interactive_app_factory=None,
        deferred_help=False,
    ):
        # Patch command.Command to add a default auth_required = True
        command.Command.auth_required = True

        # Some commands do not need authentication
        help.HelpCommand.auth_required = False
        complete.CompleteCommand.auth_required = False

        # Slight change to the meaning of --debug
        self.DEFAULT_DEBUG_VALUE = None
        self.DEFAULT_DEBUG_HELP = 'Set debug logging and traceback on errors.'

        # Do default for positionals
        if not command_manager:
            cm = commandmanager.CommandManager('openstack.cli')
        else:
            cm = command_manager

        super(OpenStackShell, self).__init__(
            description=__doc__.strip(),
            version=version,
            command_manager=cm,
            deferred_help=True,
        )

        # Until we have command line arguments parsed, dump any stack traces
        self.dump_stack_trace = True

        # Set in subclasses
        self.api_version = None

        self.client_manager = None
        self.command_options = None

        self.do_profile = False