Revision c38c44ad scripts/gnt-cluster

b/scripts/gnt-cluster
24 24
# W0614: Unused import %s from wildcard import (since we need cli)
25 25

  
26 26
import sys
27
from optparse import make_option
28 27
import os.path
29 28

  
30 29
from ganeti.cli import *
......
536 535

  
537 536
# this is an option common to more than one command, so we declare
538 537
# it here and reuse it
539
node_option = make_option("-n", "--node", action="append", dest="nodes",
540
                          help="Node to copy to (if not given, all nodes),"
541
                               " can be given multiple times",
542
                          metavar="<node>", default=[])
538
node_option = cli_option("-n", "--node", action="append", dest="nodes",
539
                         help="Node to copy to (if not given, all nodes),"
540
                              " can be given multiple times",
541
                         metavar="<node>", default=[])
543 542

  
544 543
commands = {
545 544
  'init': (InitCluster, [ArgUnknown(min=1, max=1)],
546 545
           [DEBUG_OPT,
547
            make_option("-s", "--secondary-ip", dest="secondary_ip",
548
                        help="Specify the secondary ip for this node;"
549
                        " if given, the entire cluster must have secondary"
550
                        " addresses",
551
                        metavar="ADDRESS", default=None),
552
            make_option("-m", "--mac-prefix", dest="mac_prefix",
553
                        help="Specify the mac prefix for the instance IP"
554
                        " addresses, in the format XX:XX:XX",
555
                        metavar="PREFIX",
556
                        default=constants.DEFAULT_MAC_PREFIX,),
557
            make_option("-g", "--vg-name", dest="vg_name",
558
                        help="Specify the volume group name "
559
                        " (cluster-wide) for disk allocation [xenvg]",
560
                        metavar="VG",
561
                        default=None,),
562
            make_option("--master-netdev", dest="master_netdev",
563
                        help="Specify the node interface (cluster-wide)"
564
                          " on which the master IP address will be added "
565
                          " [%s]" % constants.DEFAULT_BRIDGE,
566
                        metavar="NETDEV",
567
                        default=constants.DEFAULT_BRIDGE,),
568
            make_option("--file-storage-dir", dest="file_storage_dir",
569
                        help="Specify the default directory (cluster-wide)"
570
                             " for storing the file-based disks [%s]" %
571
                             constants.DEFAULT_FILE_STORAGE_DIR,
572
                        metavar="DIR",
573
                        default=constants.DEFAULT_FILE_STORAGE_DIR,),
574
            make_option("--no-lvm-storage", dest="lvm_storage",
575
                        help="No support for lvm based instances"
576
                             " (cluster-wide)",
577
                        action="store_false", default=True,),
578
            make_option("--no-etc-hosts", dest="modify_etc_hosts",
579
                        help="Don't modify /etc/hosts"
580
                             " (cluster-wide)",
581
                        action="store_false", default=True,),
582
            make_option("--enabled-hypervisors", dest="enabled_hypervisors",
583
                        help="Comma-separated list of hypervisors",
584
                        type="string",
585
                        default=constants.DEFAULT_ENABLED_HYPERVISOR),
546
            cli_option("-s", "--secondary-ip", dest="secondary_ip",
547
                       help="Specify the secondary ip for this node;"
548
                       " if given, the entire cluster must have secondary"
549
                       " addresses",
550
                       metavar="ADDRESS", default=None),
551
            cli_option("-m", "--mac-prefix", dest="mac_prefix",
552
                       help="Specify the mac prefix for the instance IP"
553
                       " addresses, in the format XX:XX:XX",
554
                       metavar="PREFIX",
555
                       default=constants.DEFAULT_MAC_PREFIX,),
556
            cli_option("-g", "--vg-name", dest="vg_name",
557
                       help="Specify the volume group name "
558
                       " (cluster-wide) for disk allocation [xenvg]",
559
                       metavar="VG",
560
                       default=None,),
561
            cli_option("--master-netdev", dest="master_netdev",
562
                       help="Specify the node interface (cluster-wide)"
563
                         " on which the master IP address will be added "
564
                         " [%s]" % constants.DEFAULT_BRIDGE,
565
                       metavar="NETDEV",
566
                       default=constants.DEFAULT_BRIDGE,),
567
            cli_option("--file-storage-dir", dest="file_storage_dir",
568
                       help="Specify the default directory (cluster-wide)"
569
                            " for storing the file-based disks [%s]" %
570
                            constants.DEFAULT_FILE_STORAGE_DIR,
571
                       metavar="DIR",
572
                       default=constants.DEFAULT_FILE_STORAGE_DIR,),
573
            cli_option("--no-lvm-storage", dest="lvm_storage",
574
                       help="No support for lvm based instances"
575
                            " (cluster-wide)",
576
                       action="store_false", default=True,),
577
            cli_option("--no-etc-hosts", dest="modify_etc_hosts",
578
                       help="Don't modify /etc/hosts"
579
                            " (cluster-wide)",
580
                       action="store_false", default=True,),
581
            cli_option("--enabled-hypervisors", dest="enabled_hypervisors",
582
                       help="Comma-separated list of hypervisors",
583
                       type="string",
584
                       default=constants.DEFAULT_ENABLED_HYPERVISOR),
586 585
            cli_option("-H", "--hypervisor-parameters", dest="hvparams",
587
                       help="Hypervisor and hypervisor options, in the"
588
                         " format"
589
                       " hypervisor:option=value,option=value,...",
586
                       help="Hypervisor and hypervisor options, in the format"
587
                            " hypervisor:option=value,option=value,...",
590 588
                       default=[],
591 589
                       action="append",
592 590
                       type="identkeyval"),
......
596 594
            cli_option("-N", "--nic-parameters", dest="nicparams",
597 595
                       type="keyval", default={},
598 596
                       help="NIC parameters"),
599
            make_option("-C", "--candidate-pool-size",
600
                        default=constants.MASTER_POOL_SIZE_DEFAULT,
601
                        help="Set the candidate pool size",
602
                        dest="candidate_pool_size", type="int"),
597
            cli_option("-C", "--candidate-pool-size",
598
                       default=constants.MASTER_POOL_SIZE_DEFAULT,
599
                       help="Set the candidate pool size",
600
                       dest="candidate_pool_size", type="int"),
603 601
            ],
604 602
           "[opts...] <cluster_name>",
605 603
           "Initialises a new cluster configuration"),
606 604
  'destroy': (DestroyCluster, [],
607 605
              [DEBUG_OPT,
608
               make_option("--yes-do-it", dest="yes_do_it",
609
                           help="Destroy cluster",
610
                           action="store_true"),
606
               cli_option("--yes-do-it", dest="yes_do_it",
607
                          help="Destroy cluster",
608
                          action="store_true"),
611 609
              ],
612 610
              "", "Destroy cluster"),
613 611
  'rename': (RenameCluster, [ArgUnknown(min=1, max=1)],
......
619 617
                  "Forces a push of the configuration file and ssconf files"
620 618
                  " to the nodes in the cluster"),
621 619
  'verify': (VerifyCluster, [], [DEBUG_OPT,
622
             make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
623
                         help="Skip N+1 memory redundancy tests",
624
                         action="store_true",
625
                         default=False,),
620
             cli_option("--no-nplus1-mem", dest="skip_nplusone_mem",
621
                        help="Skip N+1 memory redundancy tests",
622
                        action="store_true",
623
                        default=False,),
626 624
             ],
627 625
             "", "Does a check on the cluster configuration"),
628 626
  'verify-disks': (VerifyDisks, [], [DEBUG_OPT],
......
630 628
  'repair-disk-sizes': (RepairDiskSizes, [ArgInstance()], [DEBUG_OPT],
631 629
                   "", "Updates mismatches in recorded disk sizes"),
632 630
  'masterfailover': (MasterFailover, [], [DEBUG_OPT,
633
                     make_option("--no-voting", dest="no_voting",
634
                                 help="Skip node agreement check (dangerous)",
635
                                 action="store_true",
636
                                 default=False,),
631
                     cli_option("--no-voting", dest="no_voting",
632
                                help="Skip node agreement check (dangerous)",
633
                                action="store_true",
634
                                default=False,),
637 635
                     ],
638 636
                     "", "Makes the current node the master"),
639 637
  'version': (ShowClusterVersion, [], [DEBUG_OPT],
......
664 662
            "drain|undrain|info", "Change queue properties"),
665 663
  'modify': (SetClusterParams, [],
666 664
             [DEBUG_OPT,
667
              make_option("-g", "--vg-name", dest="vg_name",
668
                          help="Specify the volume group name "
669
                          " (cluster-wide) for disk allocation "
670
                          "and enable lvm based storage",
671
                          metavar="VG",),
672
              make_option("--no-lvm-storage", dest="lvm_storage",
673
                          help="Disable support for lvm based instances"
674
                               " (cluster-wide)",
675
                          action="store_false", default=True,),
676
              make_option("--enabled-hypervisors", dest="enabled_hypervisors",
677
                          help="Comma-separated list of hypervisors",
678
                          type="string", default=None),
665
              cli_option("-g", "--vg-name", dest="vg_name",
666
                         help="Specify the volume group name "
667
                         " (cluster-wide) for disk allocation "
668
                         "and enable lvm based storage",
669
                         metavar="VG",),
670
              cli_option("--no-lvm-storage", dest="lvm_storage",
671
                         help="Disable support for lvm based instances"
672
                              " (cluster-wide)",
673
                         action="store_false", default=True,),
674
              cli_option("--enabled-hypervisors", dest="enabled_hypervisors",
675
                         help="Comma-separated list of hypervisors",
676
                         type="string", default=None),
679 677
              cli_option("-H", "--hypervisor-parameters", dest="hvparams",
680 678
                         help="Hypervisor and hypervisor options, in the"
681 679
                         " format"
......
689 687
              cli_option("-N", "--nic-parameters", dest="nicparams",
690 688
                         type="keyval", default={},
691 689
                         help="NIC parameters"),
692
              make_option("-C", "--candidate-pool-size", default=None,
693
                          help="Set the candidate pool size",
694
                          dest="candidate_pool_size", type="int"),
690
              cli_option("-C", "--candidate-pool-size", default=None,
691
                         help="Set the candidate pool size",
692
                         dest="candidate_pool_size", type="int"),
695 693
              ],
696 694
             "[opts...]",
697 695
             "Alters the parameters of the cluster"),

Also available in: Unified diff