Skip to content

Instantly share code, notes, and snippets.

@teodor-pripoae
Created June 23, 2015 13:50
Show Gist options
  • Save teodor-pripoae/8447f5f1f2afa0f8a9dc to your computer and use it in GitHub Desktop.
Save teodor-pripoae/8447f5f1f2afa0f8a9dc to your computer and use it in GitHub Desktop.
Update skydns from hosts file
#!/usr/bin/env python
import os
def blank(el):
return len(el) == 2
with open('dns.txt', 'r') as f:
lines = [x.split(' ') for x in f.read().split('\n')]
results = filter(blank, lines)
for result in results:
print result
ip = result[0]
key = "/".join(result[1].split('.')[::-1])
cmd = "curl -XPUT http://127.0.0.1:4001/v2/keys/skydns/%s -d value='{\"host\":\"%s\"}'" %(key, ip)
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment