[asterisk-scf-commits] asterisk-scf/integration/testsuite.git branch "review" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 25 13:20:15 CDT 2011


branch "review" has been updated
       via  04992c28c8f7a68e3edab8219f8d5f162fe3bac1 (commit)
      from  cb204490bec2a36e5b2eb31e4dfd5f1a92538318 (commit)

Summary of changes:
 remote.py |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit 04992c28c8f7a68e3edab8219f8d5f162fe3bac1
Author: Darren Sessions <dsessions at digium.com>
Date:   Wed May 25 13:20:12 2011 -0500

    Added IP address discovery support for Linux and Darwin in the remote script to ease failover support.

diff --git a/remote.py b/remote.py
index 6072048..d1c109e 100755
--- a/remote.py
+++ b/remote.py
@@ -20,10 +20,13 @@ import xmlrpclib
 import subprocess
 import SimpleXMLRPCServer
 
+iface = 'eth0'
+
 cwd = os.path.dirname(os.path.realpath(__file__))
 arch = platform.machine()
 plat = platform.system()
-
+ipv4addr = None
+ipv6addr = None
 processList = {}
 
 class RemoteManagement(object):
@@ -245,7 +248,30 @@ class RemoteManagement(object):
                     return prog
         return app
 
+def discoverIps():
+    def tryToGetIP(ipv, cmd, inetStr, sed):
+        results = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+        results = subprocess.Popen(['grep','%s' % inetStr], stdout=subprocess.PIPE, stdin=results.stdout)
+        results = subprocess.Popen(sed, stdout=subprocess.PIPE, stdin=results.stdout)
+        results = subprocess.Popen(['tail','-n1'], stdout=subprocess.PIPE, stdin=results.stdout)
+        results = results.communicate()[0].rstrip('\n')
+        if results == '':
+            print '\n  Warning! %s does not have an %s address assigned to it. This will effect testing!\n' % (iface, ipv)
+            return None
+        else:
+            return results
+    if plat == 'Linux':
+        return (tryToGetIP('ipv4',['ip','addr','show','%s' % iface], 'inet', ['sed','-e','/fe/d','-e','s/ *inet *//g','-e','s/\/.*$//g']),
+            tryToGetIP('ipv6',['ip','addr','show','%s' % iface], 'inet6', ['sed','-e','/fe80/d','-e','s/ *inet6 *//g','-e','s/\/64.*$//g']))
+    elif plat == 'Darwin':
+        return (tryToGetIP('ipv4',['ifconfig','%s' % iface], 'inet ', ['sed','-e','s/\t*inet *//g','-e','s/netmask.*$//g','-e','s/\ //g']),
+            tryToGetIP('ipv6',['ifconfig','%s' % iface], 'inet6', ['sed','-e','/fe80/d','-e','s/\t *inet6 *//g','-e','s/prefixlen.*$//g','-e','s/\ //g']))
+    else:
+        print 'This platform is currently not supported.'
+        sys.exit(1)
+
 if __name__=='__main__':
+    (ipv4addr, ipv6addr) = discoverIps()
     server = SimpleXMLRPCServer.SimpleXMLRPCServer(('', 8000))
     server.register_instance(RemoteManagement())
     server.serve_forever()

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


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list