Commit 74adc100 authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow cluster copy file over the replication net



This patch introduces the option “--use-replication-network” for the
cluster copyfile functionality, which is useful if the primary and
secondary network are significantly different (see issue 32).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e9e26bb3
...@@ -123,6 +123,7 @@ __all__ = [ ...@@ -123,6 +123,7 @@ __all__ = [
"TAG_SRC_OPT", "TAG_SRC_OPT",
"TIMEOUT_OPT", "TIMEOUT_OPT",
"USEUNITS_OPT", "USEUNITS_OPT",
"USE_REPL_NET_OPT",
"VERBOSE_OPT", "VERBOSE_OPT",
"VG_NAME_OPT", "VG_NAME_OPT",
"YES_DOIT_OPT", "YES_DOIT_OPT",
...@@ -890,6 +891,12 @@ NEW_CONFD_HMAC_KEY_OPT = cli_option("--new-confd-hmac-key", ...@@ -890,6 +891,12 @@ NEW_CONFD_HMAC_KEY_OPT = cli_option("--new-confd-hmac-key",
help=("Create a new HMAC key for %s" % help=("Create a new HMAC key for %s" %
constants.CONFD)) constants.CONFD))
USE_REPL_NET_OPT = cli_option("--use-replication-network",
dest="use_replication_network",
help="Whether to use the replication network"
" for talking to the nodes",
action="store_true", default=False)
def _ParseArgs(argv, commands, aliases): def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments. """Parser for the command line arguments.
......
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
<cmdsynopsis> <cmdsynopsis>
<command>copyfile</command> <command>copyfile</command>
<arg>--use-replication-network</arg>
<arg>-n <replaceable>node</replaceable></arg> <arg>-n <replaceable>node</replaceable></arg>
<arg choice="req"><replaceable>file</replaceable></arg> <arg choice="req"><replaceable>file</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
...@@ -150,6 +151,10 @@ ...@@ -150,6 +151,10 @@
<option>-n</option> is not given at all, the file will be <option>-n</option> is not given at all, the file will be
copied to all nodes. copied to all nodes.
Passing the <option>--use-replication-network</option> option
will cause the copy to be done over the replication network
(only matters if the primary/secondary IPs are different).
Example: Example:
<screen> <screen>
# gnt-cluster -n node1.example.com -n node2.example.com copyfile /tmp/test # gnt-cluster -n node1.example.com -n node2.example.com copyfile /tmp/test
......
...@@ -300,12 +300,10 @@ def ClusterCopyFile(opts, args): ...@@ -300,12 +300,10 @@ def ClusterCopyFile(opts, args):
cl = GetClient() cl = GetClient()
myname = utils.GetHostInfo().name
cluster_name = cl.QueryConfigValues(["cluster_name"])[0] cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
results = GetOnlineNodes(nodes=opts.nodes, cl=cl) results = GetOnlineNodes(nodes=opts.nodes, cl=cl, filter_master=True,
results = [name for name in results if name != myname] secondary_ips=opts.use_replication_network)
srun = ssh.SshRunner(cluster_name=cluster_name) srun = ssh.SshRunner(cluster_name=cluster_name)
for node in results: for node in results:
...@@ -749,7 +747,7 @@ commands = { ...@@ -749,7 +747,7 @@ commands = {
"", "Shows the cluster master"), "", "Shows the cluster master"),
'copyfile': ( 'copyfile': (
ClusterCopyFile, [ArgFile(min=1, max=1)], ClusterCopyFile, [ArgFile(min=1, max=1)],
[NODE_LIST_OPT], [NODE_LIST_OPT, USE_REPL_NET_OPT],
"[-n node...] <filename>", "Copies a file to all (or only some) nodes"), "[-n node...] <filename>", "Copies a file to all (or only some) nodes"),
'command': ( 'command': (
RunClusterCommand, [ArgCommand(min=1)], RunClusterCommand, [ArgCommand(min=1)],
......
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