commit
b67c251e89
46
lxc.js
46
lxc.js
@ -6,41 +6,6 @@ module.exports = function(config){
|
||||
// console.log('sysExec: ', command, '||| callback:', callback)
|
||||
cmd.get('unset XDG_SESSION_ID XDG_RUNTIME_DIR; cgm movepid all virt $$; '+command, callback)
|
||||
}
|
||||
/* var obj = {};
|
||||
var child = require('child'),
|
||||
sshBind = config.sshBind || false;
|
||||
|
||||
//http://stackoverflow.com/questions/10530532/
|
||||
function textToArgs(s){
|
||||
var words = [];
|
||||
s.replace(/"([^"]*)"|'([^']*)'|(\S+)/g,function(g0,g1,g2,g3){ words.push(g1 || g2 || g3 || '')});
|
||||
return words;
|
||||
}
|
||||
|
||||
var sysExec = function(command, onData, onClose){
|
||||
|
||||
onData = onData || function(){};
|
||||
onClose = onClose || function(){};
|
||||
|
||||
if (sshBind != false)
|
||||
{
|
||||
var runCommand = sshBind.slice();
|
||||
runCommand.push(command);
|
||||
} else {
|
||||
var runCommand = textToArgs('unset XDG_SESSION_ID XDG_RUNTIME_DIR; cgm movepid all virt $$; '+command);
|
||||
}
|
||||
|
||||
var errors = '';
|
||||
|
||||
child({
|
||||
command: runCommand.slice(0,1)[0],
|
||||
args: runCommand.slice(1),
|
||||
cbStdout: function(data){ onData(''+data) },
|
||||
cbStderr: function(data){ errors+=data; onData(''+data) },
|
||||
cbClose: function(exitCode){ onClose(exitCode == 0 ? null:exitCode, errors) }
|
||||
}).start();
|
||||
};
|
||||
*/
|
||||
|
||||
obj.create = function(name, template, config, cbComplete){
|
||||
sysExec('lxc-create -n '+name+' -t '+template, cbComplete);
|
||||
@ -63,7 +28,6 @@ module.exports = function(config){
|
||||
};
|
||||
|
||||
obj.startEphemeral = function(name, base_name, callback){
|
||||
|
||||
var output = '';
|
||||
sysExec('lxc-start-ephemeral -o '+base_name+ ' -n '+name +' --union-type overlayfs -d', function(data){
|
||||
if(data.match("doesn't exist.")) return callback({status: 500, error: "doesn't exist."});
|
||||
@ -78,17 +42,15 @@ module.exports = function(config){
|
||||
sysExec('lxc-stop -n '+ name, callback);
|
||||
};
|
||||
|
||||
|
||||
obj.freeze = function(name, cbComplete, cbData){
|
||||
sysExec('lxc-freeze -n '+name, cbComplete, cbData);
|
||||
obj.freeze = function(name, callback){
|
||||
sysExec('lxc-freeze -n '+name, callback);
|
||||
};
|
||||
|
||||
obj.unfreeze = function(name, cbComplete, cbData){
|
||||
sysExec('lxc-unfreeze -n '+name, cbComplete, cbData);
|
||||
obj.unfreeze = function(name, callback){
|
||||
sysExec('lxc-unfreeze -n '+name, callback);
|
||||
};
|
||||
|
||||
obj.info = function(name, callback){
|
||||
|
||||
var output = '';
|
||||
sysExec('lxc-info -n '+name, function(data){
|
||||
console.log('info', name, data)
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user