Skip to content

Commit 5ff3395

Browse files
committed
Merge branch 'requires-infra' of https://github.com/learnlinux/tuxlab-app into requires-infra
2 parents cac069e + 22664aa commit 5ff3395

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

server/imports/api/lab.env.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ env.prototype.shell = function(vmName,command,opts) {
370370
*/
371371
env.prototype.getPass = function(vmName,callback){
372372
this.shell1(vmName, "cat /pass")
373-
.then(function(sOut){ callback(null,null,sOut); }, function(s1,s2,s3){callback(s1,s2,s3);});
373+
.then(function(sOut){ callback(null,sOut); }, function(s1,s2,s3){
374+
if(s1){ callback(s1,s3) }
375+
else{ callback(s2,s3) }
376+
});
374377
}
375378
env.prototype.getNetwork = function() {} //Don't know what this does
376379
env.prototype.getVolume = function() {} //Don't know what this does

server/imports/api/lab.session.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ session.prototype.init = function(user,labId,callback){
4545
});
4646

4747
slf.lab.taskNo = 0;
48-
callback(null, lab.tasks);
48+
slf.env.getPass(callback);
4949
}
5050
else{
5151
// Get LabFile from Cache
5252
slf.lab.taskNo = 0;
5353
slf.lab = value;
54-
callback(null, lab.tasks);
54+
slf.env.getPass(callback);
5555
}
5656
});
5757
}
@@ -125,4 +125,4 @@ session.prototype.end = function(callback){
125125
});
126126
}
127127

128-
module.exports = new session();
128+
module.exports = session;

server/imports/lab/methods.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
11
declare var Collections : any;
22
declare var TuxLog : any;
33

4+
var Session = require('../api/lab.session.js');
45
Meteor.methods({
56

6-
/** prepareLab: prepares a labExec object for the current user
7-
* takes the id of the lab and a callback as parameter
8-
* callback: (err,parseTasks,labExec)
7+
/**prepareLab: prepares a labExec object for the current user
8+
* takes the id of the lab and a callback as parameter
9+
* callback: (err,pass)
10+
* implement loading wheel, md fetch, course record create in callback
911
*/
10-
'prepareLab' : function(labId : number, callback : any){
11-
var session = require('../api/lab.session.js');
12-
var userid = Meteor.userId();
13-
14-
/** session.init(userId,labId,cb)
15-
* cb(err,parsedTasks) cache session in cb, get rid of parsedTasks if unnecessary
16-
* implement loading wheel here -in callback
17-
* session.env.getPass(cb) callback(pass) is called, call this here and then call the prepareLab callback
18-
* what to put in res of callback(err,res)? session obj? true/false? session id?...
19-
* get task md -frontend
20-
* create course record
21-
*/
22-
session.init(userid,labId,function(err,res){
23-
session.env.getPass(function(err,pass){
24-
if(err){
25-
TuxLog.log("debug","error getting pass from labVm container: "+err);
26-
callback("Internal Service Error",null);
27-
}
28-
else{
29-
var resp = {'pass': pass}
30-
callback(null, resp);
31-
}
32-
});
33-
});
12+
'prepareLab': function(labId : number, callback : any){
13+
var session = Session();
14+
var uId = Meteor.userId();
15+
session.init(uId,labId,callback);
3416
},
3517
'startLab': function(callback : any){
3618
/** somehow get session,

0 commit comments

Comments
 (0)