Skip to content

Instantly share code, notes, and snippets.

@ipl31
Created November 5, 2012 19:42
Show Gist options
  • Save ipl31/4019873 to your computer and use it in GitHub Desktop.
Save ipl31/4019873 to your computer and use it in GitHub Desktop.
poc.py
#!/usr/bin/env python
import netaddr
from fabric import api
from fabric.network import disconnect_all
USER = "ubuntu"
PASS = "ubuntu"
NETWORK = "172.16.0.0/12"
CMD = "uptime"
for IP in netaddr.IPNetwork(NETWORK).iter_hosts():
try:
api.env.abort_on_prompts=True
api.env.skip_bad_hosts = True
api.env.warn_only = True
api.env.user = USER
api.env.password = PASS
api.env.command_timeout = 3 # seconds
api.env.host_string = str(IP)
api.run(CMD)
except:
print "Error talking to {0}".format(str(IP))
finally:
disconnect_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment