예제 #1
0
class RmSVManClass(object):
	def __init__(self,db_session):
		self.db_session=db_session
		self.multipartencode=MultiPartEncode()
		
	def upload_file(self,vm_ip,contenttype,data):
		r = urllib2.Request("http://"+vm_ip+":8091/filedeploy")
		r.add_unredirected_header('Content-Type',contenttype)
		r.add_data(data)
		u = urllib2.urlopen(r)
		return u

	def delete_file(self,vm_ip,sv_id):
		r = urllib2.Request("http://"+vm_ip+":8091/fileundeploy/"+sv_id)
		return urllib2.urlopen(r)
		
		pass
	def addSv2Vm(self,vm_id,sv_id,sv_file,contenttype):
		vm_ip=vmmanmod_client.get_vm_ip(vm_id)
		sv_url = 'http://'+vm_ip+":8091/v1/svs/"+sv_id
		
		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
		
	def deleteSvOnVM(self,id):
		#1.���id��÷�������vm
		#2.����Զ�̴���--һ��webServer--ɾ��Զ��vm�ϵķ������
		'''
		sv_vmip=db.getSvVmip(self.db_session, id)
		self.delete_file(sv_vmip)
		'''
		print 'delete sv On VM successuflly!!!'
		return 'ture'
예제 #2
0
 def __init__(self, config):
     self.config = config
     self.mysql = Mysql()
     self.fileupload = FileUpload()
     self.multipartencode = MultiPartEncode()
예제 #3
0
	def __init__(self,db_session):
		self.db_session=db_session
		self.multipartencode=MultiPartEncode()