Unify the “--no-nics” option
[ganeti-local] / scripts / gnt-node
index a23e822..ed667ba 100755 (executable)
@@ -223,7 +223,7 @@ def EvacuateNode(opts, args):
 
   cnt = [dst_node, iallocator].count(None)
   if cnt != 1:
-    raise errors.OpPrereqError("One and only one of the -n and -i"
+    raise errors.OpPrereqError("One and only one of the -n and -I"
                                " options must be passed")
 
   selected_fields = ["name", "sinst_list"]
@@ -622,7 +622,7 @@ def SetNodeParams(opts, args):
 
 
 commands = {
-  'add': (AddNode, [ArgUnknown(min=1, max=1)],
+  'add': (AddNode, [ArgHost(min=1, max=1)],
           [DEBUG_OPT,
            cli_option("-s", "--secondary-ip", dest="secondary_ip",
                       help="Specify the secondary ip for the node",
@@ -636,21 +636,23 @@ commands = {
            ],
           "[-s ip] [--readd] [--no-ssh-key-check] <node_name>",
           "Add a node to the cluster"),
-  'evacuate': (EvacuateNode, [ArgNode(min=1, max=1)],
+  'evacuate': (EvacuateNode, ARGS_ONE_NODE,
                [DEBUG_OPT, FORCE_OPT,
                 cli_option("-n", "--new-secondary", dest="dst_node",
                            help="New secondary node", metavar="NODE",
-                           default=None),
+                           default=None,
+                           completion_suggest=OPT_COMPL_ONE_NODE),
                 cli_option("-I", "--iallocator", metavar="<NAME>",
                            help="Select new secondary for the instance"
                            " automatically using the"
                            " <NAME> iallocator plugin",
-                           default=None, type="string"),
+                           default=None, type="string",
+                           completion_suggest=OPT_COMPL_ONE_IALLOCATOR),
                 ],
                "[-f] {-I <iallocator> | -n <dst>} <node>",
                "Relocate the secondary instances from a node"
                " to other nodes (only for instances with drbd disk template)"),
-  'failover': (FailoverNode, [ArgNode(min=1, max=1)],
+  'failover': (FailoverNode, ARGS_ONE_NODE,
                [DEBUG_OPT, FORCE_OPT,
                 cli_option("--ignore-consistency", dest="ignore_consistency",
                            action="store_true", default=False,
@@ -660,7 +662,7 @@ commands = {
                "[-f] <node>",
                "Stops the primary instances on a node and start them on their"
                " secondary node (only for instances with drbd disk template)"),
-  'migrate': (MigrateNode, [ArgNode(min=1, max=1)],
+  'migrate': (MigrateNode, ARGS_ONE_NODE,
                [DEBUG_OPT, FORCE_OPT,
                 cli_option("--non-live", dest="live",
                            default=True, action="store_false",
@@ -672,16 +674,16 @@ commands = {
                "[-f] <node>",
                "Migrate all the primary instance on a node away from it"
                " (only for instances of type drbd)"),
-  'info': (ShowNodeConfig, [ArgNode()], [DEBUG_OPT],
+  'info': (ShowNodeConfig, ARGS_MANY_NODES, [DEBUG_OPT],
            "[<node_name>...]", "Show information about the node(s)"),
-  'list': (ListNodes, [ArgNode()],
+  'list': (ListNodes, ARGS_MANY_NODES,
            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SYNC_OPT],
            "[nodes...]",
            "Lists the nodes in the cluster. The available fields"
            " are (see the man page for details): %s"
            " The default field list is (in order): %s." %
            (", ".join(_LIST_HEADERS), ", ".join(_LIST_DEF_FIELDS))),
-  'modify': (SetNodeParams, [ArgNode(min=1, max=1)],
+  'modify': (SetNodeParams, ARGS_ONE_NODE,
              [DEBUG_OPT, FORCE_OPT,
               SUBMIT_OPT,
               cli_option("-C", "--master-candidate", dest="master_candidate",
@@ -695,16 +697,16 @@ commands = {
                          choices=('yes', 'no'), default=None,
                          help="Set the drained flag on the node"),
               ],
-             "<node>", "Alters the parameters of a node"),
-  'powercycle': (PowercycleNode, [ArgNode(min=1, max=1)],
+             "<node_name>", "Alters the parameters of a node"),
+  'powercycle': (PowercycleNode, ARGS_ONE_NODE,
                  [DEBUG_OPT, FORCE_OPT, CONFIRM_OPT],
                  "<node_name>", "Tries to forcefully powercycle a node"),
-  'remove': (RemoveNode, [ArgNode(min=1, max=1)], [DEBUG_OPT],
+  'remove': (RemoveNode, ARGS_ONE_NODE, [DEBUG_OPT],
              "<node_name>", "Removes a node from the cluster"),
   'volumes': (ListVolumes, [ArgNode()],
               [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
               "[<node_name>...]", "List logical volumes on node(s)"),
-  'physical-volumes': (ListPhysicalVolumes, [ArgNode()],
+  'physical-volumes': (ListPhysicalVolumes, ARGS_MANY_NODES,
                        [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT,
                         FIELDS_OPT, _STORAGE_TYPE_OPT],
                        "[<node_name>...]",
@@ -730,7 +732,7 @@ commands = {
                     [DEBUG_OPT],
                     "<node_name> <storage_type> <name>",
                     "Repairs a storage volume on a node"),
-  'list-tags': (ListTags, [ArgNode(min=1, max=1)], [DEBUG_OPT],
+  'list-tags': (ListTags, ARGS_ONE_NODE, [DEBUG_OPT],
                 "<node_name>", "List the tags of the given node"),
   'add-tags': (AddTags, [ArgNode(min=1, max=1), ArgUnknown()],
                [DEBUG_OPT, TAG_SRC_OPT],