def init_vps(d): name = d['name'] ip = d['ip'] if not vps_util.highstate_pid(name): print("Highstate not running yet; waiting for a bit just in case...") time.sleep(10) while vps_util.highstate_pid(name): print("Highstate still running...") time.sleep(10) print("Highstate done!") return vps_util.hammer_the_damn_thing_until_it_proxies(name)
def init_vps(name_and_ip): name, ip = name_and_ip if not vps_util.highstate_pid(name): print("Highstate not running yet; waiting for a bit just in case...") time.sleep(10) while vps_util.highstate_pid(name): print("Highstate still running...") time.sleep(10) print("Highstate done!") return vps_util.hammer_the_damn_thing_until_it_proxies( name, ssh_tmpl % ip, fetchaccessdata_tmpl % ip)
def launch_config_server(): # XXX: this doesn't perform a complete setup yet. name = vps_util.new_vps_name('cs') d = do_util.create_vps(name, plan=vps_util.dc_by_cm(vps_util.my_cm()) + '_2GB') if not vps_util.highstate_pid(name): print("Highstate not running yet; waiting for a bit just in case...") time.sleep(10) while vps_util.highstate_pid(name): print("Highstate still running...") time.sleep(10) ip = d['ip'] print "Checking for completion..." while True: try: resp = requests.get(('http://%s/proxies.yaml.gz' % ip), timeout=5) if resp.ok: break except requests.exceptions.RequestException: pass print "Server setup not complete yet; retrying..." time.sleep(5) print "%s (%s) is up." % (name, ip)
do_token = os.getenv("DO_TOKEN") do = digitalocean.Manager(token=do_token) def create_vps(name): vps_util.save_pillar(name) out = subprocess.check_output(["salt-cloud", "-p", "do_nl_1GB", name]) # Uberhack; It'll get better with newer salt-cloud versions. d = yaml.load(out[out.rfind(name + ":"):].replace("----------", "")).values()[0] return d['name'], d['ip_address'] def init_vps((name, ip), wait_for_hs=True): if wait_for_hs: while not vps_util.highstate_pid(name): print "Highstate not running yet..." time.sleep(10) while vps_util.highstate_pid(name): print "Highstate still running..." time.sleep(10) print "Highstate done!" return vps_util.hammer_the_damn_thing_until_it_proxies( name, ssh_tmpl % ip, fetchaccessdata_tmpl % ip) def destroy_vps(name): os.system('salt-cloud -yd ' + name) os.system('salt-key -yd' + name)
"scp -o StrictHostKeyChecking=no -i /etc/salt/cloudmaster.id_rsa root@%s:/home/lantern/access_data.json ." ) do_token = os.getenv("DO_TOKEN") do = digitalocean.Manager(token=do_token) def create_vps(name): vps_util.save_pillar(name) out = subprocess.check_output(["salt-cloud", "-p", "do_nl_1GB", name]) # Uberhack; It'll get better with newer salt-cloud versions. d = yaml.load(out[out.rfind(name + ":") :].replace("----------", "")).values()[0] return d["name"], d["ip_address"] def init_vps((name, ip), wait_for_hs=True): if wait_for_hs: while not vps_util.highstate_pid(name): print "Highstate not running yet..." time.sleep(10) while vps_util.highstate_pid(name): print "Highstate still running..." time.sleep(10) print "Highstate done!" return vps_util.hammer_the_damn_thing_until_it_proxies(name, ssh_tmpl % ip, fetchaccessdata_tmpl % ip) def destroy_vps(name): os.system("salt-cloud -yd " + name) os.system("salt-key -yd" + name)