Revision 4a265c08

b/lib/cli.py
54 54
           "GetOnlineNodes", "JobExecutor", "SYNC_OPT", "CONFIRM_OPT",
55 55
           "ArgJobId", "ArgSuggest", "ArgUnknown", "ArgFile", "ArgCommand",
56 56
           "ArgInstance", "ArgNode", "ArgChoice",
57
           "ARGS_NONE", "ARGS_ONE_INSTANCE", "ARGS_ONE_NODE",
58
           "ARGS_MANY_INSTANCES", "ARGS_MANY_NODES",
57 59
           ]
58 60

  
59 61
NO_PREFIX = "no_"
......
129 131
  """
130 132

  
131 133

  
134
ARGS_NONE = []
135
ARGS_MANY_INSTANCES = [ArgInstance()]
136
ARGS_MANY_NODES = [ArgNode()]
137
ARGS_ONE_INSTANCE = [ArgInstance(min=1, max=1)]
138
ARGS_ONE_NODE = [ArgNode(min=1, max=1)]
139

  
140

  
132 141
def _ExtractTagsObject(opts, args):
133 142
  """Extract the tag type object.
134 143

  
b/scripts/gnt-backup
261 261
  ]
262 262

  
263 263
commands = {
264
  'list': (PrintExportList, [],
264
  'list': (PrintExportList, ARGS_NONE,
265 265
           [DEBUG_OPT,
266 266
            cli_option("--node", dest="nodes", default=[], action="append",
267 267
                       help="List only backups stored on this node"
268 268
                            " (can be used multiple times)"),
269 269
            ],
270 270
           "", "Lists instance exports available in the ganeti cluster"),
271
  'export': (ExportInstance, [ArgInstance(min=1, max=1)],
271
  'export': (ExportInstance, ARGS_ONE_INSTANCE,
272 272
             [DEBUG_OPT, FORCE_OPT,
273 273
              cli_option("-n", "--node", dest="node", help="Target node",
274 274
                         metavar="<node>"),
......
277 277
                         help="Don't shutdown the instance (unsafe)"), ],
278 278
             "-n <target_node> [opts...] <name>",
279 279
             "Exports an instance to an image"),
280
  'import': (ImportInstance, [ArgInstance(min=1, max=1)], import_opts,
280
  'import': (ImportInstance, ARGS_ONE_INSTANCE, import_opts,
281 281
             ("[...] -t disk-type -n node[:secondary-node]"
282 282
              " <name>"),
283 283
             "Imports an instance from an exported image"),
b/scripts/gnt-cluster
601 601
            ],
602 602
           "[opts...] <cluster_name>",
603 603
           "Initialises a new cluster configuration"),
604
  'destroy': (DestroyCluster, [],
604
  'destroy': (DestroyCluster, ARGS_NONE,
605 605
              [DEBUG_OPT,
606 606
               cli_option("--yes-do-it", dest="yes_do_it",
607 607
                          help="Destroy cluster",
......
612 612
             [DEBUG_OPT, FORCE_OPT],
613 613
             "<new_name>",
614 614
             "Renames the cluster"),
615
  'redist-conf': (RedistributeConfig, [], [DEBUG_OPT, SUBMIT_OPT],
615
  'redist-conf': (RedistributeConfig, ARGS_NONE, [DEBUG_OPT, SUBMIT_OPT],
616 616
                  "",
617 617
                  "Forces a push of the configuration file and ssconf files"
618 618
                  " to the nodes in the cluster"),
619
  'verify': (VerifyCluster, [], [DEBUG_OPT,
619
  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
620 620
             cli_option("--no-nplus1-mem", dest="skip_nplusone_mem",
621 621
                        help="Skip N+1 memory redundancy tests",
622 622
                        action="store_true",
623 623
                        default=False,),
624 624
             ],
625 625
             "", "Does a check on the cluster configuration"),
626
  'verify-disks': (VerifyDisks, [], [DEBUG_OPT],
626
  'verify-disks': (VerifyDisks, ARGS_NONE, [DEBUG_OPT],
627 627
                   "", "Does a check on the cluster disk status"),
628
  'repair-disk-sizes': (RepairDiskSizes, [ArgInstance()], [DEBUG_OPT],
628
  'repair-disk-sizes': (RepairDiskSizes, ARGS_MANY_INSTANCES, [DEBUG_OPT],
629 629
                   "", "Updates mismatches in recorded disk sizes"),
630
  'masterfailover': (MasterFailover, [], [DEBUG_OPT,
630
  'masterfailover': (MasterFailover, ARGS_NONE, [DEBUG_OPT,
631 631
                     cli_option("--no-voting", dest="no_voting",
632 632
                                help="Skip node agreement check (dangerous)",
633 633
                                action="store_true",
634 634
                                default=False,),
635 635
                     ],
636 636
                     "", "Makes the current node the master"),
637
  'version': (ShowClusterVersion, [], [DEBUG_OPT],
637
  'version': (ShowClusterVersion, ARGS_NONE, [DEBUG_OPT],
638 638
              "", "Shows the cluster version"),
639
  'getmaster': (ShowClusterMaster, [], [DEBUG_OPT],
639
  'getmaster': (ShowClusterMaster, ARGS_NONE, [DEBUG_OPT],
640 640
                "", "Shows the cluster master"),
641 641
  'copyfile': (ClusterCopyFile, [ArgFile(min=1, max=1)],
642 642
               [DEBUG_OPT, node_option],
......
645 645
  'command': (RunClusterCommand, [ArgCommand(min=1)], [DEBUG_OPT, node_option],
646 646
              "[-n node...] <command>",
647 647
              "Runs a command on all (or only some) nodes"),
648
  'info': (ShowClusterConfig, [], [DEBUG_OPT],
648
  'info': (ShowClusterConfig, ARGS_NONE, [DEBUG_OPT],
649 649
           "", "Show cluster configuration"),
650
  'list-tags': (ListTags, [],
650
  'list-tags': (ListTags, ARGS_NONE,
651 651
                [DEBUG_OPT], "", "List the tags of the cluster"),
652 652
  'add-tags': (AddTags, [ArgUnknown()], [DEBUG_OPT, TAG_SRC_OPT],
653 653
               "tag...", "Add tags to the cluster"),
......
660 660
            [ArgChoice(min=1, max=1, choices=["drain", "undrain", "info"])],
661 661
            [DEBUG_OPT],
662 662
            "drain|undrain|info", "Change queue properties"),
663
  'modify': (SetClusterParams, [],
663
  'modify': (SetClusterParams, ARGS_NONE,
664 664
             [DEBUG_OPT,
665 665
              cli_option("-g", "--vg-name", dest="vg_name",
666 666
                         help="Specify the volume group name "
b/scripts/gnt-debug
142 142
  'submit-job': (GenericOpCodes, [ArgFile(min=1)], [DEBUG_OPT],
143 143
                 "<op_list_file...>", "Submits jobs built from json files"
144 144
                 " containing a list of serialized opcodes"),
145
  'allocator': (TestAllocator, [ArgInstance(min=1, max=1)],
145
  'allocator': (TestAllocator, ARGS_ONE_INSTANCE,
146 146
                [DEBUG_OPT,
147 147
                 cli_option("--dir", dest="direction",
148 148
                            default="in", choices=["in", "out"],
b/scripts/gnt-instance
1425 1425
                   [DEBUG_OPT],
1426 1426
                   "<instances_file.json>",
1427 1427
                   "Create a bunch of instances based on specs in the file."),
1428
  'console': (ConnectToInstanceConsole, [ArgInstance(min=1, max=1)],
1428
  'console': (ConnectToInstanceConsole, ARGS_ONE_INSTANCE,
1429 1429
              [DEBUG_OPT,
1430 1430
               cli_option("--show-cmd", dest="show_command",
1431 1431
                          action="store_true", default=False,
1432 1432
                          help=("Show command instead of executing it"))],
1433 1433
              "[--show-cmd] <instance>",
1434 1434
              "Opens a console on the specified instance"),
1435
  'failover': (FailoverInstance, [ArgInstance(min=1, max=1)],
1435
  'failover': (FailoverInstance, ARGS_ONE_INSTANCE,
1436 1436
               [DEBUG_OPT, FORCE_OPT,
1437 1437
                cli_option("--ignore-consistency", dest="ignore_consistency",
1438 1438
                           action="store_true", default=False,
......
1443 1443
               "[-f] <instance>",
1444 1444
               "Stops the instance and starts it on the backup node, using"
1445 1445
               " the remote mirror (only for instances of type drbd)"),
1446
  'migrate': (MigrateInstance, [ArgInstance(min=1, max=1)],
1446
  'migrate': (MigrateInstance, ARGS_ONE_INSTANCE,
1447 1447
               [DEBUG_OPT, FORCE_OPT,
1448 1448
                cli_option("--non-live", dest="live",
1449 1449
                           default=True, action="store_false",
......
1463 1463
               "[-f] <instance>",
1464 1464
               "Migrate instance to its secondary node"
1465 1465
               " (only for instances of type drbd)"),
1466
  'move': (MoveInstance, [ArgInstance(min=1, max=1)],
1466
  'move': (MoveInstance, ARGS_ONE_INSTANCE,
1467 1467
           [DEBUG_OPT, FORCE_OPT, SUBMIT_OPT,
1468 1468
            cli_option("-n", "--new-node", dest="target_node",
1469 1469
                       help="Destinattion node", metavar="NODE",
......
1472 1472
           "[-f] <instance>",
1473 1473
           "Move instance to an arbitrary node"
1474 1474
           " (only for instances of type file and lv)"),
1475
  'info': (ShowInstanceConfig, [ArgInstance()],
1475
  'info': (ShowInstanceConfig, ARGS_MANY_INSTANCES,
1476 1476
           [DEBUG_OPT,
1477 1477
            cli_option("-s", "--static", dest="static",
1478 1478
                       action="store_true", default=False,
......
1483 1483
                       " This can take a long time to run, use wisely."),
1484 1484
            ], "[-s] {--all | <instance>...}",
1485 1485
           "Show information on the specified instance(s)"),
1486
  'list': (ListInstances, [ArgInstance()],
1486
  'list': (ListInstances, ARGS_MANY_INSTANCES,
1487 1487
           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SYNC_OPT],
1488 1488
           "[<instance>...]",
1489 1489
           "Lists the instances and their status. The available fields are"
......
1506 1506
                 SUBMIT_OPT,
1507 1507
                 ],
1508 1508
                "[-f] <instance>", "Reinstall a stopped instance"),
1509
  'remove': (RemoveInstance, [ArgInstance(min=1, max=1)],
1509
  'remove': (RemoveInstance, ARGS_ONE_INSTANCE,
1510 1510
             [DEBUG_OPT, FORCE_OPT,
1511 1511
              cli_option("--ignore-failures", dest="ignore_failures",
1512 1512
                         action="store_true", default=False,
......
1526 1526
              SUBMIT_OPT,
1527 1527
              ],
1528 1528
             "<instance> <new_name>", "Rename the instance"),
1529
  'replace-disks': (ReplaceDisks, [ArgInstance(min=1, max=1)],
1529
  'replace-disks': (ReplaceDisks, ARGS_ONE_INSTANCE,
1530 1530
                    [DEBUG_OPT,
1531 1531
                     cli_option("-n", "--new-secondary", dest="new_secondary",
1532 1532
                                help=("New secondary node (for secondary"
......
1558 1558
                     ],
1559 1559
                    "[-s|-p|-n NODE|-I NAME] <instance>",
1560 1560
                    "Replaces all disks for the instance"),
1561
  'modify': (SetInstanceParams, [ArgInstance(min=1, max=1)],
1561
  'modify': (SetInstanceParams, ARGS_ONE_INSTANCE,
1562 1562
             [DEBUG_OPT, FORCE_OPT,
1563 1563
              cli_option("-H", "--hypervisor", type="keyval",
1564 1564
                         default={}, dest="hypervisor",
......
1610 1610
               SUBMIT_OPT,
1611 1611
               ],
1612 1612
            "<instance>", "Reboots an instance"),
1613
  'activate-disks': (ActivateDisks, [ArgInstance(min=1, max=1)],
1613
  'activate-disks': (ActivateDisks, ARGS_ONE_INSTANCE,
1614 1614
                     [DEBUG_OPT, SUBMIT_OPT,
1615 1615
                      cli_option("--ignore-size", dest="ignore_size",
1616 1616
                                 default=False, action="store_true",
......
1620 1620
                      ],
1621 1621
                     "<instance>",
1622 1622
                     "Activate an instance's disks"),
1623
  'deactivate-disks': (DeactivateDisks, [ArgInstance(min=1, max=1)],
1623
  'deactivate-disks': (DeactivateDisks, ARGS_ONE_INSTANCE,
1624 1624
                       [DEBUG_OPT, SUBMIT_OPT],
1625 1625
                       "<instance>",
1626 1626
                       "Deactivate an instance's disks"),
1627
  'recreate-disks': (RecreateDisks, [ArgInstance(min=1, max=1)],
1627
  'recreate-disks': (RecreateDisks, ARGS_ONE_INSTANCE,
1628 1628
                     [DEBUG_OPT, SUBMIT_OPT,
1629 1629
                     cli_option("--disks", dest="disks", default=None,
1630 1630
                                help="Comma-separated list of disks"
......
1643 1643
                            help="Don't wait for sync (DANGEROUS!)"),
1644 1644
                 ],
1645 1645
                "<instance> <disk> <size>", "Grow an instance's disk"),
1646
  'list-tags': (ListTags, [ArgInstance(min=1, max=1)], [DEBUG_OPT],
1646
  'list-tags': (ListTags, ARGS_ONE_INSTANCE, [DEBUG_OPT],
1647 1647
                "<instance_name>", "List the tags of the given instance"),
1648 1648
  'add-tags': (AddTags, [ArgInstance(min=1, max=1), ArgUnknown()],
1649 1649
               [DEBUG_OPT, TAG_SRC_OPT],
b/scripts/gnt-node
636 636
           ],
637 637
          "[-s ip] [--readd] [--no-ssh-key-check] <node_name>",
638 638
          "Add a node to the cluster"),
639
  'evacuate': (EvacuateNode, [ArgNode(min=1, max=1)],
639
  'evacuate': (EvacuateNode, ARGS_ONE_NODE,
640 640
               [DEBUG_OPT, FORCE_OPT,
641 641
                cli_option("-n", "--new-secondary", dest="dst_node",
642 642
                           help="New secondary node", metavar="NODE",
......
650 650
               "[-f] {-I <iallocator> | -n <dst>} <node>",
651 651
               "Relocate the secondary instances from a node"
652 652
               " to other nodes (only for instances with drbd disk template)"),
653
  'failover': (FailoverNode, [ArgNode(min=1, max=1)],
653
  'failover': (FailoverNode, ARGS_ONE_NODE,
654 654
               [DEBUG_OPT, FORCE_OPT,
655 655
                cli_option("--ignore-consistency", dest="ignore_consistency",
656 656
                           action="store_true", default=False,
......
660 660
               "[-f] <node>",
661 661
               "Stops the primary instances on a node and start them on their"
662 662
               " secondary node (only for instances with drbd disk template)"),
663
  'migrate': (MigrateNode, [ArgNode(min=1, max=1)],
663
  'migrate': (MigrateNode, ARGS_ONE_NODE,
664 664
               [DEBUG_OPT, FORCE_OPT,
665 665
                cli_option("--non-live", dest="live",
666 666
                           default=True, action="store_false",
......
672 672
               "[-f] <node>",
673 673
               "Migrate all the primary instance on a node away from it"
674 674
               " (only for instances of type drbd)"),
675
  'info': (ShowNodeConfig, [ArgNode()], [DEBUG_OPT],
675
  'info': (ShowNodeConfig, ARGS_MANY_NODES, [DEBUG_OPT],
676 676
           "[<node_name>...]", "Show information about the node(s)"),
677
  'list': (ListNodes, [ArgNode()],
677
  'list': (ListNodes, ARGS_MANY_NODES,
678 678
           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SYNC_OPT],
679 679
           "[nodes...]",
680 680
           "Lists the nodes in the cluster. The available fields"
681 681
           " are (see the man page for details): %s"
682 682
           " The default field list is (in order): %s." %
683 683
           (", ".join(_LIST_HEADERS), ", ".join(_LIST_DEF_FIELDS))),
684
  'modify': (SetNodeParams, [ArgNode(min=1, max=1)],
684
  'modify': (SetNodeParams, ARGS_ONE_NODE,
685 685
             [DEBUG_OPT, FORCE_OPT,
686 686
              SUBMIT_OPT,
687 687
              cli_option("-C", "--master-candidate", dest="master_candidate",
......
696 696
                         help="Set the drained flag on the node"),
697 697
              ],
698 698
             "<node>", "Alters the parameters of a node"),
699
  'powercycle': (PowercycleNode, [ArgNode(min=1, max=1)],
699
  'powercycle': (PowercycleNode, ARGS_ONE_NODE,
700 700
                 [DEBUG_OPT, FORCE_OPT, CONFIRM_OPT],
701 701
                 "<node_name>", "Tries to forcefully powercycle a node"),
702
  'remove': (RemoveNode, [ArgNode(min=1, max=1)], [DEBUG_OPT],
702
  'remove': (RemoveNode, ARGS_ONE_NODE, [DEBUG_OPT],
703 703
             "<node_name>", "Removes a node from the cluster"),
704 704
  'volumes': (ListVolumes, [ArgNode()],
705 705
              [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
706 706
              "[<node_name>...]", "List logical volumes on node(s)"),
707
  'physical-volumes': (ListPhysicalVolumes, [ArgNode()],
707
  'physical-volumes': (ListPhysicalVolumes, ARGS_MANY_NODES,
708 708
                       [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT,
709 709
                        FIELDS_OPT, _STORAGE_TYPE_OPT],
710 710
                       "[<node_name>...]",
......
730 730
                    [DEBUG_OPT],
731 731
                    "<node_name> <storage_type> <name>",
732 732
                    "Repairs a storage volume on a node"),
733
  'list-tags': (ListTags, [ArgNode(min=1, max=1)], [DEBUG_OPT],
733
  'list-tags': (ListTags, ARGS_ONE_NODE, [DEBUG_OPT],
734 734
                "<node_name>", "List the tags of the given node"),
735 735
  'add-tags': (AddTags, [ArgNode(min=1, max=1), ArgUnknown()],
736 736
               [DEBUG_OPT, TAG_SRC_OPT],
b/scripts/gnt-os
145 145

  
146 146

  
147 147
commands = {
148
  'list': (ListOS, [], [DEBUG_OPT, NOHDR_OPT], "",
148
  'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT], "",
149 149
           "Lists all valid OSes on the master"),
150
  'diagnose': (DiagnoseOS, [], [DEBUG_OPT], "",
150
  'diagnose': (DiagnoseOS, ARGS_NONE, [DEBUG_OPT], "",
151 151
               "Diagnose all OSes"),
152 152
  }
153 153

  

Also available in: Unified diff