From d8ca1bcf28298d50493a8cb2c7fbd2c57e9f7987 Mon Sep 17 00:00:00 2001 From: Luke Hinds Date: Wed, 8 Jun 2016 16:59:44 +0100 Subject: Fixes incorrect parenthesis format & adds ft_logger import JIRA: FUNCTEST-302 Change-Id: Id83077a1b1376f726ea8abd4a97e5b705c22f9cc Signed-off-by: Luke Hinds --- testcases/security_scan/connect.py | 53 ++++++++++++++++---------------- testcases/security_scan/security_scan.py | 2 ++ 2 files changed, 28 insertions(+), 27 deletions(-) (limited to 'testcases/security_scan') diff --git a/testcases/security_scan/connect.py b/testcases/security_scan/connect.py index 9430e9a7..60caade0 100644 --- a/testcases/security_scan/connect.py +++ b/testcases/security_scan/connect.py @@ -16,15 +16,14 @@ import paramiko import functest.utils.functest_logger as ft_logger -# Enable below for connection debugging -# paramiko.util.log_to_file('ssh.log') - # add installer IP from env INSTALLER_IP = os.getenv('INSTALLER_IP') -# Set up logger +# Set up loggers logger = ft_logger.Logger("security_scan").getLogger() +paramiko.util.log_to_file("/var/log/paramiko.log") + class novaManager: def __init__(self, *args): @@ -38,13 +37,13 @@ class novaManager: client.connect(INSTALLER_IP, port=22, username='stack') except paramiko.SSHException: logger.error("Password is invalid for " - "undercloud host: {0}").format(INSTALLER_IP) + "undercloud host: {0}".format(INSTALLER_IP)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "undercloud host: {0}").format(INSTALLER_IP) + "undercloud host: {0}".format(INSTALLER_IP)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(INSTALLER_IP) + "undercloud host: {0}".format(INSTALLER_IP)) stdin, stdout, stderr = client.exec_command(com) return stdout.read() @@ -69,13 +68,13 @@ class connectionManager: client.connect(INSTALLER_IP, port=22, username='stack') except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) transport = client.get_transport() local_addr = ('127.0.0.1', 0) @@ -92,13 +91,13 @@ class connectionManager: sftp.put(localpath, remotepath) except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) output = "" stdin, stdout, stderr = remote_client.exec_command(com) @@ -123,13 +122,13 @@ class connectionManager: client.connect(INSTALLER_IP, port=22, username='stack') except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) transport = client.get_transport() local_addr = ('127.0.0.1', 0) # 0 denotes choose random port @@ -144,13 +143,13 @@ class connectionManager: key_filename=self.user_key, sock=channel) except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) chan = remote_client.get_transport().open_session() chan.get_pty() @@ -173,13 +172,13 @@ class connectionManager: client.connect(INSTALLER_IP, port=22, username='stack') except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) transport = client.get_transport() local_addr = ('127.0.0.1', 0) # 0 denotes choose random port @@ -194,18 +193,18 @@ class connectionManager: key_filename=self.user_key, sock=channel) except paramiko.SSHException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except paramiko.AuthenticationException: logger.error("Authentication failed for " - "host: {0}").format(self.host) + "host: {0}".format(self.host)) except socket.error: logger.error("Socker Connection failed for " - "undercloud host: {0}").format(self.host) + "undercloud host: {0}".format(self.host)) # Download the reports sftp = remote_client.open_sftp() - logger.info('Downloading \"{0}\"...\n').format(reportname) + logger.info("Downloading \"{0}\"...\n".format(reportname)) sftp.get(reportfile, ('{0}/{1}'.format(dl_folder, reportname))) - logger.info('Downloading \"{0}\"...\n').format(resultsname) + logger.info("Downloading \"{0}\"...\n".format(resultsname)) sftp.get(reportfile, ('{0}/{1}'.format(dl_folder, resultsname))) sftp.close() transport.close() diff --git a/testcases/security_scan/security_scan.py b/testcases/security_scan/security_scan.py index f7f02cd9..25b5b292 100644 --- a/testcases/security_scan/security_scan.py +++ b/testcases/security_scan/security_scan.py @@ -22,6 +22,8 @@ from keystoneclient.auth.identity import v2 from keystoneclient import session from novaclient import client +import functest.utils.functest_logger as ft_logger + __version__ = 0.1 __author__ = 'Luke Hinds (lhinds@redhat.com)' __url__ = 'https://wiki.opnfv.org/display/functest/Functest+Security' -- cgit 1.2.3-korg