ssh_tools.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:OpsManage 作者: welliamcao 项目源码 文件源码
def thread(self,model,queue,cmd=None,
               cmd_args=None,localPath=None,
               remotePath=None,remoteFile=None):           
        if model == 'command':         
            self.sshConn = paramiko.SSHClient()
            self.sshConn.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
            self.sshConn.connect(hostname = self.hostname,port=self.port,
                                 username=self.username, password=self.password)          
            self.threads = SSH(ssh=self.sshConn,hostname=self.hostname,
                           queue=queue,model=model,cmd=cmd,
                           cmd_args=cmd_args,localPath=localPath,
                           remotePath=remotePath,remoteFile=remoteFile)

        elif model in ['upload','download']:
            self.sshConn = paramiko.Transport((self.hostname,self.port))
            self.sshConn.connect(username=self.username, password=self.password)         
            self.threads = SSH(ssh=self.sshConn,hostname=self.hostname,
                           queue=queue,model=model,cmd=cmd,
                           cmd_args=cmd_args,localPath=localPath,
                           remotePath=remotePath,remoteFile=remoteFile)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号