[ONOS-7104]: Style fixes to the drivers directory in TestON
Change-Id: Ie151a956c15f1b1cc6ebc09a2e7474f8e4066459
diff --git a/TestON/drivers/common/api/dockerapidriver.py b/TestON/drivers/common/api/dockerapidriver.py
index 3fac610..1393e18 100644
--- a/TestON/drivers/common/api/dockerapidriver.py
+++ b/TestON/drivers/common/api/dockerapidriver.py
@@ -55,7 +55,7 @@
self.home = "/var/tmp"
self.handle = super( DockerApiDriver, self ).connect()
- self.dockerClient = Client(base_url='unix://var/run/docker.sock')
+ self.dockerClient = Client( base_url='unix://var/run/docker.sock' )
return self.handle
except Exception as e:
main.log.exception( e )
@@ -72,7 +72,7 @@
if imageDict[ 'RepoTags' ] is not None:
if len( imageDict[ 'RepoTags' ] ) > 1:
duplicateTagDetected = 1
- imageListToSend.append( imageDict['RepoTags'][0].encode('UTF8').split(':')[1] )
+ imageListToSend.append( imageDict[ 'RepoTags' ][ 0 ].encode( 'UTF8' ).split( ':' )[ 1 ] )
return imageListToSend, duplicateTagDetected
except Exception as e:
main.log.exception( e )
@@ -83,18 +83,18 @@
"""
try:
main.log.info( self.name +
- ": Pulling Docker image " + onosRepo + ":"+ onosTag )
- for line in self.dockerClient.pull( repository = onosRepo, \
- tag = onosTag, stream = True ):
- print "#",
- main.log.info(json.dumps(json.loads(line), indent =4))
+ ": Pulling Docker image " + onosRepo + ":" + onosTag )
+ for line in self.dockerClient.pull( repository = onosRepo,
+ tag = onosTag, stream = True ):
+ print "#",
+ main.log.info( json.dumps( json.loads( line ), indent =4 ))
- #response = json.dumps( json.load( pullResult ), indent=4 )
+ # response = json.dumps( json.load( pullResult ), indent=4 )
if re.search( "for onosproject/onos:" + onosTag, line ):
main.log.info( "onos docker image pulled is: " + line )
return main.TRUE
else:
- main.log.error( "Failed to download image from: " + onosRepo +":"+ onosTag )
+ main.log.error( "Failed to download image from: " + onosRepo + ":" + onosTag )
main.log.error( "Error respone: " )
main.log.error( line )
return main.FALSE
@@ -109,17 +109,17 @@
try:
main.log.info( self.name +
": Creating Docker container for node: " + onosNode )
- response = self.dockerClient.create_container( image=onosImage, \
- tty=True, name=onosNode, detach=True )
- #print response
- #print response.get("Id")
- #print response.get("Warnings")
- if( str( response.get("Warnings") ) == 'None' ):
- main.log.info( "Created container for node: " + onosNode + "; container id is: " + response.get("Id") )
- return ( main.TRUE, response.get("Id") )
+ response = self.dockerClient.create_container( image=onosImage,
+ tty=True, name=onosNode, detach=True )
+ # print response
+ # print response.get("Id")
+ # print response.get("Warnings")
+ if( str( response.get( "Warnings" ) ) == 'None' ):
+ main.log.info( "Created container for node: " + onosNode + "; container id is: " + response.get( "Id" ) )
+ return( main.TRUE, response.get( "Id" ) )
else:
main.log.info( "Noticed warnings during create" )
- return ( main.FALSE, null)
+ return( main.FALSE, null )
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
@@ -157,11 +157,11 @@
main.log.info( "Noticed warnings during stop" )
return main.FALSE
except errors.NotFound:
- main.log.info( ctName + " not found! Continue on tests...")
+ main.log.info( ctName + " not found! Continue on tests..." )
return main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- #main.cleanAndExit()
+ # main.cleanAndExit()
def dockerRestartCT( self, ctName ):
"""
@@ -181,27 +181,27 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def dockerCheckCTName( self, ctName):
+ def dockerCheckCTName( self, ctName ):
"""
Check Docker conatiner status
"""
try:
main.log.info( self.name +
": Checking Docker Status for CT with 'Names' " + ctName )
- namelist = [response["Names"] for response in self.dockerClient.containers(all=True) if not []]
- main.log.info("Name list is: " + str(namelist) )
- if( [ctName] in namelist):
+ namelist = [ response[ "Names" ] for response in self.dockerClient.containers( all=True ) if not [] ]
+ main.log.info( "Name list is: " + str( namelist ) )
+ if( [ ctName ] in namelist ):
main.log.info( "Container " + ctName + " exists" )
return main.TRUE
else:
main.log.info( "Container " + ctName + " does not exist" )
return main.FALSE
except errors.NotFound:
- main.log.warn( ctName + "not found! Continue with the tests...")
+ main.log.warn( ctName + "not found! Continue with the tests..." )
return main.FALSE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continue tests..." )
- #main.cleanAndExit()
+ # main.cleanAndExit()
def dockerRemoveCT( self, ctName ):
"""
@@ -215,15 +215,15 @@
main.log.info( "Removed container for node: " + ctName )
return main.TRUE
else:
- main.log.info( "Noticed warnings during Remove " + ctName)
+ main.log.info( "Noticed warnings during Remove " + ctName )
return main.FALSE
- main.log.exception(self.name + ": not found, continuing...")
+ main.log.exception( self.name + ": not found, continuing..." )
except errors.NotFound:
- main.log.warn( ctName + "not found! Continue with the tests...")
+ main.log.warn( ctName + "not found! Continue with the tests..." )
return main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continuing..." )
- #main.cleanAndExit()
+ # main.cleanAndExit()
def dockerRemoveImage( self, imageRepoTag=None ):
"""
@@ -234,13 +234,13 @@
main.log.info( "No docker image found" )
return rmResult
else:
- imageList = [ image["Id"] for image in self.dockerClient.images()
- if image["RepoTags"] is None
- or imageRepoTag in image["RepoTags"] ]
+ imageList = [ image[ "Id" ] for image in self.dockerClient.images()
+ if image[ "RepoTags" ] is None
+ or imageRepoTag in image[ "RepoTags" ] ]
for id in imageList:
try:
main.log.info( self.name + ": Removing Docker image " + id )
- response = self.dockerClient.remove_image(id, force = True)
+ response = self.dockerClient.remove_image( id, force = True )
if response is None:
main.log.info( "Removed Docker image: " + id )
rmResult = rmResult and main.TRUE
@@ -248,12 +248,12 @@
main.log.info( "Noticed warnings during Remove " + id )
rmResult = rmResult and main.FALSE
except errors.NotFound:
- main.log.warn( image + "not found! Continue with the tests...")
+ main.log.warn( image + "not found! Continue with the tests..." )
rmResult = rmResult and main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continuing..." )
rmResult = rmResult and main.FALSE
- #main.cleanAndExit()
+ # main.cleanAndExit()
return rmResult
def fetchLatestClusterFile( self, branch="master" ):
@@ -263,7 +263,7 @@
try:
command = "wget -N https://raw.githubusercontent.com/opennetworkinglab/\
onos/" + branch + "/tools/package/bin/onos-form-cluster"
- subprocess.call( command ) # output checks are missing for now
+ subprocess.call( command ) # output checks are missing for now
command = "chmod u+x " + "onos-form-cluster"
subprocess.call( command )
return main.TRUE
@@ -276,7 +276,7 @@
From ONOS cluster for IP addresses in onosIPs list
"""
try:
- onosIPs = " ".join(onosIPs)
+ onosIPs = " ".join( onosIPs )
command = "{}/onos-form-cluster -u {} -p {} {}".format( cmdPath,
user,
passwd,
@@ -285,7 +285,7 @@
if result == 0:
return main.TRUE
else:
- main.log.info("Something is not right in forming cluster>")
+ main.log.info( "Something is not right in forming cluster>" )
return main.FALSE
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
@@ -297,11 +297,10 @@
"""
try:
output = self.dockerClient.inspect_container( ctName )
- nodeIP = output['NetworkSettings']['IPAddress']
- main.log.info( " Docker IP " + str(nodeIP) )
- return str(nodeIP)
+ nodeIP = output[ 'NetworkSettings' ][ 'IPAddress' ]
+ main.log.info( " Docker IP " + str( nodeIP ) )
+ return str( nodeIP )
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
-