Revert "CLI: remove command opts/args in "gnt-X""
authorIustin Pop <iustin@google.com>
Tue, 13 May 2008 13:03:14 +0000 (13:03 +0000)
committerIustin Pop <iustin@google.com>
Tue, 13 May 2008 13:03:14 +0000 (13:03 +0000)
This reverts commit 974, as it's not a good way to proceed (we still
want the usage to be shown when using gnt-X $cmd --help).

Reviewed-by: ultrotter

lib/cli.py
scripts/gnt-backup
scripts/gnt-cluster
scripts/gnt-debug [changed mode: 0755->0644]
scripts/gnt-instance
scripts/gnt-node
scripts/gnt-os

index 3b823fc..72e32aa 100644 (file)
@@ -254,15 +254,16 @@ def _ParseArgs(argv, commands, aliases):
            "\n%(bin)s <command> --help to see details, or"
            " man %(bin)s\n" % {"bin": binary})
     # compute the max line length for cmd + usage
-    mlen = max([len(" %s" % cmd) for cmd in commands])
+    mlen = max([len(" %s %s" % (cmd, commands[cmd][3])) for cmd in commands])
     mlen = min(60, mlen) # should not get here...
     # and format a nice command list
     print "Commands:"
     for cmd in sortedcmds:
-      cmdstr = " %s" % (cmd,)
-      help_text = commands[cmd][3]
+      cmdstr = " %s %s" % (cmd, commands[cmd][3])
+      help_text = commands[cmd][4]
       help_lines = textwrap.wrap(help_text, 79-3-mlen)
-      print "%-*s - %s" % (mlen, cmdstr, help_lines.pop(0))
+      print "%-*s - %s" % (mlen, cmdstr,
+                                          help_lines.pop(0))
       for line in help_lines:
         print "%-*s   %s" % (mlen, "", line)
     print
index b7be0b0..61e95a6 100755 (executable)
@@ -168,7 +168,7 @@ commands = {
                         help="List only backups stored on this node"
                              " (can be used multiple times)"),
             ],
-           "Lists instance exports available in the ganeti cluster"),
+           "", "Lists instance exports available in the ganeti cluster"),
   'export': (ExportInstance, ARGS_ONE,
              [DEBUG_OPT, FORCE_OPT,
               make_option("-n", "--node", dest="node", help="Target node",
@@ -176,11 +176,13 @@ commands = {
               make_option("","--noshutdown", dest="shutdown",
                           action="store_false", default=True,
                           help="Don't shutdown the instance (unsafe)"), ],
+             "-n <target_node> [opts...] <name>",
              "Exports an instance to an image"),
-  'import': (ImportInstance, ARGS_ONE, import_opts,
+  'import': (ImportInstance, ARGS_ONE, import_opts, "[opts...] <name>",
              "Imports an instance from an exported image"),
   'remove': (RemoveExport, ARGS_ONE,
              [DEBUG_OPT],
+             "<name>",
              "Remove exports of named instance from the filesystem."),
   }
 
index 681dcbd..5fffb2e 100755 (executable)
@@ -321,6 +321,7 @@ commands = {
                         metavar="NETDEV",
                         default=constants.DEFAULT_BRIDGE,),
             ],
+           "[opts...] <cluster_name>",
            "Initialises a new cluster configuration"),
   'destroy': (DestroyCluster, ARGS_NONE,
               [DEBUG_OPT,
@@ -328,8 +329,9 @@ commands = {
                            help="Destroy cluster",
                            action="store_true"),
               ],
-              "Destroy cluster"),
+              "", "Destroy cluster"),
   'rename': (RenameCluster, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
+               "<new_name>",
                "Renames the cluster"),
   'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
              make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
@@ -337,29 +339,31 @@ commands = {
                          action="store_true",
                          default=False,),
              ],
-             "Does a check on the cluster configuration"),
+             "", "Does a check on the cluster configuration"),
   'verify-disks': (VerifyDisks, ARGS_NONE, [DEBUG_OPT],
-                   "Does a check on the cluster disk status"),
+                   "", "Does a check on the cluster disk status"),
   'masterfailover': (MasterFailover, ARGS_NONE, [DEBUG_OPT],
-                     "Makes the current node the master"),
+                     "", "Makes the current node the master"),
   'version': (ShowClusterVersion, ARGS_NONE, [DEBUG_OPT],
-              "Shows the cluster version"),
+              "", "Shows the cluster version"),
   'getmaster': (ShowClusterMaster, ARGS_NONE, [DEBUG_OPT],
-                "Shows the cluster master"),
+                "", "Shows the cluster master"),
   'copyfile': (ClusterCopyFile, ARGS_ONE, [DEBUG_OPT, node_option],
+               "[-n node...] <filename>",
                "Copies a file to all (or only some) nodes"),
   'command': (RunClusterCommand, ARGS_ATLEAST(1), [DEBUG_OPT, node_option],
+              "[-n node...] <command>",
               "Runs a command on all (or only some) nodes"),
   'info': (ShowClusterConfig, ARGS_NONE, [DEBUG_OPT],
-                 "Show cluster configuration"),
+                 "", "Show cluster configuration"),
   'list-tags': (ListTags, ARGS_NONE,
-                [DEBUG_OPT], "List the tags of the cluster"),
+                [DEBUG_OPT], "", "List the tags of the cluster"),
   'add-tags': (AddTags, ARGS_ANY, [DEBUG_OPT, TAG_SRC_OPT],
-               "Add tags to the cluster"),
+               "tag...", "Add tags to the cluster"),
   'remove-tags': (RemoveTags, ARGS_ANY, [DEBUG_OPT, TAG_SRC_OPT],
-                  "Remove tags from the cluster"),
+                  "tag...", "Remove tags from the cluster"),
   'search-tags': (SearchTags, ARGS_ONE,
-                  [DEBUG_OPT], "Searches the tags on all objects on"
+                  [DEBUG_OPT], "", "Searches the tags on all objects on"
                   " the cluster for a given pattern (regex)"),
   }
 
old mode 100755 (executable)
new mode 100644 (file)
index 1e4e7b1..7f1ab82
@@ -97,7 +97,7 @@ commands = {
                          action="append",
                          help="Select nodes to sleep on"),
              ],
-            "Executes a TestDelay OpCode"),
+            "[opts...] <duration>", "Executes a TestDelay OpCode"),
   'allocator': (TestAllocator, ARGS_ONE,
                 [DEBUG_OPT,
                  make_option("--dir", dest="direction",
@@ -128,7 +128,7 @@ commands = {
                  make_option("--tags", default=None,
                              help="Comma separated list of tags"),
                  ],
-                "Executes a TestAllocator OpCode"),
+                "{opts...} <instance>", "Executes a TestAllocator OpCode"),
   }
 
 
index 808b7b7..1f1b00a 100755 (executable)
@@ -854,14 +854,17 @@ add_opts = [
 
 commands = {
   'add': (AddInstance, ARGS_ONE, add_opts,
+          "[opts...] <name>",
           "Creates and adds a new instance to the cluster"),
   'add-mirror': (AddMDDRBDComponent, ARGS_ONE,
                 [DEBUG_OPT, node_opt,
                  make_option("-b", "--disk", dest="disk", metavar="sdX",
                              help=("The name of the instance disk for which to"
                                    " add the mirror"))],
+                "-n node -b disk <instance>",
                 "Creates a new mirror for the instance"),
   'console': (ConnectToInstanceConsole, ARGS_ONE, [DEBUG_OPT],
+              "<instance>",
               "Opens a console on the specified instance"),
   'failover': (FailoverInstance, ARGS_ONE,
                [DEBUG_OPT, FORCE_OPT,
@@ -870,12 +873,13 @@ commands = {
                             help="Ignore the consistency of the disks on"
                             " the secondary"),
                 ],
+               "[-f] <instance>",
                "Stops the instance and starts it on the backup node, using"
                " the remote mirror (only for instances of type drbd or remote_raid1)"),
-  'info': (ShowInstanceConfig, ARGS_ANY, [DEBUG_OPT],
+  'info': (ShowInstanceConfig, ARGS_ANY, [DEBUG_OPT], "[<instance>...]",
            "Show information on the specified instance"),
   'list': (ListInstances, ARGS_NONE,
-           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
+           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], "",
            "Lists the instances and their status. The available fields are"
            " (see the man page for details): status, oper_state, oper_ram,"
            " name, os, pnode, snodes, admin_state, admin_ram, disk_template,"
@@ -883,7 +887,7 @@ commands = {
            " list is (in order): %s." % ", ".join(_LIST_DEF_FIELDS),
            ),
   'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
-                "Reinstall a stopped instance"),
+                "[-f] <instance>", "Reinstall a stopped instance"),
   'remove': (RemoveInstance, ARGS_ONE,
              [DEBUG_OPT, FORCE_OPT,
               make_option("--ignore-failures", dest="ignore_failures",
@@ -892,7 +896,7 @@ commands = {
                                 " if there are failures during the removal"
                                 " process (shutdown, disk removal, etc.)")),
               ],
-             "Shuts down the instance and removes it"),
+             "[-f] <instance>", "Shuts down the instance and removes it"),
   'remove-mirror': (RemoveMDDRBDComponent, ARGS_ONE,
                    [DEBUG_OPT, node_opt,
                     make_option("-b", "--disk", dest="disk", metavar="sdX",
@@ -903,6 +907,7 @@ commands = {
                                       " which to remove from the mirror"),
                                 type="int"),
                     ],
+                   "-b disk -p port <instance>",
                    "Removes a mirror from the instance"),
   'rename': (RenameInstance, ARGS_FIXED(2),
              [DEBUG_OPT,
@@ -911,7 +916,7 @@ commands = {
                           " is alive",
                           default=False, action="store_true"),
               ],
-             "Rename the instance"),
+             "<instance> <new_name>", "Rename the instance"),
   'replace-disks': (ReplaceDisks, ARGS_ONE,
                     [DEBUG_OPT,
                      make_option("-n", "--new-secondary", dest="new_secondary",
@@ -936,7 +941,8 @@ commands = {
                                  " secondary node replacement)",
                                  default=None, type="string"),
                      ],
-                    "Replaces disks for the instance"),
+                    "[-s|-p|-n NODE] <instance>",
+                    "Replaces all disks for the instance"),
   'modify': (SetInstanceParms, ARGS_ONE,
              [DEBUG_OPT, FORCE_OPT,
               cli_option("-m", "--memory", dest="mem",
@@ -981,11 +987,11 @@ commands = {
                           help="bind address for VNC (IP address)",
                           default=None, type="string", metavar="<VNCADDRESS>"),
               ],
-             "Alters the parameters of an instance"),
+             "<instance>", "Alters the parameters of an instance"),
   'shutdown': (ShutdownInstance, ARGS_ANY,
                [DEBUG_OPT, m_node_opt, m_pri_node_opt, m_sec_node_opt,
                 m_clust_opt, m_inst_opt, m_force_multi],
-               "Stops an instance"),
+               "<instance>", "Stops an instance"),
   'startup': (StartupInstance, ARGS_ANY,
               [DEBUG_OPT, FORCE_OPT, m_force_multi,
                make_option("-e", "--extra", dest="extra_args",
@@ -994,7 +1000,7 @@ commands = {
                m_node_opt, m_pri_node_opt, m_sec_node_opt,
                m_clust_opt, m_inst_opt,
                ],
-              "Starts an instance"),
+            "<instance>", "Starts an instance"),
 
   'reboot': (RebootInstance, ARGS_ANY,
               [DEBUG_OPT, m_force_multi,
@@ -1011,17 +1017,19 @@ commands = {
                m_node_opt, m_pri_node_opt, m_sec_node_opt,
                m_clust_opt, m_inst_opt,
                ],
-             "Reboots an instance"),
+            "<instance>", "Reboots an instance"),
   'activate-disks': (ActivateDisks, ARGS_ONE, [DEBUG_OPT],
+                     "<instance>",
                      "Activate an instance's disks"),
   'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT],
+                       "<instance>",
                        "Deactivate an instance's disks"),
   'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
-                "List the tags of the given instance"),
+                "<node_name>", "List the tags of the given instance"),
   'add-tags': (AddTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT],
-               "Add tags to the given instance"),
+               "<node_name> tag...", "Add tags to the given instance"),
   'remove-tags': (RemoveTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT],
-                  "Remove tags from given instance"),
+                  "<node_name> tag...", "Remove tags from given instance"),
   }
 
 aliases = {
index 63e7cc8..85dff02 100755 (executable)
@@ -290,9 +290,10 @@ commands = {
            make_option("-s", "--secondary-ip", dest="secondary_ip",
                        help="Specify the secondary ip for the node",
                        metavar="ADDRESS", default=None),],
-          "Add a node to the cluster"),
+          "[-s ip] <node_name>", "Add a node to the cluster"),
   'evacuate': (EvacuateNode, ARGS_FIXED(2),
                [DEBUG_OPT, FORCE_OPT],
+               "[-f] <src> <dst>",
                "Relocate the secondary instances from the first node"
                " to the second one (only for instances of type remote_raid1"
                " or drbd)"),
@@ -303,30 +304,31 @@ commands = {
                             help="Ignore the consistency of the disks on"
                             " the secondary"),
                 ],
+               "[-f] <node>",
                "Stops the primary instances on a node and start them on their"
                " secondary node (only for instances of type remote_raid1"
                " or drbd)"),
   'info': (ShowNodeConfig, ARGS_ANY, [DEBUG_OPT],
-           "Show information about the node(s)"),
+           "[<node_name>...]", "Show information about the node(s)"),
   'list': (ListNodes, ARGS_NONE,
            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
-           "Lists the nodes in the cluster. The available fields"
+           "", "Lists the nodes in the cluster. The available fields"
            " are (see the man page for details): name, pinst_cnt, pinst_list,"
            " sinst_cnt, sinst_list, pip, sip, dtotal, dfree, mtotal, mnode,"
            " mfree, bootid, cpu_count. The default field list is"
            " (in order): %s." % ", ".join(_LIST_DEF_FIELDS),
            ),
   'remove': (RemoveNode, ARGS_ONE, [DEBUG_OPT],
-             "Removes a node from the cluster"),
+             "<node_name>", "Removes a node from the cluster"),
   'volumes': (ListVolumes, ARGS_ANY,
               [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
-              "List logical volumes on node(s)"),
+              "[<node_name>...]", "List logical volumes on node(s)"),
   'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
-                "List the tags of the given node"),
+                "<node_name>", "List the tags of the given node"),
   'add-tags': (AddTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT],
-               "Add tags to the given node"),
+               "<node_name> tag...", "Add tags to the given node"),
   'remove-tags': (RemoveTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT],
-                  "Remove tags from the given node"),
+                  "<node_name> tag...", "Remove tags from the given node"),
   }
 
 
index 873f09f..e4041c7 100755 (executable)
@@ -116,9 +116,9 @@ def DiagnoseOS(opts, args):
 
 
 commands = {
-  'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT],
+  'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT], "",
            "Lists all valid OSes on the master"),
-  'diagnose': (DiagnoseOS, ARGS_NONE, [DEBUG_OPT],
+  'diagnose': (DiagnoseOS, ARGS_NONE, [DEBUG_OPT], "",
                "Diagnose all OSes"),
   }