[X2Go-Commits] x2gobroker.git - master (branch) updated: 0.0.2.3-42-gd149ad7

X2Go dev team git-admin at x2go.org
Wed Oct 2 11:03:35 CEST 2013


The branch, master has been updated
       via  d149ad7c51dcedacf68fea315ef281b0a543ffa4 (commit)
      from  70cd5e294a5c10f36c68496ed534ffbecafbb087 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d149ad7c51dcedacf68fea315ef281b0a543ffa4
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Oct 2 11:03:25 2013 +0200

    Let an ICMP ping request precede the SSH ping command. This notably reduces timeout duration if the host running the queried broker agent is down).

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog    |    3 +++
 x2gobroker/agent.py |   34 +++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 6d392a6..2772c85 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,9 @@ x2gobroker (0.0.3.0-0~x2go1) UNRELEASED; urgency=low
     - Provide a test function that checks if the basic broker agent setup
       (SSH private/public key pair) is available. If not, no SSH broker
       usage will be attempted.
+    - Let an ICMP ping request precede the SSH ping command. This notably
+      reduces timeout duration if the host running the queried broker agent
+      is down).
   * /debian/control:
     + Replace LDAP support with session brokerage support in LONG_DESCRIPTION.
   * /debian/x2gobroker-agent.dirs:
diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py
index e46c99e..be7b0e5 100644
--- a/x2gobroker/agent.py
+++ b/x2gobroker/agent.py
@@ -54,6 +54,7 @@ class delayed_execution(threading.Thread):
         self.agent_func(**self.kwargs)
 
 
+
 def has_remote_broker_agent_setup():
     """\
     Peform some integrity checks that may indicate that a remote
@@ -162,6 +163,35 @@ def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None)
         raise x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException('Query to remote X2Go Broker Agent (user: {user}, hostname: {hostname}, port: {port}) failed'.format(user=remote_username, hostname=remote_hostname, port=remote_port))
 
 
+def icmp_ping(hostname):
+    """\
+    Perform an ICMP ping to the requested hostname.
+
+    param hostname: name of the host that shall be pinged
+    type hostname: C{unicode}
+
+    @raise X2GoBrokerAgentException: raised if host is down or unresolvable via DNS.
+
+    """
+    # Detect the IP protocol version...
+    try:
+        dns_query = socket.getaddrinfo(hostname, None, socket.AF_INET6)
+        ping_cmd = "ping6"
+    except socket.gaierror:
+        try:
+            dns_query = socket.getaddrinfo(hostname, None, socket.AF_INET)
+            ping_cmd = "ping"
+        except socket.gaierror:
+            # we can't find a valid address for this host, so returning a failure...
+            return False
+
+    # do the actual ping...
+    if os.system(ping_cmd + " -c 1 -w2 " + hostname + " > /dev/null 2>&1") != 0:
+        return False
+
+    return True
+
+
 def ping(query_mode='LOCAL', remote_agent=None):
     """\
     Ping X2Go Broker Agent.
@@ -176,7 +206,9 @@ def ping(query_mode='LOCAL', remote_agent=None):
     if unicode(query_mode).upper() == u'LOCAL':
         return call_local_broker_agent(username, mode='ping')
     else:
-        return call_remote_broker_agent(username, mode='ping', remote_agent=remote_agent)
+        return remote_agent is not None and \
+               icmp_ping(remote_agent['hostname']) and \
+               call_remote_broker_agent(username, mode='ping', remote_agent=remote_agent)
 
 
 def list_sessions(username, query_mode='LOCAL', remote_agent=None):


hooks/post-receive
-- 
x2gobroker.git (HTTP(S) Session broker for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).




More information about the x2go-commits mailing list