Пример #1
0
def getSvVmip(db_session,id):
	sql='select vm_id from sv_tb where sv_id= "'+str(id)+'"'
	print sql
	r=db_session.query(sql)
	if len(r)==0:
		raise BadServiceIDException(sv_id=id)
	vm_id=r[0]['vm_id']
	vm_ip=vmclient.get_vm_ip(vm_id)
	return vm_ip
Пример #2
0
	def addSv2Vm(self,vm_id,sv_id,sv_file,contenttype):
		sv_id=str(sv_id)
		vm_ip=vmclient.get_vm_ip(vm_id)
		sv_url = 'http://'+str(vm_ip)+":8091/v1/svs/"+str(sv_id)
		print sv_url
		sv_filename=sv_id+"."+sv_file.filename.split('.')[-1].strip()
		boundary=contenttype.split(';')[-1].split("=")[-1].strip()
		sv_data = self.multipartencode.encode(sv_filename,sv_file,boundary)
		
		self.upload_file(vm_ip, contenttype, sv_data)
		return sv_url
Пример #3
0
		#DELETE ip:8089/v1/dbs/id
		db_session=req.environ['db_session']
		
 		try:
			checkpolicy(req,id)
 		except Exception,e:
 			return e.msg
		try:
		#dbname = db.get_dbinfo_dbname(db_session,id)
		#db_user_count为数据库的用户名为db_username的数目
		#db_username,db_user_count = db.get_dbinfo_dbusername(db_session,id)
 			dbinfo = db.get_dbinfo4id_all(db_session,id)
		 	if not dbinfo:
		 		raise NUllResourceIDException(id=id) 
 			vm_id = dbinfo['vm_id']
 		 	vm_ip = vmclient.get_vm_ip(vm_id)
 		  	dbname = dbinfo['dbname']
		
		#db_username = dbinfo['db_username']
		#user_count = get_usercount4username(db_session,db_username)
		#delete_db_username = False
		#if user_count<2:
		#	delete_db_username = True
		#删除远程数据库
		
			proxyclient.deletedbreq(vm_ip,dbname)
			db.deleteDBInfo4ID(db_session,id)
		except Exception,e:
			return e.msg
		return 'Delete User DataBase information which id is %s successfully' %id