Use the python logging module to log.
Add logs for vsg health checks.
Change-Id: I290e569c05113c88adc89d941085b1d17ceaafbb
diff --git a/src/test/utils/CordTestUtils.py b/src/test/utils/CordTestUtils.py
index 59b785d..7621f13 100644
--- a/src/test/utils/CordTestUtils.py
+++ b/src/test/utils/CordTestUtils.py
@@ -3,6 +3,12 @@
import fcntl
import struct
import os
+import logging
+
+log_test = logging.getLogger('cordTester')
+test_consolehandler = logging.StreamHandler()
+#test_consolehandler.setFormatter(logging.Formatter("%(levelname)s:%(message)s"))
+log_test.addHandler(test_consolehandler)
# we use subprocess as commands.getstatusoutput would be deprecated
def getstatusoutput(cmd):
diff --git a/src/test/utils/VSGAccess.py b/src/test/utils/VSGAccess.py
index 392ebde..3d138df 100644
--- a/src/test/utils/VSGAccess.py
+++ b/src/test/utils/VSGAccess.py
@@ -4,6 +4,9 @@
from novaclient import client as nova_client
from SSHTestAgent import SSHTestAgent
from CordTestUtils import *
+from CordTestUtils import log_test as log
+
+log.setLevel('INFO')
class VSGAccess(object):
@@ -319,15 +322,21 @@
if self.ip is None:
return True
cmd = 'ping -c 1 {}'.format(self.ip)
+ log.info('Pinging VSG %s at IP %s' %(self.name, self.ip))
st, _ = self.run_cmd_compute(cmd)
+ log.info('VSG %s at IP %s is %s' %(self.name, self.ip, 'reachable' if st == True else 'unreachable'))
return st
def check_access(self):
if self.ip is None:
- return False
+ return True
ssh_agent = SSHTestAgent(self.compute_node)
st, _ = ssh_agent.run_cmd('ls', timeout=10)
if st == False:
+ log.error('Compute node at %s is not accessible' %(self.compute_node))
return st
+ log.info('Checking if VSG at %s is accessible from compute node %s' %(self.ip, self.compute_node))
st, _ = ssh_agent.run_cmd('ssh {} ls'.format(self.ip), timeout=30)
+ if st == True:
+ log.info('OK')
return st
diff --git a/src/test/vsg/vsgTest.py b/src/test/vsg/vsgTest.py
index 5ad8d3e..db8dd36 100644
--- a/src/test/vsg/vsgTest.py
+++ b/src/test/vsg/vsgTest.py
@@ -15,14 +15,13 @@
import time
import os
from nose.tools import *
-from scapy.all import *
from CordTestUtils import *
from OltConfig import OltConfig
from onosclidriver import OnosCliDriver
from SSHTestAgent import SSHTestAgent
from CordLogger import CordLogger
from VSGAccess import VSGAccess
-
+from CordTestUtils import log_test as log
log.setLevel('INFO')
class vsg_exchange(CordLogger):