Commit b6e88032 authored by Michael Hanselmann's avatar Michael Hanselmann

gnt-cluster {command|copyfile}: Support per-group operations

This patch allows commands to be run on and files to be copied to all
nodes within a specific group.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 05484a24
......@@ -397,7 +397,8 @@ def ClusterCopyFile(opts, args):
cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
results = GetOnlineNodes(nodes=opts.nodes, cl=cl, filter_master=True,
srun = ssh.SshRunner(cluster_name=cluster_name)
for node in results:
......@@ -421,7 +422,7 @@ def RunClusterCommand(opts, args):
command = " ".join(args)
nodes = GetOnlineNodes(nodes=opts.nodes, cl=cl)
nodes = GetOnlineNodes(nodes=opts.nodes, cl=cl, nodegroup=opts.nodegroup)
cluster_name, master_node = cl.QueryConfigValues(["cluster_name",
......@@ -1288,11 +1289,11 @@ commands = {
"", "Shows the cluster master"),
'copyfile': (
ClusterCopyFile, [ArgFile(min=1, max=1)],
"[-n node...] <filename>", "Copies a file to all (or only some) nodes"),
'command': (
RunClusterCommand, [ArgCommand(min=1)],
"[-n node...] <command>", "Runs a command on all (or only some) nodes"),
'info': (
ShowClusterConfig, ARGS_NONE, [ROMAN_OPT],
......@@ -37,7 +37,7 @@ interpreted as stdin.
**command** [-n *node*] {*command*}
**command** [-n *node*] [-g *group*] {*command*}
Executes a command on all nodes. If the option ``-n`` is not given,
the command will be executed on all nodes, otherwise it will be
......@@ -46,6 +46,11 @@ times for running it on multiple nodes, like::
# gnt-cluster command -n -n date
The ``-g`` option can be used to run a command only on a specific node
group, e.g.::
# gnt-cluster command -g default date
The command is executed serially on the selected nodes. If the
master node is present in the list, the command will be executed
last on the master. Regarding the other nodes, the execution order
......@@ -67,12 +72,14 @@ and the command which will be executed will be ``ls -l /etc``.
**copyfile** [--use-replication-network] [-n *node*] {*file*}
| **copyfile** [--use-replication-network] [-n *node*] [-g *group*]
| {*file*}
Copies a file to all or to some nodes. The argument specifies the
source file (on the current system), the ``-n`` argument specifies
the target node, or nodes if the option is given multiple times. If
``-n`` is not given at all, the file will be copied to all nodes.
``-n`` is not given at all, the file will be copied to all nodes. The
``-g`` option can be used to only select nodes in a specific node group.
Passing the ``--use-replication-network`` option will cause the
copy to be done over the replication network (only matters if the
primary/secondary IPs are different). Example::
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment