Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
remove s3fs and mounting refernces (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayadebellis authored Apr 8, 2021
1 parent c7b5bdb commit 9664628
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 113 deletions.
5 changes: 1 addition & 4 deletions show_ssh_info/show_ssh_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{
Expand All @@ -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)])

11 changes: 11 additions & 0 deletions show_ssh_info/show_ssh_info/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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
Expand Down
50 changes: 0 additions & 50 deletions show_ssh_info/src/funcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
const profile = await getUsernameToken(state);

Expand Down
5 changes: 0 additions & 5 deletions show_ssh_info/src/getKeycloak.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
56 changes: 2 additions & 54 deletions show_ssh_info/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -70,55 +70,6 @@ const extensionUser: JupyterFrontEndPlugin<void> = {
};


///////////////////////////////////////////////////////////////
//
// Mount user workspace extension
//
///////////////////////////////////////////////////////////////
const extensionMount: JupyterFrontEndPlugin<void> = {
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<void> = {
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
Expand Down Expand Up @@ -154,7 +105,4 @@ const extensionRefreshToken: JupyterFrontEndPlugin<void> = {
}
};




export default [extensionSsh, extensionUser, extensionMount, extensionPreSigneds3Url, extensionRefreshToken, extensionMountOrgBuckets];
export default [extensionSsh, extensionUser, extensionPreSigneds3Url, extensionRefreshToken];

0 comments on commit 9664628

Please sign in to comment.