def create(self,req,body=None): environ = req.environ ''' user_id = environ['HTTP_X_USER_ID']''' self.db_session=environ['db_session'] # need to upgrade to use permission engine ''' if user_role == 'nuser': return "you have no permission to upload service" ''' #登记服务的基本信息到sv_tb中 try: request_body_size = int(environ.get('CONTENT_LENGTH',0)) except ValueError: request_body_size=0 fileds=cgi.FieldStorage(environ["wsgi.input"],environ=environ) #用于测试的代码段: #fileds={} #print fileds #print environ["wsgi.input"].read() #print self.db_session user_id = '123' #insert sv_tb table about service information sv_id=db.addSvInfo2TB(self.db_session, user_id, fileds) #登记服务的参数信息到sv_arg_type_tb中 #insert service arg information into sv_arg_type_tb table db.addSvInputArg2TB(self.db_session, sv_id, fileds) db.addSvOutputArg2TB(self.db_session, sv_id, fileds) ''' #将文件上传到虚拟机 contenttype = environ['CONTENT_TYPE'] sv_file = fileds['svfile'] vm_id = fileds['vm_id'].value sv_url=self.rmsvMan.addSv2Vm(vm_id,sv_id, sv_file,contenttype) #将更新sv_tb数据库中年sv_url信息 db.updatedSvUrl(self.db_session, sv_id, sv_url) ''' return 'service upload successfully!!!'
def create(self, req, body=None): environ = req.environ ''' user_id = environ['HTTP_X_USER_ID']''' self.db_session = environ['db_session'] # need to upgrade to use permission engine ''' if user_role == 'nuser': return "you have no permission to upload service" ''' #登记服务的基本信息到sv_tb中 try: request_body_size = int(environ.get('CONTENT_LENGTH', 0)) except ValueError: request_body_size = 0 fileds = cgi.FieldStorage(environ["wsgi.input"], environ=environ) #用于测试的代码段: #fileds={} #print fileds #print environ["wsgi.input"].read() #print self.db_session user_id = '123' #insert sv_tb table about service information sv_id = db.addSvInfo2TB(self.db_session, user_id, fileds) #登记服务的参数信息到sv_arg_type_tb中 #insert service arg information into sv_arg_type_tb table db.addSvInputArg2TB(self.db_session, sv_id, fileds) db.addSvOutputArg2TB(self.db_session, sv_id, fileds) ''' #将文件上传到虚拟机 contenttype = environ['CONTENT_TYPE'] sv_file = fileds['svfile'] vm_id = fileds['vm_id'].value sv_url=self.rmsvMan.addSv2Vm(vm_id,sv_id, sv_file,contenttype) #将更新sv_tb数据库中年sv_url信息 db.updatedSvUrl(self.db_session, sv_id, sv_url) ''' return 'service upload successfully!!!'
return "No service file Error!" #用于测试的代码段: #fileds={} #print fileds #print environ["wsgi.input"].read() #print self.db_session #insert sv_tb table about service information try: sv_id=db.addSvInfo2TB(self.db_session, user_id,user_name, fileds) except HydrogenException,e: return e.msg #登记服务的参数信息到sv_arg_type_tb中 #insert service arg information into sv_arg_type_tb table db.addSvInputArg2TB(self.db_session, sv_id, fileds) db.addSvOutputArg2TB(self.db_session, sv_id, fileds) #将文件上传到虚拟机 contenttype = environ['CONTENT_TYPE'] sv_file = fileds['svfile'] vm_id = fileds['vm_id'].value sv_url=self.rmsvMan.addSv2Vm(vm_id,sv_id, sv_file,contenttype) #将更新sv_tb数据库中年sv_url信息 db.updatedSvUrl(self.db_session, sv_id, sv_url) return 'service upload successfully!!!' def delete(self,req,id=None): #1.获取服务所在的虚拟机 #2.调用删除命令,删除虚拟机上的服务 #3.删除sv_arg_type_tb数据库与该服务相关的信息, #4.删除sv_tb上与该服务相关的数据