Created
May 27, 2018 23:49
-
-
Save minskmaz/6b88d45631d47d27f19fce30e0a956da to your computer and use it in GitHub Desktop.
get your mitogen on - Mitogen, an infrastructure code baseline that sucks less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mitogen.master | |
import mitogen.utils | |
import logging | |
broker = mitogen.master.Broker() | |
router = mitogen.master.Router(broker) | |
def my_first_function(): | |
try: | |
import socket | |
print(socket.gethostname()) | |
except mitogen.core.CallError, e: | |
print 'Call failed:', str(e) | |
def main(router): | |
trace_aws = router.ssh( | |
username='ec2-user', | |
hostname='ec2-at-some-ip-addr.compute-1.amazonaws.com' | |
) | |
local = router.local() | |
try: | |
local.call(my_first_function) | |
trace_aws.call(my_first_function) | |
finally: | |
broker.shutdown() | |
if __name__ == '__main__': | |
mitogen.utils.log_to_file() | |
mitogen.utils.run_with_router(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment