Example #1
0
def request(server, attrs):
	get.intialize(server,200)
	try:
		pmid = attrs["pmid"]
		machine = get.find_machine_pmid(pmid)
		user = machine[0]
		ip = machine[1]
		connect = libv.open(get.make_path(user,ip))
		
		#int numDomains;
		#numDomains = NumOfDomains(connect)
		
		#server.write(json_out({"pmid":pmid,"vms":numDomains}))		

		#int *activeDomains
		#activeDomains = malloc(sizeof(int) * numDomains)

		domains = connect.listDefinedDomains()

		out = {"pmid": pmid}

		for d in domains:
			out.append(find_vmid_name(d))
		server.write(json_out({"vmids":out}))

	except:
		server.write(json_out({"vmids":[]}))
Example #2
0
def request(server, attrs):
	get.intialize(server,200)
	try:
		vmid = int(attrs["vmid"])
		vm = get.reqs[vmid]

		server.write(json_out({"vmid":vmid, "name":vm[0],"instance_type":vm[1],"pmid":vm[2]}))
	except:
		server.write(json_out({"vmid":0,"name":"","instance_type":0,"pmid":0}))
Example #3
0
def request(server, attrs):
	get.intialize(server,200)
	try:
		ids = []
		for i in get.machines:
			ids.append(i[2])
		server.write(json_out({"pmids":ids}))

	except:
		server.write(json_out({"pmids":[]}))
Example #4
0
def request(server, attrs):
    get.intialize(server, 200)
    out = []
    try:
        for i in get.images:
            out.append({"id": i[3], "name": find_image_name(i[2])})

        server.write(json_out({"images": out}))

    except:
        server.write(json_out({"images": []}))
Example #5
0
def request(server, attrs):
	get.intialize(server,200)
	try:
		pmid = attrs["pmid"]
		
		ids = []
		for i in get.reqs:
			if get.reqs[i][2] == pmid:
				ids.append(get.reqs[i][2])
		server.write(json_out({"vmids":ids}))


	except:
		server.write(json_out({"vmids":[]}))
Example #6
0
def request(server, attrs):
	get.intialize(server,200)
	try:
		connect = libv.open("qemu:///system")
		vmid = int(attrs["vmid"])
		req = connect.lookupByName(get.reqs[vmid][0])

		if req.isActive():
			req.destroy()

		req.undefine()
		del get.reqs[vmid]

		server.write(json_out({"status":1}))
	except:
		server.write(json_out({"status":0}))
Example #7
0
def request(server, attrs):
	get.intialize(server, 200)

	try:
		name = attrs["name"]
		instance_type = int(attrs["instance_type"])
		#addr = "[email protected]/"
		
		machine = get.machine_list[random()*len(get.machines_list)]
		user = machine[0]
		ip = machine[1]
		connect = libv.open(get.make_path(user, ip))
		req = connect.defineXML(create_xml(name, connect.getType().lower()))
		try:
			req.create()
		except:
			server.write(json_out({"vmid":0}))

		vmid = get.next_vmid()
		get.req[vmid] = [name, instance_type, machine[2]]

		server.write(json_out({"vmid":vmid}))
	except:
		server.write(json_out({"vmid":0}))