def post(self, request, *args, **kwargs): """ 启动服务 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path """ try: new_add_memory = self.service.min_memory * self.service.min_node allow_create, tips = app_service.verify_source(self.tenant, self.service.service_region, new_add_memory, "start_app") if not allow_create: return Response(general_message(412, "resource is not enough", "资源不足,无法启动")) code, msg = app_manage_service.start(self.tenant, self.service, self.user) bean = {} if code != 200: return Response(general_message(code, "start app error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except ResourceNotEnoughException as re: raise re except AccountOverdueException as re: logger.exception(re) return Response(general_message(10410, "resource is not enough", re.message), status=412) return Response(result, status=result["code"])
def restart_tenant_service_group(self, user, group_id): group = self.get_tenant_service_group_by_pk(group_id, True) if not group: return False, '应用组不存在' tenant = group.tenant # 将应用组中应用排序, 并逐一启动 sorted_services = self.__sort_service(group.service_list) logger.debug('restart order ==> {}'.format([ tenant_service.service_cname for tenant_service in sorted_services ])) for service in sorted_services: try: app_manage_service.start(tenant, service, user) except Exception as e: logger.exception(e) logger.error('restart {0}[{1}]:{2} failed!'.format( service.service_cname, service.service_alias, service.service_id)) return False, '启动应用组失败' return True, '启动应用组成功'
def post(self, request, *args, **kwargs): """ 启动组件 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path """ try: code, msg = app_manage_service.start( self.tenant, self.service, self.user, oauth_instance=self.oauth_instance) bean = {} if code != 200: return Response(general_message(code, "start app error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except ResourceNotEnoughException as re: raise re except AccountOverdueException as re: logger.exception(re) return Response(general_message(10410, "resource is not enough", re.message), status=412) return Response(result, status=result["code"])
def post(self, request, *args, **kwargs): """ 启动服务 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path """ try: code, msg, event = app_manage_service.start( self.tenant, self.service, self.user) bean = {} if event: bean = event.to_dict() bean["type_cn"] = event_service.translate_event_type( event.type) if code != 200: return Response(general_message(code, "start app error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])