def _post_(self): project_url = self.get_argument("project_url",None) project_name = self.get_argument("project_name",None) storage_path = self.get_argument("storage_path",None) user_id = str(self.current_user.get("_id",None)) user_name = str(self.current_user.get("name",None)) create_time = time.time() # 数据库操作 insertData = {} insertData["project_url"] = project_url insertData["project_name"] = project_name insertData["storage_path"] = storage_path insertData["user_id"] = user_id insertData["status"] = 'created' insertData["logs"] = [{"create_time":create_time,"info":"started run application:"+project_name,"user_id":user_id}] result= yield self.s_application.insert_application(insertData) # 加入队列 msg = Message( json.dumps({ "project_url":project_url, "project_name":project_name, "storage_path":storage_path, "user_id":user_id, "user_name":user_name, 'app_count':1, "reply_to":'service_logs' })) send_message(msg,settings.RUN_APPLICATION_EXCHANGE,settings.RUN_APPLICATION_ROUTING) if result is None: self.render_error(error_code=404,msg="not data") else: insertData["_id"] = str(result) self.write_result(data=insertData)
def _post_(self): project_url = self.get_argument("project_url",None) project_name = self.get_argument("project_name",None) storage_path = self.get_argument("storage_path",None) user_id = str(self.current_user.get("_id",None)) user_name = str(self.current_user.get("name",None)) create_time = time.time() # 数据库操作 insertData = {} insertData["project_url"] = project_url insertData["project_name"] = project_name insertData["storage_path"] = storage_path insertData["user_id"] = user_id insertData["status"] = 'created' insertData["logs"] = [{"create_time":create_time,"info":{"stream":"started run application:"+project_name},"user_id":user_id}] result = yield self.s_application.insert_application(insertData) # 加入队列 msg = Message( json.dumps({ "application_id":result["_id"], "project_url":project_url, "project_name":project_name, "storage_path":storage_path, "user_id":user_id, "user_name":user_name, 'app_count':1, "reply_to":'service_logs' })) send_message(msg,settings.RUN_APPLICATION_EXCHANGE,settings.RUN_APPLICATION_ROUTING) if result is None: self.render_error(error_code=404,msg="not data") else: insertData["_id"] = result["_id"] self.write_result(data=insertData)
def _post_(self): user_id = str(self.current_user.get("_id", None)) user_name = str(self.current_user.get("name", None)) import time create_time = time.time() # 数据库操作 insertData = {} insertData["user_id"] = user_id insertData["status"] = 'start' insertData["logs"] = [{ "create_time": create_time, "info": { "stream": "started user registry" }, "user_id": user_id }] result = yield self.s_registry.insert_registry(insertData) # 加入队列 msg = Message( json.dumps({ "registry_id": result["registry_id"], "user_id": user_id, "user_name": user_name })) send_message(msg, settings.RUN_REGISTRY_EXCHANGE, settings.RUN_REGISTRY_ROUTING) if result is None: self.render_error(error_code=404, msg="not data") else: insertData["_id"] = result["registry_id"] self.write_result(data=insertData)
def _post_(self): project_url = self.get_argument("project_url",None) project_name = self.get_argument("project_name",None) project_id = self.get_argument("project_id",None) user_id = str(self.current_user.get("_id",None)) user_name = str(self.current_user.get("name",None)) create_time = time.time() # 数据库操作 insertData = {} insertData["project_url"] = project_url insertData["project_name"] = project_name insertData["project_id"] = project_id insertData["user_id"] = user_id insertData["status"] = 'created' insertData["logs"] = [{"create_time":create_time,"info":"started build project:"+project_name,"user_id":user_id}] result= yield self.s_service.insert_service(insertData) # 加入队列 msg = Message( json.dumps({ "project_url":project_url, "project_name":project_name, "project_id":project_id, "user_id":user_id, "user_name":user_name, "reply_to":'service_logs' })) send_message(msg,settings.CREATE_SERVICE_EXCHANGE,settings.CREATE_SERVICE_ROUTING) if result is None: self.render_error(error_code=404,msg="not data") else: insertData["_id"] = str(result) self.write_result(data=insertData)
def _post_(self): access_type = self.get_argument("type",None) application_id = self.get_argument("id",None) access_content = self.get_argument("content","") container_info =yield self.s_application.find_one(application_id) if container_info is None: container_info = {} # 从数据库获取,切记不要对外公开 container_host = container_info.get("run_host",None) container_name = container_info.get("app_name",None) if container_host is None or container_name is None: self.render_error(error_code=404,msg="not success") user_id = str(self.current_user.get("_id",None)) user_name = str(self.current_user.get("name",None)) create_time = time.time() # 数据库操作 accessData = {} accessData["access_type"] = access_type accessData["application_id"] = application_id accessData["container_name"] = container_name accessData["container_host"] = container_host accessData["access_content"] = access_content accessData["user_id"] = user_id accessData["status"] = 'start' accessData["logs"] = [ { "create_time":create_time, "info":"started access application:"+application_id+",it is hosted in "+container_host, "user_id":user_id } ] result= yield self.s_application_access.access_application(accessData) # 加入队列 msg = Message( json.dumps({ "access_id":result, "access_type":access_type, "access_content":access_content, "application_id":application_id, "container_host":container_host, "container_name":container_name, "user_id":user_id, "user_name":user_name, "reply_to":'access_logs' })) send_message(msg,settings.ACCESS_APPLICATION_EXCHANGE,settings.ACCESS_APPLICATION_ROUTING+"."+container_host) if result is None: self.render_error(error_code=404,msg="not data") else: accessData["_id"] = str(result) self.write_result(data=accessData)
def _post_(self): project_url = self.get_argument("project_url", None) project_name = self.get_argument("project_name", None) project_id = self.get_argument("project_id", None) user_id = str(self.current_user.get("_id", None)) user_name = str(self.current_user.get("name", None)) create_time = time.time() # 数据库操作 insertData = {} insertData["project_url"] = project_url insertData["project_name"] = project_name insertData["project_id"] = project_id insertData["user_id"] = user_id insertData["status"] = 'created' insertData["logs"] = [{ "create_time": create_time, "info": { "stream": "started build project:" + project_name }, "user_id": user_id }] result = yield self.s_service.insert_service(insertData) # 加入队列 msg = Message( json.dumps({ "project_url": project_url, "project_name": project_name, "project_id": project_id, "user_id": user_id, "user_name": user_name, "reply_to": 'service_logs' })) send_message(msg, settings.CREATE_SERVICE_EXCHANGE, settings.CREATE_SERVICE_ROUTING) if result is None: self.render_error(error_code=404, msg="not data") else: insertData["_id"] = str(result) self.write_result(data=insertData)
def _post_(self): user_id = str(self.current_user.get("_id",None)) user_name = str(self.current_user.get("name",None)) import time create_time = time.time() # 数据库操作 insertData = {} insertData["user_id"] = user_id insertData["status"] = 'start' insertData["logs"] = [{"create_time":create_time,"info":{"stream":"started user registry"},"user_id":user_id}] result = yield self.s_registry.insert_registry(insertData) # 加入队列 msg = Message( json.dumps({ "registry_id":result["registry_id"], "user_id":user_id, "user_name":user_name })) send_message(msg,settings.RUN_REGISTRY_EXCHANGE,settings.RUN_REGISTRY_ROUTING) if result is None: self.render_error(error_code=404,msg="not data") else: insertData["_id"] = result["registry_id"] self.write_result(data=insertData)