aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/SECTests/connect.py
diff options
context:
space:
mode:
authorlukehinds <lukehinds@gmail.com>2016-05-26 19:53:28 +0100
committerJose Lausuch <jose.lausuch@ericsson.com>2016-05-31 13:14:11 +0000
commitc6caba5fd5261909ce0ab26b9b9dabbd35e0bf00 (patch)
tree191036d84f706e5a5650bf3f63b99de5a997547b /testcases/SECTests/connect.py
parent03a5887906ce8c757f8b646b8ec65bf56f44829c (diff)
Add Apex based security scan code
JIRA: FUNCTEST-169 Performs a SCAP based security scan of all overcloud nodes, followed by report download to functest dashboard Change-Id: I9058227e19c0877e5f8913931febdd667a908cdd Signed-off-by: lukehinds <lukehinds@gmail.com>
Diffstat (limited to 'testcases/SECTests/connect.py')
-rw-r--r--testcases/SECTests/connect.py103
1 files changed, 0 insertions, 103 deletions
diff --git a/testcases/SECTests/connect.py b/testcases/SECTests/connect.py
deleted file mode 100644
index f766eabf9..000000000
--- a/testcases/SECTests/connect.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2016 Red Hat
-# Luke Hinds (lhinds@redhat.com)
-# This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# 0.1: OpenSCAP paramiko connection functions
-
-import paramiko
-
-__version__ = 0.1
-__author__ = 'Luke Hinds (lhinds@redhat.com)'
-__url__ = 'http:/https://wiki.opnfv.org/display/security'
-
-
-class connectionManager:
- def __init__(self, hostname, user, password, *args):
- self.hostname = hostname
- self.user = user
- self.password = password
- self.args = args
-
- def remotescript(self):
- localpath = self.args[0]
- remotepath = self.args[1]
- com = self.args[2]
-
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(self.hostname, 22, self.user, self.password)
-
- sftp = client.open_sftp()
- sftp.put(localpath, remotepath)
-
- output = ""
- stdin, stdout, stderr = client.exec_command(com)
- stdout = stdout.readlines()
- sftp.remove(remotepath)
- client.close()
-
- # Spool it back (can be improved at later point)
- for line in stdout:
- output = output + line
- if output != "":
- return output
-
- def remotecmd(self):
- com = self.args[0]
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(self.hostname, 22, self.user, self.password)
- output = ""
- stdin, stdout, stderr = client.exec_command(com)
- stdout = stdout.readlines()
- client.close()
-
- # Spool it back (can be improved at later point)
- for line in stdout:
- output = output + line
- if output != "":
- return output
- else:
- print "There was no output for this command"
-
- def run_tool(self):
- # dist = self.args[0]
- # report = self.args[1]
- com = self.args[2]
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(self.hostname, 22, self.user, self.password)
-
- output = ""
- stdin, stdout, stderr = client.exec_command(com)
- stdout = stdout.readlines()
- client.close()
-
- # Spool it back (can be improved at later point)
- for line in stdout:
- output = output + line
- if output != "":
- return output
-
- def download_reports(self):
- dl_folder = self.args[0]
- reportfile = self.args[1]
- reportname = self.args[2]
- resultsname = self.args[3]
- transport = paramiko.Transport((self.hostname, 22))
- transport.connect(username=self.user, password=self.password)
- sftp = paramiko.SFTPClient.from_transport(transport)
-
- # Download the reportfile (html) and the results (xml)
- print 'Downloading \"{0}\"...'.format(reportname)
- sftp.get(reportfile, ('{0}/{1}'.format(dl_folder, reportname)))
- print 'Downloading \"{0}\"...'.format(resultsname)
- sftp.get(reportfile, ('{0}/{1}'.format(dl_folder, resultsname)))
- sftp.close()
- transport.close()