def get_copy(host): '''copy a remote file to local file''' log(ok=True, msg="start to copy...") hostip = ENV[host]['ipaddress'] name = ENV[host]['username'] passwd = ENV[host]['password'] paths = ENV[host]['file'] repo = ENV[C_GIT]['repopath'] log(ok=True, msg="connect to %s user %s"%(hostip, name)) print "%s %s %s"%(hostip, name, passwd) client = ssh.open(hostip, name, passwd) ssh.scp(client, paths, repo) client.close() log(ok=True, msg="copy ok")
def get_copy_remote(host): '''copy a remote file to local file, which was copied from pc6248 to remote file. we must delete the remote file''' log(ok=True, msg="start to copy...") hostip = ENV[C_SSH]['ipaddress'] name = ENV[C_SSH]['username'] passwd = ENV[C_SSH]['password'] paths = ENV[host]['pc6428'] repo = ENV[C_GIT]['repopath'] # TODO: it is better if we have temporaer local files log(ok=True, msg="connect to %s user %s"%(hostip, name)) client = ssh.open(hostip, name, passwd) ssh.scp(client, paths, repo) for x in paths: ssh.remove(client, x['remotepath']) client.close() log(ok=True, msg="copy ok")