#!/usr/bin/env python
#
import mitogen.master
import mitogen.select
import subprocess
import logging
import mitogen.utils
import time
import osdef read_local():
with open('/Users/Redheat/Downloads/cmake-3.12.1-Darwin-x86_64.dmg','rb') as f:
return f.read()def main(router):
local = router.local(debug=True)
file_content = local.call(read_local)
hostnames = ['192.168.101.25', '192.168.101.27', '192.168.101.29']
remote_hosts = [router.ssh(hostname=hostname, username='root', check_host_keys='accept') for hostname in hostnames]
rc = [remote_host.call(write_local,file_content) for remote_host in remote_hosts]
print('Command return code was:', rc)def write_local(file_content):
with open('/tmp/cmake-3.12.1-Darwin-x86_64.dmg', 'wb') as f:
f.write(file_content)if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
mitogen.utils.run_with_router(main)