示例#1
0
文件: ssh_utils.py 项目: zyclove/gpdb
    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
示例#2
0
    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
示例#3
0
    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
示例#4
0
    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