def init_test(config, hostname, build): isinstance(config, dict) PamTestCase.version = build PamTestCase.logger = logging.getLogger(hostname) PamTestCase.restconsole = config.get('restconsole') PamTestCase.unixhost = eval(config.get('unixhost','{}')) PamTestCase.params = eval(config.get('params','{}')) PamTestCase.spath = config.get("scriptpath") PamTestCase.setupinfo = eval(config.get("setupinfo",'{}')) osinfo = eval(config.get('osinfo','{}')) username = config.get("username", "root") password = config.get("password", "test123") params = PamTestCase.params # Open connections to test computer and peers PamTestCase.computer = create_computer_with_hostname(hostname, username, password, PamComputer, **osinfo) assert PamTestCase.computer.is_connected, 'There was a problem trying to connect to computer' assert setupcleanup("/tmp/%s" % PamTestCase.restconsole, "/tmp/%s" % PamTestCase.computer.hostname), 'Failure to start setup' if params: cps = params['console'] assert 0 == run_script(PamTestCase, 'setupPrivateNetwork.sh %s %s' % (cps['host'], params['privhost'])), 'Private Network Setup Failure' assert 0 == run_script(PamTestCase, "initAppliance.sh %s %s %s %s '%s' '%s'" % (cps['host'],cps['ip'],cps['netmask'],cps['gateway'],cps['resolvers'],cps['dnssearch'])) if PamTestCase.unixhost: PamTestCase.unixhostcomputer = create_computer_with_hostname(PamTestCase.unixhost['unixhost'], username, password, PamComputer, **PamTestCase.unixhost) assert PamTestCase.unixhostcomputer.is_connected, 'There was a problem trying to connect to computer' # Lock computer after mounts are setup # PamTestCase.computer.lock_on_computer() if PamTestCase.unixhost: PamTestCase.unixhostcomputer.lock_on_computer() return PamTestCase
def cleanup_test(): if docleanup("/tmp/%s" % PamTestCase.restconsole, "/tmp/%s" % PamTestCase.computer.hostname): PamTestCase.logger.info("Doing cleanup") s = PamTestCase.setupinfo if s: PamTestCase.logger.info("Found cleanup info") run_script(PamTestCase, "initAppliance.sh '%s'" % "' '".join([s['host'],s['ip'],s['netmask'],s['gateway'],s['resolvers'],s['dnssearch']])) run_script(PamTestCase, "teardownPrivateNetwork.sh '%s'" % s['privhost']) PamTestCase.logger.info("Closing connection to test facilitator computer") PamTestCase.computer.remove_lock_on_computer() PamTestCase.computer.closeConnection() PamTestCase.logger.info("Closing connection to Unix Host computer") if PamTestCase.unixhost: PamTestCase.unixhostcomputer.remove_lock_on_computer() PamTestCase.unixhostcomputer.closeConnection()