|  |  | @ -7,7 +7,7 @@ module JupyterService | 
			
		
	
		
		
			
				
					
					|  |  |  |             shixun_tomcat = edu_setting('cloud_bridge') |  |  |  |             shixun_tomcat = edu_setting('cloud_bridge') | 
			
		
	
		
		
			
				
					
					|  |  |  |             uri = "#{shixun_tomcat}/bridge/jupyter/get" |  |  |  |             uri = "#{shixun_tomcat}/bridge/jupyter/get" | 
			
		
	
		
		
			
				
					
					|  |  |  |             tpiID = "tpm#{shixun.id}" |  |  |  |             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}" |  |  |  |             logger.info "test_juypter: uri->#{uri}, params->#{params}" | 
			
		
	
		
		
			
				
					
					|  |  |  |             res = uri_post uri, params |  |  |  |             res = uri_post uri, params | 
			
		
	
	
		
		
			
				
					|  |  | @ -45,7 +45,7 @@ module JupyterService | 
			
		
	
		
		
			
				
					
					|  |  |  |             uri = "#{shixun_tomcat}/bridge/jupyter/get" |  |  |  |             uri = "#{shixun_tomcat}/bridge/jupyter/get" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             tpiID = myshixun.id |  |  |  |             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 |  |  |  |             res = uri_post uri, params | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             logger.info "test_juypter: #{res}" |  |  |  |             logger.info "test_juypter: #{res}" | 
			
		
	
	
		
		
			
				
					|  |  | @ -130,4 +130,59 @@ module JupyterService | 
			
		
	
		
		
			
				
					
					|  |  |  |     end |  |  |  |     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 |  |  |  | end | 
			
		
	
	
		
		
			
				
					|  |  | 
 |