Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi.conf.in | 2 +-
src/kimchi/model/peers.py | 7 +++++--
src/kimchi/utils.py | 2 +-
src/kimchid.in | 5 +++--
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/kimchi.conf.in b/src/kimchi.conf.in
index 003ce4a..9f62ac0 100644
--- a/src/kimchi.conf.in
+++ b/src/kimchi.conf.in
@@ -27,7 +27,7 @@
#environment = production
# Federation feature: register Kimchi server on openSLP and discover peers
-# at the same network
+# in the same network. Check README-federation for more details.
#federation = off
# Max request body size in KB, default value is 4GB
diff --git a/src/kimchi/model/peers.py b/src/kimchi/model/peers.py
index 1bf74cb..a9f5fcd 100644
--- a/src/kimchi/model/peers.py
+++ b/src/kimchi/model/peers.py
@@ -38,7 +38,7 @@ class PeersModel(object):
cmd = ["slptool", "register",
"service:kimchid://%s" % self.url]
out, error, ret = run_command(cmd)
- if len(out) != 0:
+ if out and len(out) != 0:
kimchi_log.error("Unable to register server on openSLP."
" Details: %s" % out)
@@ -47,9 +47,12 @@ class PeersModel(object):
if config.get("server", "federation") == "off":
return []
- peers = []
cmd = ["slptool", "findsrvs", "service:kimchid"]
out, error, ret = run_command(cmd)
+ if ret != 0:
+ return []
+
+ peers = []
for server in out.strip().split("\n"):
match = re.match("service:kimchid://(.*?),.*", server)
peer = match.group(1)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index 68415dc..989e370 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -224,7 +224,7 @@ def run_command(cmd, timeout=None):
except Exception as e:
msg = "Failed to run command: %s." % " ".join(cmd)
msg = msg if proc is None else msg + "\n error code: %s."
- kimchi_log.error("%s\n %s", msg, e)
+ kimchi_log.error("%s %s", msg, e)
if proc:
return out, error, proc.returncode
diff --git a/src/kimchid.in b/src/kimchid.in
index 0746ba6..0a8dc1f 100644
--- a/src/kimchid.in
+++ b/src/kimchid.in
@@ -70,8 +70,9 @@ def main(options):
parser.add_option('--environment', default=runningEnv,
help="Running environment of kimchi server")
parser.add_option('--federation', default=federation,
- help="Register and discover Kimchi peers at the same "
- "network using openSLP")
+ help="Register and discover Kimchi peers in the same "
+ "network using openSLP. Check README-federation
for"
+ " more details.")
parser.add_option('--test', action='store_true',
help="Run server in mock model")
(options, args) = parser.parse_args()
--
1.9.3