Last active
August 29, 2015 14:11
-
-
Save marshyski/18c81ae8838859df75e7 to your computer and use it in GitHub Desktop.
Fabric checking for port 22 socket connection
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
from fabric.api import sudo, env, put | |
import configuration as config | |
import socket, time | |
env.hosts = open('hosts_file', 'r').readline().rstrip() | |
env.user = config.USERNAME | |
env.port = '22' | |
env.key_filename = config.KEY_FILE | |
env.warn_only = True | |
s = socket.socket() | |
while True: | |
try: | |
s.connect((env.hosts, 22)) | |
break | |
except Exception: | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment