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 SearchTags(opts, args):
521 """Searches the tags on all the cluster.
523 @param opts: the command line options selected by the user
525 @param args: should contain only one element, the tag pattern
527 @return: the desired exit code
530 op = opcodes.OpSearchTags(pattern=args[0])
531 result = SubmitOpCode(op, opts=opts)
534 result = list(result)
536 for path, tag in result:
537 ToStdout("%s %s", path, tag)
540 def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename,
541 new_confd_hmac_key, new_cds, cds_filename,
543 """Renews cluster certificates, keys and secrets.
545 @type new_cluster_cert: bool
546 @param new_cluster_cert: Whether to generate a new cluster certificate
547 @type new_rapi_cert: bool
548 @param new_rapi_cert: Whether to generate a new RAPI certificate
549 @type rapi_cert_filename: string
550 @param rapi_cert_filename: Path to file containing new RAPI certificate
551 @type new_confd_hmac_key: bool
552 @param new_confd_hmac_key: Whether to generate a new HMAC key
554 @param new_cds: Whether to generate a new cluster domain secret
555 @type cds_filename: string
556 @param cds_filename: Path to file containing new cluster domain secret
558 @param force: Whether to ask user for confirmation
561 if new_rapi_cert and rapi_cert_filename:
562 ToStderr("Only one of the --new-rapi-certficate and --rapi-certificate"
563 " options can be specified at the same time.")
566 if new_cds and cds_filename:
567 ToStderr("Only one of the --new-cluster-domain-secret and"
568 " --cluster-domain-secret options can be specified at"
572 if rapi_cert_filename:
573 # Read and verify new certificate
575 rapi_cert_pem = utils.ReadFile(rapi_cert_filename)
577 OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
579 except Exception, err: # pylint: disable-msg=W0703
580 ToStderr("Can't load new RAPI certificate from %s: %s" %
581 (rapi_cert_filename, str(err)))
585 OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, rapi_cert_pem)
586 except Exception, err: # pylint: disable-msg=W0703
587 ToStderr("Can't load new RAPI private key from %s: %s" %
588 (rapi_cert_filename, str(err)))
596 cds = utils.ReadFile(cds_filename)
597 except Exception, err: # pylint: disable-msg=W0703
598 ToStderr("Can't load new cluster domain secret from %s: %s" %
599 (cds_filename, str(err)))
605 usertext = ("This requires all daemons on all nodes to be restarted and"
606 " may take some time. Continue?")
607 if not AskUser(usertext):
610 def _RenewCryptoInner(ctx):
611 ctx.feedback_fn("Updating certificates and keys")
612 bootstrap.GenerateClusterCrypto(new_cluster_cert, new_rapi_cert,
615 rapi_cert_pem=rapi_cert_pem,
621 files_to_copy.append(constants.NODED_CERT_FILE)
623 if new_rapi_cert or rapi_cert_pem:
624 files_to_copy.append(constants.RAPI_CERT_FILE)
626 if new_confd_hmac_key:
627 files_to_copy.append(constants.CONFD_HMAC_KEY)
630 files_to_copy.append(constants.CLUSTER_DOMAIN_SECRET_FILE)
633 for node_name in ctx.nonmaster_nodes:
634 ctx.feedback_fn("Copying %s to %s" %
635 (", ".join(files_to_copy), node_name))
636 for file_name in files_to_copy:
637 ctx.ssh.CopyFileToNode(node_name, file_name)
639 RunWhileClusterStopped(ToStdout, _RenewCryptoInner)
641 ToStdout("All requested certificates and keys have been replaced."
642 " Running \"gnt-cluster verify\" now is recommended.")
647 def RenewCrypto(opts, args):
648 """Renews cluster certificates, keys and secrets.
651 return _RenewCrypto(opts.new_cluster_cert,
654 opts.new_confd_hmac_key,
655 opts.new_cluster_domain_secret,
656 opts.cluster_domain_secret,
660 def SetClusterParams(opts, args):
661 """Modify the cluster.
663 @param opts: the command line options selected by the user
665 @param args: should be an empty list
667 @return: the desired exit code
670 if not (not opts.lvm_storage or opts.vg_name or
671 not opts.drbd_storage or opts.drbd_helper or
672 opts.enabled_hypervisors or opts.hvparams or
673 opts.beparams or opts.nicparams or
674 opts.candidate_pool_size is not None or
675 opts.uid_pool is not None or
676 opts.maintain_node_health is not None or
677 opts.add_uids is not None or
678 opts.remove_uids is not None or
679 opts.default_iallocator is not None or
680 opts.reserved_lvs is not None):
681 ToStderr("Please give at least one of the parameters.")
684 vg_name = opts.vg_name
685 if not opts.lvm_storage and opts.vg_name:
686 ToStderr("Options --no-lvm-storage and --vg-name conflict.")
689 if not opts.lvm_storage:
692 drbd_helper = opts.drbd_helper
693 if not opts.drbd_storage and opts.drbd_helper:
694 ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.")
697 if not opts.drbd_storage:
700 hvlist = opts.enabled_hypervisors
701 if hvlist is not None:
702 hvlist = hvlist.split(",")
704 # a list of (name, dict) we can pass directly to dict() (or [])
705 hvparams = dict(opts.hvparams)
706 for hv_params in hvparams.values():
707 utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
709 beparams = opts.beparams
710 utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
712 nicparams = opts.nicparams
713 utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
716 mnh = opts.maintain_node_health
718 uid_pool = opts.uid_pool
719 if uid_pool is not None:
720 uid_pool = uidpool.ParseUidPool(uid_pool)
722 add_uids = opts.add_uids
723 if add_uids is not None:
724 add_uids = uidpool.ParseUidPool(add_uids)
726 remove_uids = opts.remove_uids
727 if remove_uids is not None:
728 remove_uids = uidpool.ParseUidPool(remove_uids)
730 if opts.reserved_lvs is not None:
731 if opts.reserved_lvs == "":
732 opts.reserved_lvs = []
734 opts.reserved_lvs = utils.UnescapeAndSplit(opts.reserved_lvs, sep=",")
736 op = opcodes.OpSetClusterParams(vg_name=vg_name,
737 drbd_helper=drbd_helper,
738 enabled_hypervisors=hvlist,
743 candidate_pool_size=opts.candidate_pool_size,
744 maintain_node_health=mnh,
747 remove_uids=remove_uids,
748 default_iallocator=opts.default_iallocator,
749 reserved_lvs=opts.reserved_lvs)
750 SubmitOpCode(op, opts=opts)
754 def QueueOps(opts, args):
757 @param opts: the command line options selected by the user
759 @param args: should contain only one element, the subcommand
761 @return: the desired exit code
766 if command in ("drain", "undrain"):
767 drain_flag = command == "drain"
768 client.SetQueueDrainFlag(drain_flag)
769 elif command == "info":
770 result = client.QueryConfigValues(["drain_flag"])
775 ToStdout("The drain flag is %s" % val)
777 raise errors.OpPrereqError("Command '%s' is not valid." % command,
783 def _ShowWatcherPause(until):
784 if until is None or until < time.time():
785 ToStdout("The watcher is not paused.")
787 ToStdout("The watcher is paused until %s.", time.ctime(until))
790 def WatcherOps(opts, args):
791 """Watcher operations.
793 @param opts: the command line options selected by the user
795 @param args: should contain only one element, the subcommand
797 @return: the desired exit code
803 if command == "continue":
804 client.SetWatcherPause(None)
805 ToStdout("The watcher is no longer paused.")
807 elif command == "pause":
809 raise errors.OpPrereqError("Missing pause duration", errors.ECODE_INVAL)
811 result = client.SetWatcherPause(time.time() + ParseTimespec(args[1]))
812 _ShowWatcherPause(result)
814 elif command == "info":
815 result = client.QueryConfigValues(["watcher_pause"])
816 _ShowWatcherPause(result[0])
819 raise errors.OpPrereqError("Command '%s' is not valid." % command,
827 InitCluster, [ArgHost(min=1, max=1)],
828 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, GLOBAL_FILEDIR_OPT,
829 HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT, NIC_PARAMS_OPT,
830 NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
831 SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
832 UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
833 DEFAULT_IALLOCATOR_OPT],
834 "[opts...] <cluster_name>", "Initialises a new cluster configuration"),
836 DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
837 "", "Destroy cluster"),
839 RenameCluster, [ArgHost(min=1, max=1)],
842 "Renames the cluster"),
844 RedistributeConfig, ARGS_NONE, [SUBMIT_OPT],
845 "", "Forces a push of the configuration file and ssconf files"
846 " to the nodes in the cluster"),
848 VerifyCluster, ARGS_NONE,
849 [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT],
850 "", "Does a check on the cluster configuration"),
852 VerifyDisks, ARGS_NONE, [],
853 "", "Does a check on the cluster disk status"),
854 'repair-disk-sizes': (
855 RepairDiskSizes, ARGS_MANY_INSTANCES, [],
856 "", "Updates mismatches in recorded disk sizes"),
858 MasterFailover, ARGS_NONE, [NOVOTING_OPT],
859 "", "Makes the current node the master"),
861 ShowClusterVersion, ARGS_NONE, [],
862 "", "Shows the cluster version"),
864 ShowClusterMaster, ARGS_NONE, [],
865 "", "Shows the cluster master"),
867 ClusterCopyFile, [ArgFile(min=1, max=1)],
868 [NODE_LIST_OPT, USE_REPL_NET_OPT],
869 "[-n node...] <filename>", "Copies a file to all (or only some) nodes"),
871 RunClusterCommand, [ArgCommand(min=1)],
873 "[-n node...] <command>", "Runs a command on all (or only some) nodes"),
875 ShowClusterConfig, ARGS_NONE, [ROMAN_OPT],
876 "[--roman]", "Show cluster configuration"),
878 ListTags, ARGS_NONE, [], "", "List the tags of the cluster"),
880 AddTags, [ArgUnknown()], [TAG_SRC_OPT],
881 "tag...", "Add tags to the cluster"),
883 RemoveTags, [ArgUnknown()], [TAG_SRC_OPT],
884 "tag...", "Remove tags from the cluster"),
886 SearchTags, [ArgUnknown(min=1, max=1)],
887 [], "", "Searches the tags on all objects on"
888 " the cluster for a given pattern (regex)"),
891 [ArgChoice(min=1, max=1, choices=["drain", "undrain", "info"])],
892 [], "drain|undrain|info", "Change queue properties"),
895 [ArgChoice(min=1, max=1, choices=["pause", "continue", "info"]),
896 ArgSuggest(min=0, max=1, choices=["30m", "1h", "4h"])],
898 "{pause <timespec>|continue|info}", "Change watcher properties"),
900 SetClusterParams, ARGS_NONE,
901 [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
902 NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
903 UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT,
904 NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT],
906 "Alters the parameters of the cluster"),
908 RenewCrypto, ARGS_NONE,
909 [NEW_CLUSTER_CERT_OPT, NEW_RAPI_CERT_OPT, RAPI_CERT_OPT,
910 NEW_CONFD_HMAC_KEY_OPT, FORCE_OPT,
911 NEW_CLUSTER_DOMAIN_SECRET_OPT, CLUSTER_DOMAIN_SECRET_OPT],
913 "Renews cluster certificates, keys and secrets"),
917 if __name__ == '__main__':
918 sys.exit(GenericMain(commands, override={"tag_type": constants.TAG_CLUSTER}))