[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
Thu Jul 7 10:01:51 CDT 2011


branch "review" has been updated
       via  9c755d051d316bcc13907ab694aa30cf9b04853b (commit)
      from  2c2ebaa603732976dd438c1f6bec473700aee9df (commit)

Summary of changes:
 remote.py |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit 9c755d051d316bcc13907ab694aa30cf9b04853b
Author: Darren Sessions <dsessions at digium.com>
Date:   Thu Jul 7 10:01:46 2011 -0500

    Modified the network information function to obtain the mac address in Linux as well. The mac address is required for HA configuration and failover.

diff --git a/remote.py b/remote.py
index 33d8b5a..0a8eed5 100755
--- a/remote.py
+++ b/remote.py
@@ -30,6 +30,7 @@ arch = platform.machine()
 plat = platform.system()
 ipv4addr = None
 ipv6addr = None
+macaddr = None
 processList = {}
 
 class RemoteManagement(object):
@@ -373,30 +374,30 @@ class RemoteManagement(object):
         return {'success':True,'logArtifactFile':logArtifactFile}
 
 
-def discoverIps():
-    def tryToGetIP(ipv, cmd, inetStr, sed):
+def discoverNetworkData():
+    def getNetworkData(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','/f/d','-e','s/ *inet *//g','-e','s/\/.*$//g']),
-            '[%s]' % tryToGetIP('ipv6',['ip','addr','show','%s' % iface], 'inet6', ['sed','-e','/fe80/d','-e','s/ *inet6 *//g','-e','s/\/64.*$//g']))
+        return (getNetworkData('ipv4',['ip','addr','show','%s' % iface], 'inet', ['sed','-e','/f/d','-e','s/ *inet *//g','-e','s/\/.*$//g']),
+            '[%s]' % getNetworkData('ipv6',['ip','addr','show','%s' % iface], 'inet6', ['sed','-e','/fe80/d','-e','s/ *inet6 *//g','-e','s/\/64.*$//g']),
+            getNetworkData('ipv4',['ip','addr','show','%s' % iface], 'link/ether', ['sed','-e','s/ *link\/ether *//g','-e','s/ brd.*$//g']))
     elif plat == 'Darwin':
-        return (tryToGetIP('ipv4',['ifconfig','%s' % iface], 'inet ', ['sed','-e','s/\t*inet *//g','-e','s/netmask.*$//g','-e','s/\ //g']),
-            '[%s]' % tryToGetIP('ipv6',['ifconfig','%s' % iface], 'inet6', ['sed','-e','/fe80/d','-e','s/\t *inet6 *//g','-e','s/prefixlen.*$//g','-e','s/\ //g']))
+        return (getNetworkData('ipv4',['ifconfig','%s' % iface], 'inet ', ['sed','-e','s/\t*inet *//g','-e','s/netmask.*$//g','-e','s/\ //g']),
+            '[%s]' % getNetworkData('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()
+    ipv4addr, ipv6addr, macaddr = discoverNetworkData(iface)
     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