Skip to content

Instantly share code, notes, and snippets.

@bcarpio
Created March 30, 2012 15:48
Show Gist options
  • Save bcarpio/2252382 to your computer and use it in GitHub Desktop.
Save bcarpio/2252382 to your computer and use it in GitHub Desktop.
__init__.py
from fabric.api import *
from fabric.operations import local,put
import paramiko
import socket
import subprocess
import os
import mongod
import puppet
def _is_host_up(host, port):
# Set the timeout
original_timeout = socket.getdefaulttimeout()
new_timeout = 3
socket.setdefaulttimeout(new_timeout)
host_status = False
try:
transport = paramiko.Transport((host, port))
host_status = True
except:
print('***Warning*** Host {host} on port {port} is down.'.format(
host=host, port=port)
)
socket.setdefaulttimeout(original_timeout)
return host_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment