From bf64057ec2cc2dac2be15d0eb06b1c41ff27f293 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 1 Sep 2016 13:52:28 +0200 Subject: Switch print to logging.info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It follows the recommendations described in the next review [1]. [1] https://gerrit.opnfv.org/gerrit/#/c/19795/ Change-Id: Ie7ce28451122c554f135caad068844c0303deaeb Signed-off-by: Cédric Ollivier (cherry picked from commit 0ae5f5fc64868e8c68eb330fa5aa219abdbdfee0) --- .../ONOS/Teston/adapters/environment.py | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'testcases/Controllers/ONOS/Teston/adapters/environment.py') diff --git a/testcases/Controllers/ONOS/Teston/adapters/environment.py b/testcases/Controllers/ONOS/Teston/adapters/environment.py index 231677333..f2755b669 100644 --- a/testcases/Controllers/ONOS/Teston/adapters/environment.py +++ b/testcases/Controllers/ONOS/Teston/adapters/environment.py @@ -15,17 +15,21 @@ Description: # """ -import os -import time import pexpect +import pxssh import re +import os import sys -import pxssh +import time + from connection import connection +import functest.utils.functest_logger as ft_logger class environment(connection): + logger = ft_logger.Logger("environment").getLogger() + def __init__(self): connection.__init__(self) self.loginfo = connection() @@ -39,9 +43,9 @@ class environment(connection): handle: current working handle codeurl: clone code url """ - print "Now loading test codes! Please wait in patient..." + self.logger.info("Now loading test codes! Please wait in patient...") originalfolder = sys.path[0] - print originalfolder + self.logger.info(originalfolder) gitclone = handle gitclone.sendline("git clone " + codeurl) index = 0 @@ -82,7 +86,7 @@ class environment(connection): parameters: handle(input): current working handle """ - print "Now Cleaning test environment" + self.logger.info("Now Cleaning test environment") handle.sendline("sudo apt-get install -y mininet") handle.prompt() handle.sendline("sudo pip install configobj") @@ -102,7 +106,7 @@ class environment(connection): cmd(input): onos-push-keys xxx(xxx is device) password(input): login in password """ - print "Now Pushing Onos Keys:" + cmd + self.logger.info("Now Pushing Onos Keys:" + cmd) Pushkeys = handle Pushkeys.sendline(cmd) Result = 0 @@ -121,7 +125,7 @@ class environment(connection): break time.sleep(2) Pushkeys.prompt() - print "Done!" + self.logger.info("Done!") def SetOnosEnvVar(self, handle, masterpass, agentpass): """ @@ -131,13 +135,14 @@ class environment(connection): masterpass: scripts running server's password agentpass: onos cluster&compute node password """ - print "Now Setting test environment" + self.logger.info("Now Setting test environment") for host in self.hosts: - print "try to connect " + str(host) + self.logger.info("try to connect " + str(host)) result = self.CheckSshNoPasswd(host) if not result: - print ("ssh login failed,try to copy master publickey" + - "to agent " + str(host)) + self.logger.info( + "ssh login failed,try to copy master publickey" + + "to agent " + str(host)) self.CopyPublicKey(host) self.OnosPushKeys(handle, "onos-push-keys " + self.OCT, masterpass) self.OnosPushKeys(handle, "onos-push-keys " + self.OC1, agentpass) @@ -173,7 +178,7 @@ class environment(connection): user: onos&compute node user password: onos&compute node password """ - print "Now Changing ONOS name&password" + self.logger.info("Now Changing ONOS name&password") filepath = self.home + '/onos/tools/build/envDefaults' line = open(filepath, 'r').readlines() lenall = len(line) - 1 @@ -187,7 +192,7 @@ class environment(connection): NewFile = open(filepath, 'w') NewFile.writelines(line) NewFile.close - print "Done!" + self.logger.info("Done!") def ChangeTestCasePara(self, testcase, user, password): """ @@ -196,7 +201,7 @@ class environment(connection): user: onos&compute node user password: onos&compute node password """ - print "Now Changing " + testcase + " name&password" + self.logger.info("Now Changing " + testcase + " name&password") if self.masterusername == 'root': filepath = '/root/' else: @@ -232,7 +237,7 @@ class environment(connection): login.sendline('ls -l') # match prompt login.prompt() - print("SSH login " + ipaddr + " success!") + self.logger.info("SSH login " + ipaddr + " success!") return login def SSHRelease(self, handle): @@ -256,7 +261,7 @@ class environment(connection): str(publickey) + ">>/root/.ssh/authorized_keys\'") tmphandle.prompt() self.SSHRelease(tmphandle) - print "Add OCT PublicKey to " + host + " success" + self.logger.info("Add OCT PublicKey to " + host + " success") def OnosEnvSetup(self, handle): """ -- cgit 1.2.3-korg