-
Notifications
You must be signed in to change notification settings - Fork 7
TERMINAL WERCKS #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TERMINAL WERCKS #145
Changes from 64 commits
c8f5ae2
71179a9
65884ce
9c68e12
4c41fd4
6bac2e2
c41344e
0498eb0
097ff58
30ee6c2
e156b44
c6525e0
e9052be
528fb7d
e9f46e2
a511006
dbd424a
7cca5d3
7b1f48d
d6c8c4a
3db2e47
719224f
161838b
fed186e
39e8e38
f206ca2
cb8412b
ddf5730
ae5c30a
e07f9f6
7fd5d14
eb95338
0b5ef75
f0cf529
0f77939
dcf2317
574d273
7a86b9e
9c7ab13
2b653aa
8921f1c
ee6d515
97d1492
461c6ea
d8df9f7
4e15bf9
64c3179
cc69eda
d36b825
1f67feb
481ac16
6aeecf5
ada5cbd
2483bba
d445926
ea90ac4
8b9cbbb
aac86b2
6bb29d7
c07c6a1
7b54c86
6f20115
3c90352
3763331
9cbe003
a4866a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
// Meteor Imports | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Mongo } from 'meteor/mongo'; | ||
import 'reflect-metadata'; | ||
import 'zone.js/dist/zone'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Mongo } from 'meteor/mongo'; | ||
import 'reflect-metadata'; | ||
import 'zone.js/dist/zone'; | ||
|
||
// Angular Imports | ||
import { Component, ViewEncapsulation, provide } from '@angular/core'; | ||
import { bootstrap } from 'angular2-meteor-auto-bootstrap'; | ||
import { ViewChild, Component, ViewEncapsulation, provide } from '@angular/core'; | ||
import { bootstrap } from 'angular2-meteor-auto-bootstrap'; | ||
|
||
// Angular Material Imports | ||
import { MeteorComponent } from 'angular2-meteor'; | ||
import { MeteorComponent } from 'angular2-meteor'; | ||
import { OVERLAY_PROVIDERS } from '@angular2-material/core/overlay/overlay'; | ||
import { MATERIAL_PROVIDERS, MATERIAL_DIRECTIVES } from 'ng2-material'; | ||
|
||
import { InjectUser } from 'angular2-meteor-accounts-ui'; | ||
|
||
// Terminal and Markdown Imports | ||
import { Terminal } from "../../components/wetty/terminal.ts"; | ||
import { MarkdownView } from "../../components/markdown/markdown.ts"; | ||
|
@@ -22,8 +24,9 @@ | |
|
||
// Meteor method imports | ||
import "../../../lab/methods.ts" | ||
|
||
import { labs } from '../../../../../collections/labs.ts'; | ||
// Define TaskView Component | ||
|
||
@Component({ | ||
selector: 'tuxlab-taskview', | ||
templateUrl: '/client/imports/ui/pages/lab/taskview.html', | ||
|
@@ -38,15 +41,34 @@ | |
encapsulation: ViewEncapsulation.None | ||
}) | ||
|
||
@InjectUser('user') | ||
export default class TaskView extends MeteorComponent { | ||
user: Meteor.User; | ||
userid: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont need |
||
cur_user: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont need |
||
public auth : any; | ||
|
||
@ViewChild(Terminal) term : Terminal; | ||
|
||
labMarkdown = "# Lab 1 Tasks \n ### Task 1 \n Implement **bash** *on your own* ***without*** any help. \n ### Task 2 \n Install *Arch Linux*. \n ### Task 3 \n Type ```sudo rm -rf /*``` into your terminal"; | ||
|
||
constructor() { | ||
super(); | ||
// Create Icon Font | ||
var slf = this; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need anymore |
||
} | ||
|
||
ngAfterViewInit(){ | ||
var slf = this; | ||
Meteor.call('prepareLab',"1","1", function(err,res){ | ||
slf.labMarkdown = "#Sander \n ##are you sure this will work?"; | ||
console.log(slf.labMarkdown); | ||
slf.auth = { | ||
username: Meteor.user().profile.nickname, | ||
password: res.sshInfo.pass, | ||
domain: "10.100.1.11" | ||
}; | ||
slf.term.openTerminal(slf.auth); | ||
console.log("fired",err,res); | ||
//TODO: @Cem res: {host,pass} initialize terminal | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ env.prototype.init = function(opts){ | |
//declare final options | ||
var crtOptsf = { | ||
'Image': img, | ||
'Cmd': ['/bin/sh'], | ||
'Cmd': ['./entry.sh'], | ||
'name': this.labVm, | ||
'Hostname': '', | ||
'User': '', | ||
|
@@ -134,11 +134,11 @@ env.prototype.init = function(opts){ | |
|
||
//Check whether environment has been initialized correctly | ||
if(!slf.usr){ | ||
TuxLog.log('debug','no env user initialized'); | ||
TuxLog.log('warn','no env user initialized'); | ||
reject("Internal Error"); | ||
} | ||
if(slf.vmList.labVm){ | ||
TuxLog.log('labfile_error','trying to init env twice'); | ||
TuxLog.log('warn','trying to init env twice'); | ||
reject("Internal error"); | ||
} | ||
|
||
|
@@ -152,6 +152,7 @@ env.prototype.init = function(opts){ | |
|
||
//containerId to be stored in helix | ||
else { | ||
console.log("successfully created container"); | ||
var containerId = container.id.substring(0,7); | ||
container.start(strOptsf,function(err,data){ | ||
|
||
|
@@ -161,7 +162,7 @@ env.prototype.init = function(opts){ | |
} | ||
else { | ||
var etcd_redrouter = { | ||
docker: containerId, | ||
docker_container: containerId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation? |
||
port: 22, | ||
username: "root", | ||
allowed_auth: ["password"] | ||
|
@@ -171,10 +172,10 @@ env.prototype.init = function(opts){ | |
var dir = slf.root_dom.split('.'); | ||
dir.reverse().push(slf.usr,'A'); | ||
slf.helixKey = dir.join('/'); | ||
slf.redRouterKey = '/redrouter/ssh::'+slf.usr; | ||
slf.redRouterKey = '/redrouter/SSH::'+slf.usr; | ||
|
||
//set etcd record for redrouter | ||
etcd.set(slf.redRouterKey,etcd_redrouter,function(err,res){ | ||
etcd.set(slf.redRouterKey,JSON.stringify(etcd_redrouter),function(err,res){ | ||
if(err){ | ||
TuxLog.log('debug', 'error creating redrotuer etcd record: '+err); | ||
reject("Internal error"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var LabSession = require('../api/lab.session.js'); | ||
declare var SessionCache : any; | ||
declare var TuxLog : any; | ||
declare var nconf : any; | ||
declare var Collections : any; | ||
|
||
function getSession(user : string, labId : string, callback : any) : void{ | ||
SessionCache.get(user,labId,function(err,res){ | ||
if(err){ | ||
TuxLog.log("warn","SessionCache.get :"+err); | ||
callback(new Meteor.Error("Internal Service Error"),null); | ||
} | ||
else if(!res){ | ||
TuxLog.log("warn","no res"); | ||
var session = new LabSession(); | ||
session.init(user, labId, function(err,result){ | ||
if(err){ | ||
TuxLog.log("warn","session init: "+err); | ||
callback(err,null); | ||
} | ||
else{ | ||
SessionCache.add(user,labId,session,function(err){ | ||
TuxLog.log("warn",err); | ||
//callback(null,result); | ||
}); | ||
callback(null,result); | ||
} | ||
}); | ||
} | ||
else{ | ||
TuxLog.log("warn","res initialized"); | ||
res.env.getPass(function(err,result){ | ||
if(err){ | ||
callback(err,null); | ||
} | ||
else{ | ||
console.log(result); | ||
callback(null,{taskNo:res.lab.taskNo,sshPass:result}); | ||
} | ||
}) | ||
} | ||
}); | ||
} | ||
export function prepLab(user : string, labId : string, callback : any) : any{ | ||
TuxLog.log("warn","prepLab"); | ||
getSession(user, labId, function(err,res){ | ||
if(err){ | ||
TuxLog.log("warn","getSession err: "+err); | ||
callback(new Meteor.Error("Internal Service Error"),null); | ||
} | ||
else{ | ||
|
||
var optsp = {'fields': { | ||
'labfile' : 0, | ||
'lab_name': 0, | ||
'course_id': 0, | ||
'updated': 0, | ||
'disabled': 0, | ||
'hidden': 0 | ||
}}; | ||
var sshInfo = {host : nconf.get("domain_root"), pass: res.sshPass}; | ||
var tasks = Collections.labs.findOne({_id: labId}).tasks; | ||
var finalTasks = tasks.map(function(task){ | ||
if(task._id <= res.taskNo){ | ||
return {title: task.name, md: task.md}; | ||
} | ||
else{ | ||
return {title: task.name, md: null}; | ||
} | ||
}); | ||
callback(null,{sshInfo: sshInfo, taskList: finalTasks}); | ||
} | ||
}); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import isn't needed: