From f764c2f58ee9041781f8d608467db04bee03a19e Mon Sep 17 00:00:00 2001 From: guange Date: Fri, 13 Dec 2019 14:57:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?jupyter=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/jupyters_controller.rb | 12 ++++++ app/services/jupyter_service.rb | 59 +++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/app/controllers/jupyters_controller.rb b/app/controllers/jupyters_controller.rb index ab3962cbc..96ebf3452 100644 --- a/app/controllers/jupyters_controller.rb +++ b/app/controllers/jupyters_controller.rb @@ -30,5 +30,17 @@ class JupytersController < ApplicationController render json: {status: 0, url: url, port: port} end + def reset_with_tpi + myshixun = Myshixun.find_by(identifier: params[:identifier]) + info = jupyter_tpi_reset(myshixun) + render json: {status: 0, url: info[:url], port: info[:port]} + end + + def reset_with_tpm + shixun = Shixun.find_by(identifier: params[:identifier]) + info = jupyter_tpm_reset(shixun) + render json: {status: 0, url: info[:url], port: info[:port]} + end + end \ No newline at end of file diff --git a/app/services/jupyter_service.rb b/app/services/jupyter_service.rb index 32c2047c4..f4b660175 100644 --- a/app/services/jupyter_service.rb +++ b/app/services/jupyter_service.rb @@ -7,7 +7,7 @@ module JupyterService 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))}"} + params = {tpiID: tpiID, identifier: shixun.identifier, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} logger.info "test_juypter: uri->#{uri}, params->#{params}" res = uri_post uri, params @@ -45,7 +45,7 @@ module JupyterService uri = "#{shixun_tomcat}/bridge/jupyter/get" tpiID = myshixun.id - params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} + params = {tpiID: tpiID, identifier: shixun.identifier, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} res = uri_post uri, params logger.info "test_juypter: #{res}" @@ -130,4 +130,59 @@ module JupyterService end + ##重置jupyter环境 + def jupyter_tpi_reset(myshixun) + jupyter_delete_tpi(myshixun) + url = jupyter_url_with_game(myshixun) + port = jupyter_port_with_game(myshixun) + {url: url, port: port} + end + + ## 重置tpm环境 + def jupyter_tpm_reset(shixun) + jupyter_delete_tpm(shixun) + + url = jupyter_url_with_shixun(shixun) + port = jupyter_port_with_shixun(shixun) + + {url: url, port: port} + end + + + + # 删除pod + def jupyter_delete_tpi(myshixun) + myshixun_id = myshixun.id + digest = myshixun.identifier + edu_setting('bridge_secret_key') + digest_key = Digest::SHA1.hexdigest("#{digest}") + begin + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/jupyter/delete" + Rails.logger.info("#{current_user} => cloese_jupyter digest is #{digest}") + params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => myshixun.identifier} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:110)") + end + end + end + + + def jupyter_delete_tpm(shixun) + tpiID = "tpm#{shixun.id}" + digest = shixun.identifier + edu_setting('bridge_secret_key') + digest_key = Digest::SHA1.hexdigest("#{digest}") + begin + shixun_tomcat = edu_setting('cloud_bridge') + uri = "#{shixun_tomcat}/bridge/jupyter/delete" + Rails.logger.info("#{current_user} => cloese_jupyter digest is #{digest}") + params = {:tpiID => tpiID, :digestKey => digest_key, :identifier => shixun.identifier} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:110)") + end + end + end + + end From c08e6338adcae64611830f6ac52f2dba1167010a Mon Sep 17 00:00:00 2001 From: guange Date: Fri, 13 Dec 2019 15:02:16 +0800 Subject: [PATCH 2/4] . --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index f3150db7f..643972b95 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,8 @@ Rails.application.routes.draw do get :save_with_tpm get :get_info_with_tpi get :get_info_with_tpm + get :reset_with_tpi + get :reset_with_tpm end end From 36533d76beb35f9972a9757fbc52fa4f60d40bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 13 Dec 2019 15:12:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMDataset.js | 69 +++++++++++++++------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js index 68f6a5e37..cab7ec91a 100644 --- a/public/react/src/modules/tpm/TPMDataset.js +++ b/public/react/src/modules/tpm/TPMDataset.js @@ -75,7 +75,7 @@ class TPMDataset extends Component { mylistansum:30, collaboratorList:[], fileList:[], - fileListimg:[], + fileListimgs:[], file:null, datalist:[], data_sets_count:0, @@ -226,6 +226,31 @@ class TPMDataset extends Component { } + + getdatasthree = (page,limit) => { + let id=this.props.match.params.shixunId; + + let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; + axios.get(collaborators,{params:{ + page:page, + limit:limit, + }}).then((response)=> { + if(response.status===200){ + if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + + }else{ + + + } + + } + + }).catch((error)=>{ + + }); + + } + paginationonChanges = (pageNumber) => { // //console.log('Page: '); this.setState({ @@ -264,25 +289,32 @@ class TPMDataset extends Component { handleChange = (info) => { if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){ let fileList = info.fileList; - // try { - // for(var list of fileList ){ - // console.log(list) - // this.state.fileListimg.push(list); - // } - // }catch (e) { - // - // } + + this.setState({ fileList: appendFileSizeToUploadFileAll(fileList), - }); + if(info.file.status === 'done'){ + console.log("handleChange"); + console.log(info); + //done 成功就会调用这个方法 + this.getdatas(); + try { + // let datas=this.state.fileListimgs; + // for(var i=0;i { //上传前的操作 console.log('beforeUpload', file.name); - console.log("TPMDatasetTPMDatasetTPMDataset"); - console.log(fileListimg); const isLt150M = file.size / 1024 / 1024 < 150; if (!isLt150M) { this.props.showNotification('文件大小必须小于150MB!'); @@ -422,7 +452,6 @@ class TPMDataset extends Component { return isLt150M; }, }; - return (
From c1ffc5cdd6a5f1b8ba11dc6d294d729eae80f40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 13 Dec 2019 15:12:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMDataset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js index cab7ec91a..ed58211f8 100644 --- a/public/react/src/modules/tpm/TPMDataset.js +++ b/public/react/src/modules/tpm/TPMDataset.js @@ -307,8 +307,8 @@ class TPMDataset extends Component { // this.setState({ // fileListimgs:datas, // }) - console.log("datasdatasdatasdatasdatas"); - console.log(datas); + // console.log("datasdatasdatasdatasdatas"); + // console.log(datas); }catch (e) { }