Exemplo n.º 1
0
def createVolume():
	name = str(request.args.get('name'))
	size = int(request.args.get('size'))
	print "creating volume"+str(name);
	retVal=col.createVolume(name,size)

	if retVal!=-1:
		status="available";
		xml='';
		db = get_db();
		db.execute('''insert into volumes(status,name,vmid,volsize,volxml) values (?,?,?,?,?)''',[str(status),str(name),0,int(size),xml]);
		db.commit();
		volumeid=query_db('select volumeid from volumes')[-1];
		return jsonify({'volumeid':volumeid[0]})
	else:
		return jsonify({'error':0})

	print "volume created"+str(name);
Exemplo n.º 2
0
def createVolume():
	jsonpFunc = str(request.args.get('jsonp_callback'))
	name = str(request.args.get('name'))
	size = int(request.args.get('size'))
	print "creating volume"+str(name);
	retVal=col.createVolume(name,size)
	volume={}
	if retVal!=-1:
		status="available";
		xml='';
		db = get_db();
		db.execute('''insert into volumes(status,name,vmid,volsize,volxml) values (?,?,?,?,?)''',[str(status),str(name),0,int(size),xml]);
		db.commit();
		volumeid=query_db('select volumeid from volumes')[-1];
		volume={'volumeid':volumeid[0]}
	else:
		volume={'error':0}

	if jsonpFunc!='None':
		ast=jsonpFunc+'('+json.dumps(volume)+')'
		print ast
		return ast
    	return jsonify(volume);