Пример #1
0
    def setup(self):
        cli.app.CommandLineApp.setup(self)

        # Global parameters
        self.add_param('-v',
                       '--verbose',
                       action='count',
                       default=0,
                       help="Increase verbosity. If at least four `-v` option "
                       "are given, elasticluster will create new VMs "
                       "sequentially instead of doing it in parallel.")
        self.add_param(
            '-s',
            '--storage',
            metavar="PATH",
            help="Path to the storage folder. (Default: `%(default)s`",
            default=Creator.DEFAULT_STORAGE_PATH)
        self.add_param('-c',
                       '--config',
                       metavar='PATH',
                       help=("Path to the configuration file;"
                             " default: `%(default)s`."
                             " If directory `PATH.d` exists,"
                             " all files matching"
                             " pattern `PATH.d/*.conf` are parsed."),
                       default=self.default_configuration_file)
        self.add_param('--version',
                       action='store_true',
                       help="Print version information and exit.")

        # all commands in this list will be added to the subcommands
        # if you add an object here, make sure it implements the
        # subcommands.abstract_command contract
        commands = [
            Start(self.params),
            Stop(self.params),
            Pause(self.params),
            Resume(self.params),
            ListClusters(self.params),
            ListNodes(self.params),
            ListTemplates(self.params),
            SetupCluster(self.params),
            ResizeCluster(self.params),
            SshFrontend(self.params),
            SftpFrontend(self.params),
            GC3PieConfig(self.params),
            MigrationCommand(self.params),
            RemoveNode(self.params),
            ExportCluster(self.params),
            ImportCluster(self.params),
        ]

        # to parse subcommands
        self.subparsers = self.argparser.add_subparsers(
            title="COMMANDS",
            help=("Available commands. Run `elasticluster CMD --help`"
                  " to have information on command `CMD`."))

        for command in commands:
            command.setup(self.subparsers)
Пример #2
0
    def setup(self):
        cli.app.CommandLineApp.setup(self)

        # all commands in this list will be added to the subcommands
        # if you add an object here, make sure it implements the
        # subcommands.abstract_command contract
        commands = [
            Start(self.params),
            Stop(self.params),
            ListClusters(self.params),
            ListNodes(self.params),
            ListTemplates(self.params),
            SetupCluster(self.params),
            ResizeCluster(self.params),
            SshFrontend(self.params),
            SftpFrontend(self.params),
            GC3PieConfig(self.params),
            MigrationCommand(self.params),
            RemoveNode(self.params),
            ExportCluster(self.params),
            ImportCluster(self.params),
        ]

        # global parameters
        self.add_param('-v',
                       '--verbose',
                       action='count',
                       default=0,
                       help="Increase verbosity. If at least four `-v` option "
                       "are given, elasticluster will create new VMs "
                       "sequentially instead of doing it in parallel.")
        self.add_param('-s',
                       '--storage',
                       metavar="PATH",
                       help="Path to the storage folder. Default: `%s`" %
                       Configurator.default_storage_path,
                       default=Configurator.default_storage_path)
        self.add_param('-c',
                       '--config',
                       metavar='PATH',
                       help="Path to the configuration file. Default: `%s`. "
                       "If directory PATH.d, also all files like "
                       "PATH.d/*.conf are parsed." %
                       self.default_configuration_file,
                       default=self.default_configuration_file)
        self.add_param('--version',
                       action='store_true',
                       help="Print version information and exit.")

        # to parse subcommands
        self.subparsers = self.argparser.add_subparsers(
            title="COMMANDS",
            help="Available commands. Run `elasticluster cmd --help` "
            "to have information on command `cmd`.")

        for command in commands:
            if isinstance(command, AbstractCommand):
                command.setup(self.subparsers)