[WIP] ONOS-8091 Port python script and utilities to python3

Steps performed so far:
- Updated bash scripts and similar to explicitly invoke python3 (instead of python)
- Updated all python scripts using 2to3

Testing these changes will be a major headache because:
- different scripts are executed in different environments
  (e.g., Jenkins, cell servers, tutorial VMs, etc.)
- we don’t have control on all environments
- some environments we used to control have been dismissed
  (e.g., cell servers)

The approach for now is to focus on the essentials:
- Jenkins jobs for pre-merge and release

Test and fix everything else as the need arises.

Change-Id: I943e214760c9dea9a7ded0d47ef08adbc0ed0bec
diff --git a/tools/dev/mininet/onos.py b/tools/dev/mininet/onos.py
index f8e3703..8e22e5b 100755
--- a/tools/dev/mininet/onos.py
+++ b/tools/dev/mininet/onos.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 """
 onos.py: ONOS cluster and control network in Mininet
@@ -113,7 +113,7 @@
     # Get rid of stale junk
     for var in 'ONOS_CELL', 'ONOS_INSTANCES':
         env[ var ] = ''
-    for var in environ.keys():
+    for var in list(environ.keys()):
         if var.startswith( 'OC' ):
             env[ var ] = ''
     for index, node in enumerate( nodes, 1 ):
@@ -285,7 +285,7 @@
 
     def intfsDown( self ):
         """Bring all interfaces down"""
-        for intf in self.intfs.values():
+        for intf in list(self.intfs.values()):
             cmdOutput = intf.ifconfig( 'down' )
             # no output indicates success
             if cmdOutput:
@@ -293,7 +293,7 @@
 
     def intfsUp( self ):
         """Bring all interfaces up"""
-        for intf in self.intfs.values():
+        for intf in list(self.intfs.values()):
             cmdOutput = intf.ifconfig( 'up' )
             if cmdOutput:
                 error( "Error setting %s up: %s " % ( intf.name, cmdOutput ) )
@@ -338,7 +338,7 @@
     def memAvailable( self ):
         "Return available memory in KB (or -1 if we can't tell)"
         lines = open( '/proc/meminfo' ).read().strip().split( '\n' )
-        entries = map( str.split, lines )
+        entries = list(map( str.split, lines ))
         index = { entry[ 0 ]: entry for entry in entries }
         # Check MemAvailable if present
         default = ( None, '-1', 'kB' )
@@ -411,7 +411,7 @@
         "Update environment variables"
         cmd = ';'.join( ( 'export %s="%s"' % ( var, val )
                           if val else 'unset %s' % var )
-                        for var, val in envDict.iteritems() )
+                        for var, val in envDict.items() )
         self.cmd( cmd )
 
     def ucmd( self, *args, **_kwargs ):