def get_subcommand_parser(self, version):
     parser = self.get_base_parser()
     self.subcommands = {}
     subparsers = parser.add_subparsers(metavar='<subcommand>')
     # submodule = utils.import_versioned_module(version, 'shell')
     enhance_parser(parser, subparsers, self.subcommands)
     utils.define_commands_from_module(subparsers, self, self.subcommands)
     return parser
Exemplo n.º 2
0
def enhance_parser(parser, subparsers, cmd_mapper):
    '''Take a basic (nonversioned) parser and enhance it with
    commands and options specific for this version of API.

    :param parser: top level parser :param subparsers: top level
        parser's subparsers collection where subcommands will go
    '''
    for command_module in COMMAND_MODULES:
        utils.define_commands_from_module(subparsers, command_module,
                                          cmd_mapper)
Exemplo n.º 3
0
def enhance_parser(parser, subparsers, cmd_mapper):
    '''Take a basic (nonversioned) parser and enhance it with
    commands and options specific for this version of API.

    :param parser: top level parser :param subparsers: top level
        parser's subparsers collection where subcommands will go
    '''
    for command_module in COMMAND_MODULES:
        utils.define_commands_from_module(subparsers, command_module,
                                          cmd_mapper)
Exemplo n.º 4
0
    def get_subcommand_parser(self, version):
        parser = self.get_base_parser()

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>',
                                           dest='subparser_name')
        submodule = importutils.import_versioned_module('ironicclient',
                                                        version, 'shell')
        submodule.enhance_parser(parser, subparsers, self.subcommands)
        utils.define_commands_from_module(subparsers, self, self.subcommands)
        return parser
Exemplo n.º 5
0
    def get_subcommand_parser(self, version):
        parser = self.get_base_parser()

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>',
                                           dest='subparser_name')
        submodule = importutils.import_versioned_module(
            'ironicclient', version, 'shell')
        submodule.enhance_parser(parser, subparsers, self.subcommands)
        utils.define_commands_from_module(subparsers, self, self.subcommands)
        return parser
Exemplo n.º 6
0
    def get_subcommand_parser(self, version):
        parser = self.get_base_parser()

        self.subcommands = {}
        subparsers = parser.add_subparsers(metavar='<subcommand>',
                                           dest='subparser_name')
        try:
            submodule = importutils.import_versioned_module('ironicclient',
                                                            version, 'shell')
        except ImportError as e:
            msg = _("Invalid client version '%(version)s'. "
                    "Major part must be one of: '%(major)s'") % {
                "version": version,
                "major": ", ".join(self.get_available_major_versions())}
            raise exceptions.UnsupportedVersion(
                _('%(message)s, error was: %(error)s') %
                {'message': msg, 'error': e})
        submodule.enhance_parser(parser, subparsers, self.subcommands)
        utils.define_commands_from_module(subparsers, self, self.subcommands)
        return parser
def enhance_parser(parser, subparsers, cmd_mapper):
    for command_module in COMMAND_MODULES:
         utils.define_commands_from_module(subparsers, command_module,
                                           cmd_mapper)