summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-02-07 20:42:23 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-10 22:17:50 -0800
commitebd7e1771c69a056f0456ff2dccac4319806f63b (patch)
tree8fe942f33f9928e176cb55c9c2b9b85d6181d3eb /xlators
parentd6363c595ace12a1bf9060dcd76a9e88e58d3db0 (diff)
syncdaemon: config revamp #2: implement canonicalized urls, use them in config file sections
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'xlators')
-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