except: pass if not os.path.exists(os.path.expanduser(keyfile)): raise IOError("That is not a valid keyfile!", keyfile) if "------" not in lD.run_quiet("ls -l " + keyfile): raise IOError("Your private keyfile " + keyfile + " needs to have X00 permissions (400 or 600).") print "Choose instance ID from:" iidtoip = {} nametoip = {} ips = [] print "Name, iid, security_group(s), instancetype, publicIP, status" json = lA.desc_instance() for reservation in json["Reservations"]: for instance in reservation["Instances"]: # print instance if "PublicIpAddress" not in instance or not len( instance["PublicIpAddress"]): continue else: name = "??" if 'Tags' in instance: names = [ tag["Value"] for tag in instance['Tags'] if tag["Key"] == "Name" ] if len(names): name = names[0]
if not autoname: instance_to_name[instancegroups[instancegroup["Name"]] [0]] = instancegroup["Name"].lower() lA.name_resource(instancegroups[instancegroup["Name"]][0], cluster_name + '-' + instancegroup["Name"]) continue for num, instance in enumerate(instancegroups[instancegroup["Name"]]): instance_to_name[instance] = (instancegroup["Name"] + ("-%03d" % (num + 1))).lower() lA.name_resource( instance, cluster_name + '-' + instancegroup["Name"] + ("-%03d" % (num + 1))) # Also name the attached volumes for instance, iname in instance_to_name.iteritems(): idesc = lA.desc_instance(instance) vols = idesc["Reservations"][0]["Instances"][0]["BlockDeviceMappings"] for v in vols: if "Ebs" in v and "DeviceName" in v: lA.name_resource( v["Ebs"]["VolumeId"], cluster_name + '-' + iname + v["DeviceName"].replace("/", "_")) # TODO: use a proper dns configuration here instead of writing into the host file print "==============================================" print "Configure machine names" print "==============================================" sys.stdout.flush() remotes_to_name = { remote: instance_to_name[instance].lower() for instance, remote in instance_to_remote.iteritems()
print "Awaiting ambari installation ..." lD.wait_for_ambari(remote, check_inst=['inst.stderr', 'inst.stdout']) if not skip_blueprint: print "Deploying default blueprint" stdout = lD.run_quiet( base + "/../deploy_from_blueprint.py --not-strict " + base + "/../blueprints/default.blueprint.json " + base + "/../blueprints/default.cluster.json " + remote.host + " " + secf) print stdout print "Awaiting blueprint completion" lD.waitforrequest(remote, 'default', 1) # # # Stop the instance and create an image from it! # # print "Creating image from this installation" instance = lA.desc_instance(iid)["Reservations"][0]["Instances"][0] # print instance if instance["State"]["Name"] is "running": lA.killinstance(iid, "stop") lA.waitforstate(iid, "stopped") # wait until stopped ami = lA.createimage(iid, "AmbDev-" + keypair + "-" + time.strftime("%Y%m%d-%H"), "Ambari dev image with keys for " + keypair + " keypair") time.sleep(5) lA.name_resource(ami, keypair) print ami, "created and registered, might take a few minutes to be available,", print " don't forget to set your environment variable export AMIAMBDEV=" + ami
for instancegroup in cluster_config["InstanceGroups"]: count = instancegroup["Count"] autoname = True if count < 0: autoname = False if not autoname: instance_to_name[instancegroups[instancegroup["Name"]][0]] = instancegroup["Name"].lower() lA.name_resource(instancegroups[instancegroup["Name"]][0], cluster_name + '-' + instancegroup["Name"]) continue for num, instance in enumerate(instancegroups[instancegroup["Name"]]): instance_to_name[instance] = (instancegroup["Name"] + ("-%03d" % (num + 1))).lower() lA.name_resource(instance, cluster_name + '-' + instancegroup["Name"] + ("-%03d" % (num + 1))) # Also name the attached volumes for instance, iname in instance_to_name.iteritems(): idesc = lA.desc_instance(instance) vols = idesc["Reservations"][0]["Instances"][0]["BlockDeviceMappings"] for v in vols: if "Ebs" in v and "DeviceName" in v: lA.name_resource(v["Ebs"]["VolumeId"], cluster_name + '-' + iname + v["DeviceName"].replace("/", "_")) # TODO: use a proper dns configuration here instead of writing into the host file print "==============================================" print "Configure machine names" print "==============================================" sys.stdout.flush() remotes_to_name = {remote: instance_to_name[instance].lower() for instance, remote in instance_to_remote.iteritems()} # for instance, remote in instance_to_remote.iteritems(): domain_name = 'kave.io' if "Domain" in cluster_config: domain_name = cluster_config["Domain"]["Name"].lower()
keyfile = security_config["AccessKeys"]["AWS"]["KeyFile"] except: pass if not os.path.exists(os.path.expanduser(keyfile)): raise IOError("That is not a valid keyfile!", keyfile) if "------" not in lD.run_quiet("ls -l " + keyfile): raise IOError("Your private keyfile " + keyfile + " needs to have X00 permissions (400 or 600).") print "Choose instance ID from:" iidtoip = {} nametoip = {} ips = [] print "Name, iid, security_group(s), instancetype, publicIP, status" json = lA.desc_instance() for reservation in json["Reservations"]: for instance in reservation["Instances"]: # print instance if "PublicIpAddress" not in instance or not len(instance["PublicIpAddress"]): continue else: name = "??" if 'Tags' in instance: names = [tag["Value"] for tag in instance['Tags'] if tag["Key"] == "Name"] if len(names): name = names[0] print str(name), str(instance['InstanceId']), [str(group['GroupName']) for group in instance['SecurityGroups']], str( instance['InstanceType']), str(instance["PublicIpAddress"]), str(instance["State"]["Name"]) iidtoip[str(instance['InstanceId'])] = str(instance["PublicIpAddress"])