4 # Copyright (C) 2006, 2007 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)
182 ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result)
187 def RedistributeConfig(opts, args):
188 """Forces push of the cluster configuration.
190 @param opts: the command line options selected by the user
192 @param args: empty list
194 @return: the desired exit code
197 op = opcodes.OpRedistributeConfig()
198 SubmitOrSend(op, opts)
202 def ShowClusterVersion(opts, args):
203 """Write version of ganeti software to the standard output.
205 @param opts: the command line options selected by the user
207 @param args: should be an empty list
209 @return: the desired exit code
213 result = cl.QueryClusterInfo()
214 ToStdout("Software version: %s", result["software_version"])
215 ToStdout("Internode protocol: %s", result["protocol_version"])
216 ToStdout("Configuration format: %s", result["config_version"])
217 ToStdout("OS api version: %s", result["os_api_version"])
218 ToStdout("Export interface: %s", result["export_version"])
222 def ShowClusterMaster(opts, args):
223 """Write name of master node to the standard output.
225 @param opts: the command line options selected by the user
227 @param args: should be an empty list
229 @return: the desired exit code
232 master = bootstrap.GetMaster()
237 def _PrintGroupedParams(paramsdict, level=1, roman=False):
238 """Print Grouped parameters (be, nic, disk) by group.
240 @type paramsdict: dict of dicts
241 @param paramsdict: {group: {param: value, ...}, ...}
243 @param level: Level of indention
247 for item, val in sorted(paramsdict.items()):
248 if isinstance(val, dict):
249 ToStdout("%s- %s:", indent, item)
250 _PrintGroupedParams(val, level=level + 1, roman=roman)
251 elif roman and isinstance(val, int):
252 ToStdout("%s %s: %s", indent, item, compat.TryToRoman(val))
254 ToStdout("%s %s: %s", indent, item, val)
257 def ShowClusterConfig(opts, args):
258 """Shows cluster information.
260 @param opts: the command line options selected by the user
262 @param args: should be an empty list
264 @return: the desired exit code
268 result = cl.QueryClusterInfo()
270 ToStdout("Cluster name: %s", result["name"])
271 ToStdout("Cluster UUID: %s", result["uuid"])
273 ToStdout("Creation time: %s", utils.FormatTime(result["ctime"]))
274 ToStdout("Modification time: %s", utils.FormatTime(result["mtime"]))
276 ToStdout("Master node: %s", result["master"])
278 ToStdout("Architecture (this node): %s (%s)",
279 result["architecture"][0], result["architecture"][1])
282 tags = utils.CommaJoin(utils.NiceSort(result["tags"]))
286 ToStdout("Tags: %s", tags)
288 ToStdout("Default hypervisor: %s", result["default_hypervisor"])
289 ToStdout("Enabled hypervisors: %s",
290 utils.CommaJoin(result["enabled_hypervisors"]))
292 ToStdout("Hypervisor parameters:")
293 _PrintGroupedParams(result["hvparams"])
295 ToStdout("OS-specific hypervisor parameters:")
296 _PrintGroupedParams(result["os_hvp"])
298 ToStdout("OS parameters:")
299 _PrintGroupedParams(result["osparams"])
301 ToStdout("Cluster parameters:")
302 ToStdout(" - candidate pool size: %s",
303 compat.TryToRoman(result["candidate_pool_size"],
304 convert=opts.roman_integers))
305 ToStdout(" - master netdev: %s", result["master_netdev"])
306 ToStdout(" - lvm volume group: %s", result["volume_group_name"])
307 if result["reserved_lvs"]:
308 reserved_lvs = utils.CommaJoin(result["reserved_lvs"])
310 reserved_lvs = "(none)"
311 ToStdout(" - lvm reserved volumes: %s", reserved_lvs)
312 ToStdout(" - drbd usermode helper: %s", result["drbd_usermode_helper"])
313 ToStdout(" - file storage path: %s", result["file_storage_dir"])
314 ToStdout(" - maintenance of node health: %s",
315 result["maintain_node_health"])
316 ToStdout(" - uid pool: %s",
317 uidpool.FormatUidPool(result["uid_pool"],
318 roman=opts.roman_integers))
319 ToStdout(" - default instance allocator: %s", result["default_iallocator"])
321 ToStdout("Default instance parameters:")
322 _PrintGroupedParams(result["beparams"], roman=opts.roman_integers)
324 ToStdout("Default nic parameters:")
325 _PrintGroupedParams(result["nicparams"], roman=opts.roman_integers)
330 def ClusterCopyFile(opts, args):
331 """Copy a file from master to some nodes.
333 @param opts: the command line options selected by the user
335 @param args: should contain only one element, the path of
336 the file to be copied
338 @return: the desired exit code
342 if not os.path.exists(filename):
343 raise errors.OpPrereqError("No such filename '%s'" % filename,
348 cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
350 results = GetOnlineNodes(nodes=opts.nodes, cl=cl, filter_master=True,
351 secondary_ips=opts.use_replication_network)
353 srun = ssh.SshRunner(cluster_name=cluster_name)
355 if not srun.CopyFileToNode(node, filename):
356 ToStderr("Copy of file %s to node %s failed", filename, node)
361 def RunClusterCommand(opts, args):
362 """Run a command on some nodes.
364 @param opts: the command line options selected by the user
366 @param args: should contain the command to be run and its arguments
368 @return: the desired exit code
373 command = " ".join(args)
375 nodes = GetOnlineNodes(nodes=opts.nodes, cl=cl)
377 cluster_name, master_node = cl.QueryConfigValues(["cluster_name",
380 srun = ssh.SshRunner(cluster_name=cluster_name)
382 # Make sure master node is at list end
383 if master_node in nodes:
384 nodes.remove(master_node)
385 nodes.append(master_node)
388 result = srun.Run(name, "root", command)
389 ToStdout("------------------------------------------------")
390 ToStdout("node: %s", name)
391 ToStdout("%s", result.output)
392 ToStdout("return code = %s", result.exit_code)
397 def VerifyCluster(opts, args):
398 """Verify integrity of cluster, performing various test on nodes.
400 @param opts: the command line options selected by the user
402 @param args: should be an empty list
404 @return: the desired exit code
408 if opts.skip_nplusone_mem:
409 skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
410 op = opcodes.OpVerifyCluster(skip_checks=skip_checks,
411 verbose=opts.verbose,
412 error_codes=opts.error_codes,
413 debug_simulate_errors=opts.simulate_errors)
414 if SubmitOpCode(op, opts=opts):
420 def VerifyDisks(opts, args):
421 """Verify integrity of cluster disks.
423 @param opts: the command line options selected by the user
425 @param args: should be an empty list
427 @return: the desired exit code
430 op = opcodes.OpVerifyDisks()
431 result = SubmitOpCode(op, opts=opts)
432 if not isinstance(result, (list, tuple)) or len(result) != 3:
433 raise errors.ProgrammerError("Unknown result type for OpVerifyDisks")
435 bad_nodes, instances, missing = result
437 retcode = constants.EXIT_SUCCESS
440 for node, text in bad_nodes.items():
441 ToStdout("Error gathering data on node %s: %s",
442 node, utils.SafeEncode(text[-400:]))
444 ToStdout("You need to fix these nodes first before fixing instances")
447 for iname in instances:
450 op = opcodes.OpActivateInstanceDisks(instance_name=iname)
452 ToStdout("Activating disks for instance '%s'", iname)
453 SubmitOpCode(op, opts=opts)
454 except errors.GenericError, err:
455 nret, msg = FormatError(err)
457 ToStderr("Error activating disks for instance %s: %s", iname, msg)
460 for iname, ival in missing.iteritems():
461 all_missing = compat.all(x[0] in bad_nodes for x in ival)
463 ToStdout("Instance %s cannot be verified as it lives on"
464 " broken nodes", iname)
466 ToStdout("Instance %s has missing logical volumes:", iname)
468 for node, vol in ival:
469 if node in bad_nodes:
470 ToStdout("\tbroken node %s /dev/xenvg/%s", node, vol)
472 ToStdout("\t%s /dev/xenvg/%s", node, vol)
473 ToStdout("You need to run replace_disks for all the above"
474 " instances, if this message persist after fixing nodes.")
480 def RepairDiskSizes(opts, args):
481 """Verify sizes of cluster disks.
483 @param opts: the command line options selected by the user
485 @param args: optional list of instances to restrict check to
487 @return: the desired exit code
490 op = opcodes.OpRepairDiskSizes(instances=args)
491 SubmitOpCode(op, opts=opts)
495 def MasterFailover(opts, args):
496 """Failover the master node.
498 This command, when run on a non-master node, will cause the current
499 master to cease being master, and the non-master to become new
502 @param opts: the command line options selected by the user
504 @param args: should be an empty list
506 @return: the desired exit code
510 usertext = ("This will perform the failover even if most other nodes"
511 " are down, or if this node is outdated. This is dangerous"
512 " as it can lead to a non-consistent cluster. Check the"
513 " gnt-cluster(8) man page before proceeding. Continue?")
514 if not AskUser(usertext):
517 return bootstrap.MasterFailover(no_voting=opts.no_voting)
520 def MasterPing(opts, args):
521 """Checks if the master is alive.
523 @param opts: the command line options selected by the user
525 @param args: should be an empty list
527 @return: the desired exit code
532 cl.QueryClusterInfo()
534 except Exception: # pylint: disable-msg=W0703
538 def SearchTags(opts, args):
539 """Searches the tags on all the cluster.
541 @param opts: the command line options selected by the user
543 @param args: should contain only one element, the tag pattern
545 @return: the desired exit code
548 op = opcodes.OpSearchTags(pattern=args[0])
549 result = SubmitOpCode(op, opts=opts)
552 result = list(result)
554 for path, tag in result:
555 ToStdout("%s %s", path, tag)
558 def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename,
559 new_confd_hmac_key, new_cds, cds_filename,
561 """Renews cluster certificates, keys and secrets.
563 @type new_cluster_cert: bool
564 @param new_cluster_cert: Whether to generate a new cluster certificate
565 @type new_rapi_cert: bool
566 @param new_rapi_cert: Whether to generate a new RAPI certificate
567 @type rapi_cert_filename: string
568 @param rapi_cert_filename: Path to file containing new RAPI certificate
569 @type new_confd_hmac_key: bool
570 @param new_confd_hmac_key: Whether to generate a new HMAC key
572 @param new_cds: Whether to generate a new cluster domain secret
573 @type cds_filename: string
574 @param cds_filename: Path to file containing new cluster domain secret
576 @param force: Whether to ask user for confirmation
579 if new_rapi_cert and rapi_cert_filename:
580 ToStderr("Only one of the --new-rapi-certficate and --rapi-certificate"
581 " options can be specified at the same time.")
584 if new_cds and cds_filename:
585 ToStderr("Only one of the --new-cluster-domain-secret and"
586 " --cluster-domain-secret options can be specified at"
590 if rapi_cert_filename:
591 # Read and verify new certificate
593 rapi_cert_pem = utils.ReadFile(rapi_cert_filename)
595 OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
597 except Exception, err: # pylint: disable-msg=W0703
598 ToStderr("Can't load new RAPI certificate from %s: %s" %
599 (rapi_cert_filename, str(err)))
603 OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, rapi_cert_pem)
604 except Exception, err: # pylint: disable-msg=W0703
605 ToStderr("Can't load new RAPI private key from %s: %s" %
606 (rapi_cert_filename, str(err)))
614 cds = utils.ReadFile(cds_filename)
615 except Exception, err: # pylint: disable-msg=W0703
616 ToStderr("Can't load new cluster domain secret from %s: %s" %
617 (cds_filename, str(err)))
623 usertext = ("This requires all daemons on all nodes to be restarted and"
624 " may take some time. Continue?")
625 if not AskUser(usertext):
628 def _RenewCryptoInner(ctx):
629 ctx.feedback_fn("Updating certificates and keys")
630 bootstrap.GenerateClusterCrypto(new_cluster_cert, new_rapi_cert,
633 rapi_cert_pem=rapi_cert_pem,
639 files_to_copy.append(constants.NODED_CERT_FILE)
641 if new_rapi_cert or rapi_cert_pem:
642 files_to_copy.append(constants.RAPI_CERT_FILE)
644 if new_confd_hmac_key:
645 files_to_copy.append(constants.CONFD_HMAC_KEY)
648 files_to_copy.append(constants.CLUSTER_DOMAIN_SECRET_FILE)
651 for node_name in ctx.nonmaster_nodes:
652 ctx.feedback_fn("Copying %s to %s" %
653 (", ".join(files_to_copy), node_name))
654 for file_name in files_to_copy:
655 ctx.ssh.CopyFileToNode(node_name, file_name)
657 RunWhileClusterStopped(ToStdout, _RenewCryptoInner)
659 ToStdout("All requested certificates and keys have been replaced."
660 " Running \"gnt-cluster verify\" now is recommended.")
665 def RenewCrypto(opts, args):
666 """Renews cluster certificates, keys and secrets.
669 return _RenewCrypto(opts.new_cluster_cert,
672 opts.new_confd_hmac_key,
673 opts.new_cluster_domain_secret,
674 opts.cluster_domain_secret,
678 def SetClusterParams(opts, args):
679 """Modify the cluster.
681 @param opts: the command line options selected by the user
683 @param args: should be an empty list
685 @return: the desired exit code
688 if not (not opts.lvm_storage or opts.vg_name or
689 not opts.drbd_storage or opts.drbd_helper or
690 opts.enabled_hypervisors or opts.hvparams or
691 opts.beparams or opts.nicparams or
692 opts.candidate_pool_size is not None or
693 opts.uid_pool is not None or
694 opts.maintain_node_health is not None or
695 opts.add_uids is not None or
696 opts.remove_uids is not None or
697 opts.default_iallocator is not None or
698 opts.reserved_lvs is not None):
699 ToStderr("Please give at least one of the parameters.")
702 vg_name = opts.vg_name
703 if not opts.lvm_storage and opts.vg_name:
704 ToStderr("Options --no-lvm-storage and --vg-name conflict.")
707 if not opts.lvm_storage:
710 drbd_helper = opts.drbd_helper
711 if not opts.drbd_storage and opts.drbd_helper:
712 ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.")
715 if not opts.drbd_storage:
718 hvlist = opts.enabled_hypervisors
719 if hvlist is not None:
720 hvlist = hvlist.split(",")
722 # a list of (name, dict) we can pass directly to dict() (or [])
723 hvparams = dict(opts.hvparams)
724 for hv_params in hvparams.values():
725 utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
727 beparams = opts.beparams
728 utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
730 nicparams = opts.nicparams
731 utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
734 mnh = opts.maintain_node_health
736 uid_pool = opts.uid_pool
737 if uid_pool is not None:
738 uid_pool = uidpool.ParseUidPool(uid_pool)
740 add_uids = opts.add_uids
741 if add_uids is not None:
742 add_uids = uidpool.ParseUidPool(add_uids)
744 remove_uids = opts.remove_uids
745 if remove_uids is not None:
746 remove_uids = uidpool.ParseUidPool(remove_uids)
748 if opts.reserved_lvs is not None:
749 if opts.reserved_lvs == "":
750 opts.reserved_lvs = []
752 opts.reserved_lvs = utils.UnescapeAndSplit(opts.reserved_lvs, sep=",")
754 op = opcodes.OpSetClusterParams(vg_name=vg_name,
755 drbd_helper=drbd_helper,
756 enabled_hypervisors=hvlist,
761 candidate_pool_size=opts.candidate_pool_size,
762 maintain_node_health=mnh,
765 remove_uids=remove_uids,
766 default_iallocator=opts.default_iallocator,
767 reserved_lvs=opts.reserved_lvs)
768 SubmitOpCode(op, opts=opts)
772 def QueueOps(opts, args):
775 @param opts: the command line options selected by the user
777 @param args: should contain only one element, the subcommand
779 @return: the desired exit code
784 if command in ("drain", "undrain"):
785 drain_flag = command == "drain"
786 client.SetQueueDrainFlag(drain_flag)
787 elif command == "info":
788 result = client.QueryConfigValues(["drain_flag"])
793 ToStdout("The drain flag is %s" % val)
795 raise errors.OpPrereqError("Command '%s' is not valid." % command,
801 def _ShowWatcherPause(until):
802 if until is None or until < time.time():
803 ToStdout("The watcher is not paused.")
805 ToStdout("The watcher is paused until %s.", time.ctime(until))
808 def WatcherOps(opts, args):
809 """Watcher operations.
811 @param opts: the command line options selected by the user
813 @param args: should contain only one element, the subcommand
815 @return: the desired exit code
821 if command == "continue":
822 client.SetWatcherPause(None)
823 ToStdout("The watcher is no longer paused.")
825 elif command == "pause":
827 raise errors.OpPrereqError("Missing pause duration", errors.ECODE_INVAL)
829 result = client.SetWatcherPause(time.time() + ParseTimespec(args[1]))
830 _ShowWatcherPause(result)
832 elif command == "info":
833 result = client.QueryConfigValues(["watcher_pause"])
834 _ShowWatcherPause(result[0])
837 raise errors.OpPrereqError("Command '%s' is not valid." % command,
845 InitCluster, [ArgHost(min=1, max=1)],
846 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, GLOBAL_FILEDIR_OPT,
847 HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT, NIC_PARAMS_OPT,
848 NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
849 SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
850 UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
851 DEFAULT_IALLOCATOR_OPT],
852 "[opts...] <cluster_name>", "Initialises a new cluster configuration"),
854 DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
855 "", "Destroy cluster"),
857 RenameCluster, [ArgHost(min=1, max=1)],
860 "Renames the cluster"),
862 RedistributeConfig, ARGS_NONE, [SUBMIT_OPT],
863 "", "Forces a push of the configuration file and ssconf files"
864 " to the nodes in the cluster"),
866 VerifyCluster, ARGS_NONE,
867 [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT],
868 "", "Does a check on the cluster configuration"),
870 VerifyDisks, ARGS_NONE, [],
871 "", "Does a check on the cluster disk status"),
872 'repair-disk-sizes': (
873 RepairDiskSizes, ARGS_MANY_INSTANCES, [],
874 "", "Updates mismatches in recorded disk sizes"),
876 MasterFailover, ARGS_NONE, [NOVOTING_OPT],
877 "", "Makes the current node the master"),
879 MasterPing, ARGS_NONE, [],
880 "", "Checks if the master is alive"),
882 ShowClusterVersion, ARGS_NONE, [],
883 "", "Shows the cluster version"),
885 ShowClusterMaster, ARGS_NONE, [],
886 "", "Shows the cluster master"),
888 ClusterCopyFile, [ArgFile(min=1, max=1)],
889 [NODE_LIST_OPT, USE_REPL_NET_OPT],
890 "[-n node...] <filename>", "Copies a file to all (or only some) nodes"),
892 RunClusterCommand, [ArgCommand(min=1)],
894 "[-n node...] <command>", "Runs a command on all (or only some) nodes"),
896 ShowClusterConfig, ARGS_NONE, [ROMAN_OPT],
897 "[--roman]", "Show cluster configuration"),
899 ListTags, ARGS_NONE, [], "", "List the tags of the cluster"),
901 AddTags, [ArgUnknown()], [TAG_SRC_OPT],
902 "tag...", "Add tags to the cluster"),
904 RemoveTags, [ArgUnknown()], [TAG_SRC_OPT],
905 "tag...", "Remove tags from the cluster"),
907 SearchTags, [ArgUnknown(min=1, max=1)],
908 [], "", "Searches the tags on all objects on"
909 " the cluster for a given pattern (regex)"),
912 [ArgChoice(min=1, max=1, choices=["drain", "undrain", "info"])],
913 [], "drain|undrain|info", "Change queue properties"),
916 [ArgChoice(min=1, max=1, choices=["pause", "continue", "info"]),
917 ArgSuggest(min=0, max=1, choices=["30m", "1h", "4h"])],
919 "{pause <timespec>|continue|info}", "Change watcher properties"),
921 SetClusterParams, ARGS_NONE,
922 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
923 NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
924 UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT,
925 NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT],
927 "Alters the parameters of the cluster"),
929 RenewCrypto, ARGS_NONE,
930 [NEW_CLUSTER_CERT_OPT, NEW_RAPI_CERT_OPT, RAPI_CERT_OPT,
931 NEW_CONFD_HMAC_KEY_OPT, FORCE_OPT,
932 NEW_CLUSTER_DOMAIN_SECRET_OPT, CLUSTER_DOMAIN_SECRET_OPT],
934 "Renews cluster certificates, keys and secrets"),
938 #: dictionary with aliases for commands
940 'masterfailover': 'master-failover',
944 if __name__ == '__main__':
945 sys.exit(GenericMain(commands, override={"tag_type": constants.TAG_CLUSTER},