def checkSSH(self): '''Check that ssh to hostlist is okay.''' pool = WorkerPool() for h in self.list: cmd = Echo('ssh test', '', ctxt=REMOTE, remoteHost=h) pool.addCommand(cmd) pool.join() pool.haltWork() for cmd in pool.getCompletedItems(): if not cmd.get_results().wasSuccessful(): raise SSHError("Unable to ssh to '%s'" % cmd.remoteHost) return True
def removeBadHosts(self): ''' Update list of host to include only the host on which SSH was successful''' pool = WorkerPool() for h in self.list: cmd = Echo('ssh test', '', ctxt=REMOTE, remoteHost=h) pool.addCommand(cmd) pool.join() pool.haltWork() bad_hosts = [] working_hosts = [] for cmd in pool.getCompletedItems(): if not cmd.get_results().wasSuccessful(): bad_hosts.append(cmd.remoteHost) else: working_hosts.append(cmd.remoteHost) self.list = working_hosts[:] return bad_hosts