summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon/subcmds.py
diff options
context:
space:
mode:
Diffstat (limited to 'geo-replication/syncdaemon/subcmds.py')
-rw-r--r--geo-replication/syncdaemon/subcmds.py68
1 files changed, 43 insertions, 25 deletions
diff --git a/geo-replication/syncdaemon/subcmds.py b/geo-replication/syncdaemon/subcmds.py
index 258dbb0b658..b8508532e30 100644
--- a/geo-replication/syncdaemon/subcmds.py
+++ b/geo-replication/syncdaemon/subcmds.py
@@ -1,6 +1,17 @@
-import logging
-
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
+# This file is part of GlusterFS.
+#
+# This file is licensed to you under your choice of the GNU Lesser
+# General Public License, version 3 or any later version (LGPLv3 or
+# later), or the GNU General Public License, version 2 (GPLv2), in all
+# cases as published by the Free Software Foundation.
+#
+
+from __future__ import print_function
from syncdutils import lf
+import logging
import gsyncdconfig as gconf
@@ -62,7 +73,11 @@ def subcmd_worker(args):
Popen.init_errhandler()
fcntl.fcntl(args.feedback_fd, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
local = GLUSTER("localhost", args.master)
- slavehost, slavevol = args.slave.split("::")
+ slave_url, slavevol = args.slave.split("::")
+ if "@" not in slave_url:
+ slavehost = args.resource_remote
+ else:
+ slavehost = "%s@%s" % (slave_url.split("@")[0], args.resource_remote)
remote = SSH(slavehost, slavevol)
remote.connect_remote()
local.connect()
@@ -82,26 +97,21 @@ def subcmd_slave(args):
local.service_loop()
-def subcmd_agent(args):
- import os
- from changelogagent import agent, Changelog
- from syncdutils import lf
-
- os.setsid()
- logging.debug(lf("RPC FD",
- rpc_fd=repr(args.rpc_fd)))
- return agent(Changelog(), args.rpc_fd)
-
-
def subcmd_voluuidget(args):
from subprocess import Popen, PIPE
import xml.etree.ElementTree as XET
ParseError = XET.ParseError if hasattr(XET, 'ParseError') else SyntaxError
- po = Popen(['gluster', '--xml', '--remote-host=' + args.host,
- 'volume', 'info', args.volname], bufsize=0,
- stdin=None, stdout=PIPE, stderr=PIPE)
+ cmd = ['gluster', '--xml', '--remote-host=' + args.host,
+ 'volume', 'info', args.volname]
+
+ if args.inet6:
+ cmd.append("--inet6")
+
+ po = Popen(cmd, bufsize=0,
+ stdin=None, stdout=PIPE, stderr=PIPE,
+ universal_newlines=True)
vix, err = po.communicate()
if po.returncode != 0:
@@ -224,7 +234,7 @@ def print_config(name, value, only_value=False, use_underscore=False):
if use_underscore:
name = name.replace("-", "_")
- print("%s:%s" % (name, val))
+ print(("%s:%s" % (name, val)))
def config_name_format(val):
@@ -243,21 +253,29 @@ def subcmd_config_get(args):
sys.stderr.write("Invalid config name \"%s\"\n" % args.name)
sys.exit(ERROR_CONFIG_INVALID)
- print_config(args.name, val, only_value=args.only_value,
+ print_config(args.name, val["value"], only_value=args.only_value,
use_underscore=args.use_underscore)
return
if args.json:
- out = {}
+ out = []
# Convert all values as string
- for k, v in all_config.items():
- out[k] = str(v)
-
- print(json.dumps(out))
+ for k in sorted(all_config):
+ v = all_config[k]
+ out.append({
+ "name": k,
+ "value": str(v["value"]),
+ "default": str(v["default"]),
+ "configurable": v["configurable"],
+ "modified": v["modified"]
+ })
+
+ print((json.dumps(out)))
return
for k in sorted(all_config):
- print_config(k, all_config[k], use_underscore=args.use_underscore)
+ print_config(k, all_config[k]["value"],
+ use_underscore=args.use_underscore)
def subcmd_config_check(args):