From 966462803ce36adce5fa3db528306949acf7a174 Mon Sep 17 00:00:00 2001 From: Maya DeBellis Date: Thu, 8 Apr 2021 14:25:03 -0700 Subject: [PATCH] remove s3fs and mounting refernces (#87) --- show_ssh_info/show_ssh_info/__init__.py | 5 +-- show_ssh_info/show_ssh_info/handlers.py | 11 +++++ show_ssh_info/src/funcs.ts | 50 ---------------------- show_ssh_info/src/getKeycloak.js | 5 --- show_ssh_info/src/index.ts | 56 +------------------------ 5 files changed, 14 insertions(+), 113 deletions(-) diff --git a/show_ssh_info/show_ssh_info/__init__.py b/show_ssh_info/show_ssh_info/__init__.py index 958021dd..2edb439a 100644 --- a/show_ssh_info/show_ssh_info/__init__.py +++ b/show_ssh_info/show_ssh_info/__init__.py @@ -2,7 +2,7 @@ import os import os.path from notebook.utils import url_path_join -from .handlers import GetHandler, InjectKeyHandler, MountBucketHandler, Presigneds3UrlHandler, MountOrgBucketsHandler, MountSharedBucketsHandler +from .handlers import GetHandler, InjectKeyHandler, Presigneds3UrlHandler def _jupyter_server_extension_paths(): return [{ @@ -25,8 +25,5 @@ def load_jupyter_server_extension(nb_server_app): web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/get'), GetHandler)]) web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/inject_public_key'), InjectKeyHandler)]) - web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/mountBucket'), MountBucketHandler)]) - web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/mountSharedBucket'), MountSharedBucketsHandler)]) - web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/getOrgs'), MountOrgBucketsHandler)]) web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'show_ssh_info/getSigneds3Url'), Presigneds3UrlHandler)]) diff --git a/show_ssh_info/show_ssh_info/handlers.py b/show_ssh_info/show_ssh_info/handlers.py index 86a26a1f..eac57489 100644 --- a/show_ssh_info/show_ssh_info/handlers.py +++ b/show_ssh_info/show_ssh_info/handlers.py @@ -110,6 +110,10 @@ def get(self): self.finish({'ip': ip, 'port': port}) return + +""" +No longer in use. Mounting now is happening outside of the Jupyter container. +""" class MountBucketHandler(IPythonHandler): def get(self): message = '' @@ -193,6 +197,10 @@ def get(self): except: self.finish({"status_code":500, "message":message, "user_workspace":user_workspace,"user_bucket_dir":user_bucket_dir}) + +""" +No longer in use. Mounting now is happening outside of the Jupyter container. +""" class MountSharedBucketsHandler(IPythonHandler): def get(self): message = '' @@ -244,6 +252,9 @@ def get(self): except: self.finish({"status_code":500, "message":message, "shared_workspaces":shared_workspaces}) +""" +No longer in use. Mounting now is happening outside of the Jupyter container. +""" class MountOrgBucketsHandler(IPythonHandler): def get(self): # Send request to Che API for list of user's orgs diff --git a/show_ssh_info/src/funcs.ts b/show_ssh_info/src/funcs.ts index cd497284..62818a7a 100644 --- a/show_ssh_info/src/funcs.ts +++ b/show_ssh_info/src/funcs.ts @@ -42,56 +42,6 @@ export function checkUserInfo(): void { }); } -export async function mountUserFolder(state: IStateDB) { - - getUserInfo(function(profile: any) { - // get username from keycloak - if (profile['cas:username'] === undefined) { - INotification.error("Get username failed, did not mount bucket."); - return; - } - // send username to backend to create local mount point and mount s3 bucket - let username = profile['cas:username'] - let getUrl = new URL(PageConfig.getBaseUrl() + 'show_ssh_info/mountBucket'); - getUrl.searchParams.append('username',username); - - request('get', getUrl.href).then((res: RequestResult) => { - if (res.ok) { - let data:any = JSON.parse(res.data); - if (data.status_code == 200) { - let user_workspace = data.user_workspace; - let user_bucket_dir = data.user_bucket_dir; - INotification.success('Mounted user workspace '+user_workspace+' to '+user_bucket_dir); - } else { - INotification.error('Failed to mount user workspace to s3'); - } - } else { - INotification.error('Failed to mount user workspace to s3'); - } - }); - }); -} - -export async function mountOrgFolders(state: IStateDB) { - // do something - let token = getToken(); - var getUrl = new URL(PageConfig.getBaseUrl() + 'show_ssh_info/getOrgs'); - getUrl.searchParams.append('token',token); - request('get', getUrl.href).then((res: RequestResult) => { - if (res.ok) { - let data:any = JSON.parse(res.data); - if (data.status_code == 200) { - console.log(data); - INotification.success('Successfully mounted organization and sub-organization folders') - } else { - INotification.error('Failed to get user\'s Che orgs'); - } - } else { - INotification.error('Failed to get user\'s Che orgs'); - } - }); -} - export async function getPresignedUrl(state: IStateDB, key:string, duration:string): Promise { const profile = await getUsernameToken(state); diff --git a/show_ssh_info/src/getKeycloak.js b/show_ssh_info/src/getKeycloak.js index 993e8650..98a4758a 100644 --- a/show_ssh_info/src/getKeycloak.js +++ b/show_ssh_info/src/getKeycloak.js @@ -1,12 +1,7 @@ export var getUserInfo = function(callback) { - - console.log(window.parent); window.parent._keycloak.loadUserInfo().success(function(profile) { - console.log(profile); - // key = profile['public_ssh_keys']; callback(profile); - }).error(function() { console.log('Failed to load profile.'); return "error"; diff --git a/show_ssh_info/src/index.ts b/show_ssh_info/src/index.ts index 0dbd0bdc..6fb639b0 100644 --- a/show_ssh_info/src/index.ts +++ b/show_ssh_info/src/index.ts @@ -4,7 +4,7 @@ import { IFileBrowserFactory } from '@jupyterlab/filebrowser'; import { ILauncher } from '@jupyterlab/launcher'; import { IStateDB } from '@jupyterlab/statedb'; -import { checkUserInfo, mountUserFolder, checkSSH, activateGetPresignedUrl, mountOrgFolders} from './funcs' +import { checkUserInfo, checkSSH, activateGetPresignedUrl } from './funcs' import { InjectSSH } from './widgets' import { updateKeycloakToken } from "./getKeycloak"; import '../style/index.css'; @@ -70,55 +70,6 @@ const extensionUser: JupyterFrontEndPlugin = { }; -/////////////////////////////////////////////////////////////// -// -// Mount user workspace extension -// -/////////////////////////////////////////////////////////////// -const extensionMount: JupyterFrontEndPlugin = { - id: 'mount-s3-folder', - autoStart: true, - requires: [ICommandPalette, IStateDB], - optional: [], - activate: (app: JupyterFrontEnd, palette: ICommandPalette, state: IStateDB) => { - const open_command = 'sshinfo:mount'; - - app.commands.addCommand(open_command, { - label: 'User Workspace Mount', - isEnabled: () => true, - execute: args => { - mountUserFolder(state); - } - }); - palette.addItem({command:open_command,category:'User'}); - mountUserFolder(state); // automatically mount user folder on load - } -}; - -/////////////////////////////////////////////////////////////// -// -// Mount org buckets extension -// -/////////////////////////////////////////////////////////////// -const extensionMountOrgBuckets: JupyterFrontEndPlugin = { - id: 'mount-che-org-buckets', - requires: [ICommandPalette, IStateDB], - autoStart: true, - activate: (app: JupyterFrontEnd, palette: ICommandPalette, state: IStateDB) => { - const open_command = 'sshinfo:orgs'; - app.commands.addCommand(open_command, { - label: 'Che Org Workspace Mount', - isEnabled: () => true, - execute: args => { - mountOrgFolders(state); - } - }); - palette.addItem({command:open_command,category:'User'}); - mountOrgFolders(state); - } -}; - - /////////////////////////////////////////////////////////////// // // Presigned URL extension @@ -154,7 +105,4 @@ const extensionRefreshToken: JupyterFrontEndPlugin = { } }; - - - -export default [extensionSsh, extensionUser, extensionMount, extensionPreSigneds3Url, extensionRefreshToken, extensionMountOrgBuckets]; +export default [extensionSsh, extensionUser, extensionPreSigneds3Url, extensionRefreshToken];