4 # Copyright (C) 2006, 2007, 2010 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 """Cluster related commands"""
23 # pylint: disable-msg=W0401,W0613,W0614,C0103
24 # W0401: Wildcard import ganeti.cli
25 # W0613: Unused argument, since all functions follow the same API
26 # W0614: Unused import %s from wildcard import (since we need cli)
27 # C0103: Invalid name gnt-cluster
34 from ganeti.cli import *
35 from ganeti import opcodes
36 from ganeti import constants
37 from ganeti import errors
38 from ganeti import utils
39 from ganeti import bootstrap
40 from ganeti import ssh
41 from ganeti import objects
42 from ganeti import uidpool
43 from ganeti import compat
47 def InitCluster(opts, args):
48 """Initialize the cluster.
50 @param opts: the command line options selected by the user
52 @param args: should contain only one element, the desired
55 @return: the desired exit code
58 if not opts.lvm_storage and opts.vg_name:
59 ToStderr("Options --no-lvm-storage and --vg-name conflict.")
62 vg_name = opts.vg_name
63 if opts.lvm_storage and not opts.vg_name:
64 vg_name = constants.DEFAULT_VG
66 if not opts.drbd_storage and opts.drbd_helper:
67 ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.")
70 drbd_helper = opts.drbd_helper
71 if opts.drbd_storage and not opts.drbd_helper:
72 drbd_helper = constants.DEFAULT_DRBD_HELPER
74 hvlist = opts.enabled_hypervisors
76 hvlist = constants.DEFAULT_ENABLED_HYPERVISOR
77 hvlist = hvlist.split(",")
79 hvparams = dict(opts.hvparams)
80 beparams = opts.beparams
81 nicparams = opts.nicparams
83 # prepare beparams dict
84 beparams = objects.FillDict(constants.BEC_DEFAULTS, beparams)
85 utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
87 # prepare nicparams dict
88 nicparams = objects.FillDict(constants.NICC_DEFAULTS, nicparams)
89 utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
91 # prepare hvparams dict
92 for hv in constants.HYPER_TYPES:
93 if hv not in hvparams:
95 hvparams[hv] = objects.FillDict(constants.HVC_DEFAULTS[hv], hvparams[hv])
96 utils.ForceDictType(hvparams[hv], constants.HVS_PARAMETER_TYPES)
98 if opts.candidate_pool_size is None:
99 opts.candidate_pool_size = constants.MASTER_POOL_SIZE_DEFAULT
101 if opts.mac_prefix is None:
102 opts.mac_prefix = constants.DEFAULT_MAC_PREFIX
104 uid_pool = opts.uid_pool
105 if uid_pool is not None:
106 uid_pool = uidpool.ParseUidPool(uid_pool)
108 bootstrap.InitCluster(cluster_name=args[0],
109 secondary_ip=opts.secondary_ip,
111 mac_prefix=opts.mac_prefix,
112 master_netdev=opts.master_netdev,
113 file_storage_dir=opts.file_storage_dir,
114 enabled_hypervisors=hvlist,
118 candidate_pool_size=opts.candidate_pool_size,
119 modify_etc_hosts=opts.modify_etc_hosts,
120 modify_ssh_setup=opts.modify_ssh_setup,
121 maintain_node_health=opts.maintain_node_health,
122 drbd_helper=drbd_helper,
124 default_iallocator=opts.default_iallocator,
126 op = opcodes.OpPostInitCluster()
127 SubmitOpCode(op, opts=opts)
132 def DestroyCluster(opts, args):
133 """Destroy the cluster.
135 @param opts: the command line options selected by the user
137 @param args: should be an empty list
139 @return: the desired exit code
142 if not opts.yes_do_it:
143 ToStderr("Destroying a cluster is irreversible. If you really want"
144 " destroy this cluster, supply the --yes-do-it option.")
147 op = opcodes.OpDestroyCluster()
148 master = SubmitOpCode(op, opts=opts)
149 # if we reached this, the opcode didn't fail; we can proceed to
150 # shutdown all the daemons
151 bootstrap.FinalizeClusterDestroy(master)
155 def RenameCluster(opts, args):
156 """Rename the cluster.
158 @param opts: the command line options selected by the user
160 @param args: should contain only one element, the new cluster name
162 @return: the desired exit code
167 (cluster_name, ) = cl.QueryConfigValues(["cluster_name"])
171 usertext = ("This will rename the cluster from '%s' to '%s'. If you are"
172 " connected over the network to the cluster name, the"
173 " operation is very dangerous as the IP address will be"
174 " removed from the node and the change may not go through."
175 " Continue?") % (cluster_name, new_name)
176 if not AskUser(usertext):
179 op = opcodes.OpRenameCluster(name=new_name)
180 result = SubmitOpCode(op, opts=opts, cl=cl)
183 ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result)
188 def RedistributeConfig(opts, args):
189 """Forces push of the cluster configuration.
191 @param opts: the command line options selected by the user
193 @param args: empty list
195 @return: the desired exit code
198 op = opcodes.OpRedistributeConfig()
199 SubmitOrSend(op, opts)
203 def ShowClusterVersion(opts, args):
204 """Write version of ganeti software to the standard output.
206 @param opts: the command line options selected by the user
208 @param args: should be an empty list
210 @return: the desired exit code
214 result = cl.QueryClusterInfo()
215 ToStdout("Software version: %s", result["software_version"])
216 ToStdout("Internode protocol: %s", result["protocol_version"])
217 ToStdout("Configuration format: %s", result["config_version"])
218 ToStdout("OS api version: %s", result["os_api_version"])
219 ToStdout("Export interface: %s", result["export_version"])
223 def ShowClusterMaster(opts, args):
224 """Write name of master node to the standard output.
226 @param opts: the command line options selected by the user
228 @param args: should be an empty list
230 @return: the desired exit code
233 master = bootstrap.GetMaster()
238 def _PrintGroupedParams(paramsdict, level=1, roman=False):
239 """Print Grouped parameters (be, nic, disk) by group.
241 @type paramsdict: dict of dicts
242 @param paramsdict: {group: {param: value, ...}, ...}
244 @param level: Level of indention
248 for item, val in sorted(paramsdict.items()):
249 if isinstance(val, dict):
250 ToStdout("%s- %s:", indent, item)
251 _PrintGroupedParams(val, level=level + 1, roman=roman)
252 elif roman and isinstance(val, int):
253 ToStdout("%s %s: %s", indent, item, compat.TryToRoman(val))
255 ToStdout("%s %s: %s", indent, item, val)
258 def ShowClusterConfig(opts, args):
259 """Shows cluster information.
261 @param opts: the command line options selected by the user
263 @param args: should be an empty list
265 @return: the desired exit code
269 result = cl.QueryClusterInfo()
271 ToStdout("Cluster name: %s", result["name"])
272 ToStdout("Cluster UUID: %s", result["uuid"])
274 ToStdout("Creation time: %s", utils.FormatTime(result["ctime"]))
275 ToStdout("Modification time: %s", utils.FormatTime(result["mtime"]))
277 ToStdout("Master node: %s", result["master"])
279 ToStdout("Architecture (this node): %s (%s)",
280 result["architecture"][0], result["architecture"][1])
283 tags = utils.CommaJoin(utils.NiceSort(result["tags"]))
287 ToStdout("Tags: %s", tags)
289 ToStdout("Default hypervisor: %s", result["default_hypervisor"])
290 ToStdout("Enabled hypervisors: %s",
291 utils.CommaJoin(result["enabled_hypervisors"]))
293 ToStdout("Hypervisor parameters:")
294 _PrintGroupedParams(result["hvparams"])
296 ToStdout("OS-specific hypervisor parameters:")
297 _PrintGroupedParams(result["os_hvp"])
299 ToStdout("OS parameters:")
300 _PrintGroupedParams(result["osparams"])
302 ToStdout("Cluster parameters:")
303 ToStdout(" - candidate pool size: %s",
304 compat.TryToRoman(result["candidate_pool_size"],
305 convert=opts.roman_integers))
306 ToStdout(" - master netdev: %s", result["master_netdev"])
307 ToStdout(" - lvm volume group: %s", result["volume_group_name"])
308 if result["reserved_lvs"]:
309 reserved_lvs = utils.CommaJoin(result["reserved_lvs"])
311 reserved_lvs = "(none)"
312 ToStdout(" - lvm reserved volumes: %s", reserved_lvs)
313 ToStdout(" - drbd usermode helper: %s", result["drbd_usermode_helper"])
314 ToStdout(" - file storage path: %s", result["file_storage_dir"])
315 ToStdout(" - maintenance of node health: %s",
316 result["maintain_node_health"])
317 ToStdout(" - uid pool: %s",
318 uidpool.FormatUidPool(result["uid_pool"],
319 roman=opts.roman_integers))
320 ToStdout(" - default instance allocator: %s", result["default_iallocator"])
322 ToStdout("Default instance parameters:")
323 _PrintGroupedParams(result["beparams"], roman=opts.roman_integers)
325 ToStdout("Default nic parameters:")
326 _PrintGroupedParams(result["nicparams"], roman=opts.roman_integers)
331 def ClusterCopyFile(opts, args):
332 """Copy a file from master to some nodes.
334 @param opts: the command line options selected by the user
336 @param args: should contain only one element, the path of
337 the file to be copied
339 @return: the desired exit code
343 if not os.path.exists(filename):
344 raise errors.OpPrereqError("No such filename '%s'" % filename,
349 cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
351 results = GetOnlineNodes(nodes=opts.nodes, cl=cl, filter_master=True,
352 secondary_ips=opts.use_replication_network)
354 srun = ssh.SshRunner(cluster_name=cluster_name)
356 if not srun.CopyFileToNode(node, filename):
357 ToStderr("Copy of file %s to node %s failed", filename, node)
362 def RunClusterCommand(opts, args):
363 """Run a command on some nodes.
365 @param opts: the command line options selected by the user
367 @param args: should contain the command to be run and its arguments
369 @return: the desired exit code
374 command = " ".join(args)
376 nodes = GetOnlineNodes(nodes=opts.nodes, cl=cl)
378 cluster_name, master_node = cl.QueryConfigValues(["cluster_name",
381 srun = ssh.SshRunner(cluster_name=cluster_name)
383 # Make sure master node is at list end
384 if master_node in nodes:
385 nodes.remove(master_node)
386 nodes.append(master_node)
389 result = srun.Run(name, "root", command)
390 ToStdout("------------------------------------------------")
391 ToStdout("node: %s", name)
392 ToStdout("%s", result.output)
393 ToStdout("return code = %s", result.exit_code)
398 def VerifyCluster(opts, args):
399 """Verify integrity of cluster, performing various test on nodes.
401 @param opts: the command line options selected by the user
403 @param args: should be an empty list
405 @return: the desired exit code
409 if opts.skip_nplusone_mem:
410 skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
411 op = opcodes.OpVerifyCluster(skip_checks=skip_checks,
412 verbose=opts.verbose,
413 error_codes=opts.error_codes,
414 debug_simulate_errors=opts.simulate_errors)
415 if SubmitOpCode(op, opts=opts):
421 def VerifyDisks(opts, args):
422 """Verify integrity of cluster disks.
424 @param opts: the command line options selected by the user
426 @param args: should be an empty list
428 @return: the desired exit code
431 op = opcodes.OpVerifyDisks()
432 result = SubmitOpCode(op, opts=opts)
433 if not isinstance(result, (list, tuple)) or len(result) != 3:
434 raise errors.ProgrammerError("Unknown result type for OpVerifyDisks")
436 bad_nodes, instances, missing = result
438 retcode = constants.EXIT_SUCCESS
441 for node, text in bad_nodes.items():
442 ToStdout("Error gathering data on node %s: %s",
443 node, utils.SafeEncode(text[-400:]))
445 ToStdout("You need to fix these nodes first before fixing instances")
448 for iname in instances:
451 op = opcodes.OpActivateInstanceDisks(instance_name=iname)
453 ToStdout("Activating disks for instance '%s'", iname)
454 SubmitOpCode(op, opts=opts)
455 except errors.GenericError, err:
456 nret, msg = FormatError(err)
458 ToStderr("Error activating disks for instance %s: %s", iname, msg)
461 for iname, ival in missing.iteritems():
462 all_missing = compat.all(x[0] in bad_nodes for x in ival)
464 ToStdout("Instance %s cannot be verified as it lives on"
465 " broken nodes", iname)
467 ToStdout("Instance %s has missing logical volumes:", iname)
469 for node, vol in ival:
470 if node in bad_nodes:
471 ToStdout("\tbroken node %s /dev/xenvg/%s", node, vol)
473 ToStdout("\t%s /dev/xenvg/%s", node, vol)
474 ToStdout("You need to run replace_disks for all the above"
475 " instances, if this message persist after fixing nodes.")
481 def RepairDiskSizes(opts, args):
482 """Verify sizes of cluster disks.
484 @param opts: the command line options selected by the user
486 @param args: optional list of instances to restrict check to
488 @return: the desired exit code
491 op = opcodes.OpRepairDiskSizes(instances=args)
492 SubmitOpCode(op, opts=opts)
496 def MasterFailover(opts, args):
497 """Failover the master node.
499 This command, when run on a non-master node, will cause the current
500 master to cease being master, and the non-master to become new
503 @param opts: the command line options selected by the user
505 @param args: should be an empty list
507 @return: the desired exit code
511 usertext = ("This will perform the failover even if most other nodes"
512 " are down, or if this node is outdated. This is dangerous"
513 " as it can lead to a non-consistent cluster. Check the"
514 " gnt-cluster(8) man page before proceeding. Continue?")
515 if not AskUser(usertext):
518 return bootstrap.MasterFailover(no_voting=opts.no_voting)
521 def MasterPing(opts, args):
522 """Checks if the master is alive.
524 @param opts: the command line options selected by the user
526 @param args: should be an empty list
528 @return: the desired exit code
533 cl.QueryClusterInfo()
535 except Exception: # pylint: disable-msg=W0703
539 def SearchTags(opts, args):
540 """Searches the tags on all the cluster.
542 @param opts: the command line options selected by the user
544 @param args: should contain only one element, the tag pattern
546 @return: the desired exit code
549 op = opcodes.OpSearchTags(pattern=args[0])
550 result = SubmitOpCode(op, opts=opts)
553 result = list(result)
555 for path, tag in result:
556 ToStdout("%s %s", path, tag)
559 def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename,
560 new_confd_hmac_key, new_cds, cds_filename,
562 """Renews cluster certificates, keys and secrets.
564 @type new_cluster_cert: bool
565 @param new_cluster_cert: Whether to generate a new cluster certificate
566 @type new_rapi_cert: bool
567 @param new_rapi_cert: Whether to generate a new RAPI certificate
568 @type rapi_cert_filename: string
569 @param rapi_cert_filename: Path to file containing new RAPI certificate
570 @type new_confd_hmac_key: bool
571 @param new_confd_hmac_key: Whether to generate a new HMAC key
573 @param new_cds: Whether to generate a new cluster domain secret
574 @type cds_filename: string
575 @param cds_filename: Path to file containing new cluster domain secret
577 @param force: Whether to ask user for confirmation
580 if new_rapi_cert and rapi_cert_filename:
581 ToStderr("Only one of the --new-rapi-certficate and --rapi-certificate"
582 " options can be specified at the same time.")
585 if new_cds and cds_filename:
586 ToStderr("Only one of the --new-cluster-domain-secret and"
587 " --cluster-domain-secret options can be specified at"
591 if rapi_cert_filename:
592 # Read and verify new certificate
594 rapi_cert_pem = utils.ReadFile(rapi_cert_filename)
596 OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
598 except Exception, err: # pylint: disable-msg=W0703
599 ToStderr("Can't load new RAPI certificate from %s: %s" %
600 (rapi_cert_filename, str(err)))
604 OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, rapi_cert_pem)
605 except Exception, err: # pylint: disable-msg=W0703
606 ToStderr("Can't load new RAPI private key from %s: %s" %
607 (rapi_cert_filename, str(err)))
615 cds = utils.ReadFile(cds_filename)
616 except Exception, err: # pylint: disable-msg=W0703
617 ToStderr("Can't load new cluster domain secret from %s: %s" %
618 (cds_filename, str(err)))
624 usertext = ("This requires all daemons on all nodes to be restarted and"
625 " may take some time. Continue?")
626 if not AskUser(usertext):
629 def _RenewCryptoInner(ctx):
630 ctx.feedback_fn("Updating certificates and keys")
631 bootstrap.GenerateClusterCrypto(new_cluster_cert, new_rapi_cert,
634 rapi_cert_pem=rapi_cert_pem,
640 files_to_copy.append(constants.NODED_CERT_FILE)
642 if new_rapi_cert or rapi_cert_pem:
643 files_to_copy.append(constants.RAPI_CERT_FILE)
645 if new_confd_hmac_key:
646 files_to_copy.append(constants.CONFD_HMAC_KEY)
649 files_to_copy.append(constants.CLUSTER_DOMAIN_SECRET_FILE)
652 for node_name in ctx.nonmaster_nodes:
653 ctx.feedback_fn("Copying %s to %s" %
654 (", ".join(files_to_copy), node_name))
655 for file_name in files_to_copy:
656 ctx.ssh.CopyFileToNode(node_name, file_name)
658 RunWhileClusterStopped(ToStdout, _RenewCryptoInner)
660 ToStdout("All requested certificates and keys have been replaced."
661 " Running \"gnt-cluster verify\" now is recommended.")
666 def RenewCrypto(opts, args):
667 """Renews cluster certificates, keys and secrets.
670 return _RenewCrypto(opts.new_cluster_cert,
673 opts.new_confd_hmac_key,
674 opts.new_cluster_domain_secret,
675 opts.cluster_domain_secret,
679 def SetClusterParams(opts, args):
680 """Modify the cluster.
682 @param opts: the command line options selected by the user
684 @param args: should be an empty list
686 @return: the desired exit code
689 if not (not opts.lvm_storage or opts.vg_name or
690 not opts.drbd_storage or opts.drbd_helper or
691 opts.enabled_hypervisors or opts.hvparams or
692 opts.beparams or opts.nicparams or
693 opts.candidate_pool_size is not None or
694 opts.uid_pool is not None or
695 opts.maintain_node_health is not None or
696 opts.add_uids is not None or
697 opts.remove_uids is not None or
698 opts.default_iallocator is not None or
699 opts.reserved_lvs is not None):
700 ToStderr("Please give at least one of the parameters.")
703 vg_name = opts.vg_name
704 if not opts.lvm_storage and opts.vg_name:
705 ToStderr("Options --no-lvm-storage and --vg-name conflict.")
708 if not opts.lvm_storage:
711 drbd_helper = opts.drbd_helper
712 if not opts.drbd_storage and opts.drbd_helper:
713 ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.")
716 if not opts.drbd_storage:
719 hvlist = opts.enabled_hypervisors
720 if hvlist is not None:
721 hvlist = hvlist.split(",")
723 # a list of (name, dict) we can pass directly to dict() (or [])
724 hvparams = dict(opts.hvparams)
725 for hv_params in hvparams.values():
726 utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
728 beparams = opts.beparams
729 utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
731 nicparams = opts.nicparams
732 utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
735 mnh = opts.maintain_node_health
737 uid_pool = opts.uid_pool
738 if uid_pool is not None:
739 uid_pool = uidpool.ParseUidPool(uid_pool)
741 add_uids = opts.add_uids
742 if add_uids is not None:
743 add_uids = uidpool.ParseUidPool(add_uids)
745 remove_uids = opts.remove_uids
746 if remove_uids is not None:
747 remove_uids = uidpool.ParseUidPool(remove_uids)
749 if opts.reserved_lvs is not None:
750 if opts.reserved_lvs == "":
751 opts.reserved_lvs = []
753 opts.reserved_lvs = utils.UnescapeAndSplit(opts.reserved_lvs, sep=",")
755 op = opcodes.OpSetClusterParams(vg_name=vg_name,
756 drbd_helper=drbd_helper,
757 enabled_hypervisors=hvlist,
762 candidate_pool_size=opts.candidate_pool_size,
763 maintain_node_health=mnh,
766 remove_uids=remove_uids,
767 default_iallocator=opts.default_iallocator,
768 reserved_lvs=opts.reserved_lvs)
769 SubmitOpCode(op, opts=opts)
773 def QueueOps(opts, args):
776 @param opts: the command line options selected by the user
778 @param args: should contain only one element, the subcommand
780 @return: the desired exit code
785 if command in ("drain", "undrain"):
786 drain_flag = command == "drain"
787 client.SetQueueDrainFlag(drain_flag)
788 elif command == "info":
789 result = client.QueryConfigValues(["drain_flag"])
794 ToStdout("The drain flag is %s" % val)
796 raise errors.OpPrereqError("Command '%s' is not valid." % command,
802 def _ShowWatcherPause(until):
803 if until is None or until < time.time():
804 ToStdout("The watcher is not paused.")
806 ToStdout("The watcher is paused until %s.", time.ctime(until))
809 def WatcherOps(opts, args):
810 """Watcher operations.
812 @param opts: the command line options selected by the user
814 @param args: should contain only one element, the subcommand
816 @return: the desired exit code
822 if command == "continue":
823 client.SetWatcherPause(None)
824 ToStdout("The watcher is no longer paused.")
826 elif command == "pause":
828 raise errors.OpPrereqError("Missing pause duration", errors.ECODE_INVAL)
830 result = client.SetWatcherPause(time.time() + ParseTimespec(args[1]))
831 _ShowWatcherPause(result)
833 elif command == "info":
834 result = client.QueryConfigValues(["watcher_pause"])
835 _ShowWatcherPause(result[0])
838 raise errors.OpPrereqError("Command '%s' is not valid." % command,
846 InitCluster, [ArgHost(min=1, max=1)],
847 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, GLOBAL_FILEDIR_OPT,
848 HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT, NIC_PARAMS_OPT,
849 NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
850 SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
851 UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
852 DEFAULT_IALLOCATOR_OPT],
853 "[opts...] <cluster_name>", "Initialises a new cluster configuration"),
855 DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
856 "", "Destroy cluster"),
858 RenameCluster, [ArgHost(min=1, max=1)],
859 [FORCE_OPT, DRY_RUN_OPT],
861 "Renames the cluster"),
863 RedistributeConfig, ARGS_NONE, [SUBMIT_OPT, DRY_RUN_OPT],
864 "", "Forces a push of the configuration file and ssconf files"
865 " to the nodes in the cluster"),
867 VerifyCluster, ARGS_NONE,
868 [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT,
870 "", "Does a check on the cluster configuration"),
872 VerifyDisks, ARGS_NONE, [],
873 "", "Does a check on the cluster disk status"),
874 'repair-disk-sizes': (
875 RepairDiskSizes, ARGS_MANY_INSTANCES, [DRY_RUN_OPT],
876 "", "Updates mismatches in recorded disk sizes"),
878 MasterFailover, ARGS_NONE, [NOVOTING_OPT],
879 "", "Makes the current node the master"),
881 MasterPing, ARGS_NONE, [],
882 "", "Checks if the master is alive"),
884 ShowClusterVersion, ARGS_NONE, [],
885 "", "Shows the cluster version"),
887 ShowClusterMaster, ARGS_NONE, [],
888 "", "Shows the cluster master"),
890 ClusterCopyFile, [ArgFile(min=1, max=1)],
891 [NODE_LIST_OPT, USE_REPL_NET_OPT],
892 "[-n node...] <filename>", "Copies a file to all (or only some) nodes"),
894 RunClusterCommand, [ArgCommand(min=1)],
896 "[-n node...] <command>", "Runs a command on all (or only some) nodes"),
898 ShowClusterConfig, ARGS_NONE, [ROMAN_OPT],
899 "[--roman]", "Show cluster configuration"),
901 ListTags, ARGS_NONE, [], "", "List the tags of the cluster"),
903 AddTags, [ArgUnknown()], [TAG_SRC_OPT],
904 "tag...", "Add tags to the cluster"),
906 RemoveTags, [ArgUnknown()], [TAG_SRC_OPT],
907 "tag...", "Remove tags from the cluster"),
909 SearchTags, [ArgUnknown(min=1, max=1)],
910 [], "", "Searches the tags on all objects on"
911 " the cluster for a given pattern (regex)"),
914 [ArgChoice(min=1, max=1, choices=["drain", "undrain", "info"])],
915 [], "drain|undrain|info", "Change queue properties"),
918 [ArgChoice(min=1, max=1, choices=["pause", "continue", "info"]),
919 ArgSuggest(min=0, max=1, choices=["30m", "1h", "4h"])],
921 "{pause <timespec>|continue|info}", "Change watcher properties"),
923 SetClusterParams, ARGS_NONE,
924 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
925 NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
926 UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT,
927 NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT,
930 "Alters the parameters of the cluster"),
932 RenewCrypto, ARGS_NONE,
933 [NEW_CLUSTER_CERT_OPT, NEW_RAPI_CERT_OPT, RAPI_CERT_OPT,
934 NEW_CONFD_HMAC_KEY_OPT, FORCE_OPT,
935 NEW_CLUSTER_DOMAIN_SECRET_OPT, CLUSTER_DOMAIN_SECRET_OPT],
937 "Renews cluster certificates, keys and secrets"),
941 #: dictionary with aliases for commands
943 'masterfailover': 'master-failover',
947 if __name__ == '__main__':
948 sys.exit(GenericMain(commands, override={"tag_type": constants.TAG_CLUSTER},