summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/features/marker/utils/syncdaemon/gsyncd.py10
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py25
2 files changed, 32 insertions, 3 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/gsyncd.py b/xlators/features/marker/utils/syncdaemon/gsyncd.py
index d02b05d0c..c414c2a9c 100644
--- a/xlators/features/marker/utils/syncdaemon/gsyncd.py
+++ b/xlators/features/marker/utils/syncdaemon/gsyncd.py
@@ -194,14 +194,20 @@ def main_i():
remote = resource.parse_url(args[1])
if not local.can_connect_to(remote):
raise RuntimeError("%s cannot work with %s" % (local.path, remote and remote.path))
- peers = [x.url for x in [local, remote] if x]
+ pa = ([], [])
+ canon = [False, True]
+ for x in (local, remote):
+ if x:
+ for i in range(2):
+ pa[i].append(x.get_url(canonical=canon[i]))
+ peers, canon_peers = pa
gconf.__dict__.update(defaults.__dict__)
if not 'config_file' in rconf:
rconf['config_file'] = os.path.join(os.path.dirname(sys.argv[0]), "conf/gsyncd.conf")
cfg = ConfigParser.RawConfigParser({}, dict)
cfg.read(rconf['config_file'])
- for sect in ('global', 'peers ' + ' '.join(peers)):
+ for sect in ('global', 'peers ' + ' '.join(canon_peers)):
if cfg.has_section(sect):
gconf.__dict__.update(cfg._sections[sect])
gconf.__dict__.update(opts.__dict__)
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index 052c96ed3..3aaca02c0 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -6,6 +6,7 @@ import time
import errno
import struct
import select
+import socket
import logging
import tempfile
import threading
@@ -263,9 +264,19 @@ class AbstractUrl(object):
def scheme(self):
return type(self).__name__.lower()
+ def canonical_path(self):
+ return self.path
+
+ def get_url(self, canonical=False):
+ if canonical:
+ pa = self.canonical_path()
+ else:
+ pa = self.path
+ return "://".join((self.scheme(), pa))
+
@property
def url(self):
- return "://".join((self.scheme(), self.path))
+ return self.get_url()
### Concrete resource classes ###
@@ -308,6 +319,9 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):
def __init__(self, path):
self.host, self.volume = sup(self, path, '^(%s):(.+)' % HostRX.pattern)
+ def canonical_path(self):
+ return ':'.join([socket.gethostbyname(self.host), self.volume])
+
def can_connect_to(self, remote):
return True
@@ -353,6 +367,15 @@ class SSH(AbstractUrl, SlaveRemote):
'^((?:%s@)?%s):(.+)' % tuple([ r.pattern for r in (UserRX, HostRX) ]))
self.inner_rsc = parse_url(inner_url)
+ def canonical_path(self):
+ m = re.match('([^@]+)@(.+)', self.remote_addr)
+ if m:
+ u, h = m.groups()
+ else:
+ u, h = os.getlogin(), self.remote_addr
+ remote_addr = '@'.join([u, socket.gethostbyname(h)])
+ return ':'.join([remote_addr, self.inner_rsc.get_url(canonical=True)])
+
def can_connect_to(self, remote):
return False