From c43e9722dc0e3198649aff6081b1a141963a2fc5 Mon Sep 17 00:00:00 2001 From: guange Date: Tue, 10 Dec 2019 15:55:01 +0800 Subject: [PATCH] . --- app/controllers/jupyters_controller.rb | 43 ++++++++++++++++++++++++++ app/controllers/main_controller.rb | 19 ------------ 2 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 app/controllers/jupyters_controller.rb diff --git a/app/controllers/jupyters_controller.rb b/app/controllers/jupyters_controller.rb new file mode 100644 index 000000000..25b7279fd --- /dev/null +++ b/app/controllers/jupyters_controller.rb @@ -0,0 +1,43 @@ +class JupytersController < ApplicationController + + def open + #打开tpm - juypter接口 + shixun = Shixun.find(3575) + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/jupyter/get" + tpiID = "tpm#{shixun.id}" + params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} + + + logger.info "test_juypter: uri->#{uri}, params->#{params}" + + res = uri_post uri, params + + logger.info "test_juypter: #{res}" + + render plain: "https://#{res['port']}.jupyter.educoder.net/data/workspace/myshixun_#{tpiID}/01.ipynb" + end + + def open1 + ## 打开tpi + game = Game.find(0) + shixun = game.myshixun.shixun + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/jupyter/get" + params = {tpiID: game.myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} + res = uri_post uri, params + + logger.info "test_juypter: #{res}" + + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:99)") + end + end + + + def test + render plain: 'test' + end + + +end \ No newline at end of file diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 1ca65afa3..0e2628c3e 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -2,23 +2,4 @@ class MainController < ApplicationController def index render file: 'public/react/build/index.html', :layout => false end - - - - def test_juypter - #打开tpm - juypter接口 - shixun = Shixun.find(3575) - shixun_tomcat = edu_setting('cloud_bridge') - uri = "#{shixun_tomcat}/bridge/jupyter/get" - params = {tpiID: "tpm#{shixun.id}", :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} - - - logger.info "test_juypter: uri->#{uri}, params->#{params}" - - res = uri_post uri, params - - logger.info "test_juypter: #{res}" - - render plain: res.to_json - end end \ No newline at end of file