From a0502bf4ed48385e21aacf89585877de855e860a Mon Sep 17 00:00:00 2001 From: guagne <8863824@gmail.com> Date: Fri, 20 Dec 2019 16:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BB=B6=E6=97=B6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/jupyters_controller.rb | 13 ++++++++++++- app/services/jupyter_service.rb | 21 +++++++++++++++++++++ config/routes.rb | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/controllers/jupyters_controller.rb b/app/controllers/jupyters_controller.rb index 96ebf3452..4c03e0dd3 100644 --- a/app/controllers/jupyters_controller.rb +++ b/app/controllers/jupyters_controller.rb @@ -42,5 +42,16 @@ class JupytersController < ApplicationController render json: {status: 0, url: info[:url], port: info[:port]} end + def active_with_tpm + shixun = Shixun.find_by(identifier: params[:identifier]) + jupyter_active_tpm(shixun) + render json: {status: 0} + end + + def active_with_tpi + myshixun = Myshixun.find_by(identifier: params[:identifier]) + jupyter_active_tpm(myshixun) + render json: {status: 0} + end -end \ No newline at end of file +end diff --git a/app/services/jupyter_service.rb b/app/services/jupyter_service.rb index 0f5af6cb8..bff9b5dc6 100644 --- a/app/services/jupyter_service.rb +++ b/app/services/jupyter_service.rb @@ -191,5 +191,26 @@ module JupyterService edu_setting('jupyter_service').gsub("PORT", jupyter_port) end + def _jupyter_active(tpiID) + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/jupyter/active" + params = {:tpiID => tpiID} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:120)") + end + end + + # tpm 延时 + def jupyter_active_tpm(shixun) + tpiID = "tpm#{shixun.id}" + _jupyter_active(tpiID) + end + + # tpi 延时 + def jupyter_active_tpi(myshixun) + tpiID = myshixun.id + _jupyter_active(tpiID) + end end diff --git a/config/routes.rb b/config/routes.rb index 0d2aba843..151cc0b32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,8 @@ Rails.application.routes.draw do get :get_info_with_tpm get :reset_with_tpi get :reset_with_tpm + get :active_with_tpm + get :active_with_tpi end end