예제 #1
0
def startNodes(ami, inst_size, keyName, maxPrice, nodecnt):
	GF.log("... starting " + str(nodecnt) + " node(s)", 1);
	local=[]
	try:		
		res = GF.run("ec2-request-spot-instances " + ami + " -p " + str(maxPrice) + " -instance-type " + inst_size + " -n " + str(nodecnt) + " --type one-time" + " --key " + keyName)
		lines=res.split("\n")
		for i in range(0,len(res.split("\n"))):
			line=lines[i]
			print "res: ",i,line
			if line.find("SPOTINSTANCEREQUEST")>=0:
				inst=line.split("\t")
				local.append(CLnode.CLnode( ''    ,'slave' ,inst[5], ''  ,  '' ,  ''  ,inst[6] ,inst[0],  ''   ,False,inst[1],False))
				                           #instID,instName,status , ami , key , size ,  date  , ntype ,  url  ,master,sir,deployed):

		if res.find("timeout")>=0:
			print "TIMEOUT: ", res
			sys.exit()
		if res.find("InvalidAMIID")>=0:
			print "INVALID AMI ID: ", res
			sys.exit()
		
	except Exception as x:
		print x, "\n", res
		sys.exit()
	GF.addNewNodes(local)
예제 #2
0
def loadState():
	getRunningInstances()
	nodes=[]
	try:
		fname="./nodeDB"
		FILE = open(fname,"r")
		while FILE:
			line = FILE.readline().strip().split(",")
			if len(line)<=1:
				break
			nodes.append(CLnode.CLnode(*line))
			#line[0],line[1],line[2],line[3],line[4],line[5],line[6],line[7],line[8],line[9]
		FILE.close()
		GF.addNewNodes(nodes)
	except IOError:
		print "warning, nodeDB does not exists yet"
	except Exception as x:
		print x, "\n", res
		sys.exit()
예제 #3
0
def launchMaster(ami, inst_size, keyName):
	GF.log("Launching Master node..",1)
	local=[]
	try:
		res = GF.run("ec2-run-instances " + ami + " -k " + keyName + " -t " + size)
		if res.find("InvalidAMIID")>=0:
			print "INVALID AMI ID: ", res
			sys.exit()
		print res
		i=0
		lines=res.split("\n")
		master=CLnode.CLnode()
		for l in lines:
			inst=l.split("\t")
			if inst[0]=="INSTANCE":
				master = CLnode.CLnode(inst[1],"MASTER",inst[5],inst[2],inst[6],inst[9],inst[10],inst[0],'',True)
		master.desc_detail()
		local.append(master)
		GF.addNewNodes(local)
	except Exception as x:
		print x, "\n", res
		sys.exit()