From a4a1cf314aac7a6b1ec22f3c2ed371d149efa029 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:34:42 -0500 Subject: [PATCH 01/42] runner --- lxc.js | 309 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 215 insertions(+), 94 deletions(-) diff --git a/lxc.js b/lxc.js index a54a942..c6f7752 100644 --- a/lxc.js +++ b/lxc.js @@ -1,5 +1,28 @@ 'use strict'; var exec = require('child_process').exec; +var extend = require('node.extend'); + + +var parseArgs = function(required, takes, config){ + var all = Object.keys(config); + // console.log(all) + for(var i=required.length; i--;){ + if(all.indexOf(required[i]) !== -1){ + required.splice(i, 1); + } + } + + if(required.length !== 0) return false; + + var out = ''; + for(var i=0; i< takes.length; i++){ + if(all.indexOf(takes[i]) !== -1){ + out += '--'+takes[i]+' '+config[takes[i]]+' '; + } + } + + return out; +}; function sysExec(command, callback){ command = 'unset XDG_SESSION_ID XDG_RUNTIME_DIR; cgm movepid all virt $$; ' + command; @@ -13,126 +36,224 @@ function sysExec(command, callback){ })(callback)); }; + var Container = function(config){ this.name = config.name; - this.state = config.state; + this.state = config.state || 'STOPPED'; this.ip = config.ip || (config.ipv4 || '').replace('-', '') || null ; + this.overlayfs = null } -Container.prototype.autoShutDown = function(time) { - time = time || 600000; - - // this.__shutDownTimeout = setTimeout(function(){}, this.autoShutDown): +Container.prototype.clone = function(callback){ + var overlayfs = this.overlayfs : ' -B overlayfs -s ' ? ''; + + return sysExec('lxc-clone -o '+this.orig+ ' -n '+this.name + overlayfs, callback); }; -var lxcORM = function(){ - var orm = {} - lxc.list(function(data){ - for(var idx = data.length; idx--;){ - orm[data[idx].name] = new Container(data[idx]); - } +Container.prototype.start = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name'], + defaults: extend({}, this); + }); - return orm + return sysExec('lxc-start --daemon '+args, callback); }; -var lxc = { - create: function(name, template, config, callback){ - return sysExec('lxc-create -n '+name+' -t '+template, callback); - }, +Container.prototype.startEphemeral = function(callback){ + args = parseArgs({ + required: ['orig'], + takes: ['orig', 'name', 'key', 'union-type', 'keep-data'], + defaults: extend({}, this) + + }); - clone: function(name, base_name, callback){ - return sysExec('lxc-clone -o '+base_name+ ' -n '+name +' -B overlayfs -s', callback); - }, + var command = 'lxc-start-ephemeral --daemon '+args; + return sysExec(command, function(data){ + console.log('startEphemeral', arguments); + if(data.match("doesn't exist.")){ + return callback({status: 500, error: "doesn't exist."}); + } + if(data.match('already exists.')){ + return callback({status: 500, error: 'already exists'}); + } + if(data.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){ + return callback({status: 200, state:'RUNNING', ip: data.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0]}); + } - destroy: function(name, callback){ - return sysExec('lxc-destroy -n '+ name, function(data){ - var info = data.match(/Destroyed container/); - console.log('destroy info:', info); - var args = [true].concat(Array.prototype.slice.call(arguments, 1)); - return callback.apply(this, args); - }); - }, + callback({'?': '?', data: data, name: name, base_name: base_name}); + }); +}; - start: function(name, callback){ - return sysExec('lxc-start --name '+name+' --daemon', callback); - }, +Container.prototype.destroy = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name', 'force'], + defaults: extend({}, this) + }); - startEphemeral: function(name, base_name, callback){ - var command = 'lxc-start-ephemeral -o '+base_name+ ' -n '+name +' --union-type overlayfs -d'; - return sysExec(command, function(data){ - console.log('startEphemeral', arguments); - if(data.match("doesn't exist.")){ - return callback({status: 500, error: "doesn't exist."}); - } - if(data.match('already exists.')){ - return callback({status: 500, error: 'already exists'}); - } - if(data.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){ - return callback({status: 200, state:'RUNNING', ip: data.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0]}); - } + return sysExec('lxc-destroy '+ args, function(data){ + var info = data.match(/Destroyed container/); + console.log('destroy info:', info); + var args = [true].concat(Array.prototype.slice.call(arguments, 1)); + return callback.apply(this, args); + }); +}, - callback({'?': '?', data: data, name: name, base_name: base_name}); - }); - }, +Container.prototype.stop = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], + defaults: extend({}, this) + + }); + return sysExec('lxc-stop '+args, callback); +}; - stop: function(name, callback){ - return sysExec('lxc-stop -n '+ name, callback); - }, +Container.prototype.freeze = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name', 'force'], + defaults: extend({}, this) + }); + return sysExec('lxc-freeze -n '+name, callback); +}; - freeze: function(name, callback){ - return sysExec('lxc-freeze -n '+name, callback); - }, +Container.prototype.unfreeze = function(callback){ - unfreeze: function(name, callback){ - return sysExec('lxc-unfreeze -n '+name, callback); - }, + return sysExec('lxc-unfreeze --name '+this.name, callback); +}; - info: function(name, callback){ - return sysExec('lxc-info -n '+name, function(data){ - console.log('info', arguments); - if(data.match("doesn't exist")){ - return callback({state: 'NULL'}); - } +Container.prototype.info = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], + defaults: extend({}, this) + + }); + return sysExec('lxc-stop '+args, callback); +}; - var info = {}; - data = data.replace(/\suse/ig, '').replace(/\sbytes/ig, '').split("\n").slice(0,-1); - for(var i in data){ - var temp = data[i].split(/\:\s+/); - info[temp[0].toLowerCase().trim()] = temp[1].trim(); - } - var args = [info].concat(Array.prototype.slice.call(arguments, 1)); - callback.apply(this, args); - }); - }, +Container.prototype.freeze = function(callback){ + args = parseArgs({ + required: ['name'], + takes: ['name', 'force'], + defaults: extend({}, this) + }); + return sysExec('lxc-freeze -n '+name, callback); +}; - list: function(callback){ - sysExec('lxc-ls --fancy', function(data){ - var output = data.split("\n"); - var keys = output.splice(0,1)[0].split(/\s+/).slice(0,-1); - var info = []; +Container.prototype.unfreeze = function(callback){ - keys = keys.map(function(v){return v.toLowerCase()}); - output = output.slice(0).slice(0,-1); + return sysExec('lxc-unfreeze --name '+this.name, callback); +}; - for(var i in output){ - if(output[i].match(/^-/)) continue; // compatibility with 1.x and 2.x output +Container.prototype.info = function(callback){ + return sysExec('lxc-info --name '+this.name, function(data){ + console.log('info', arguments); + if(data.match("doesn't exist")){ + return callback({state: 'NULL'}); + } - var aIn = output[i].split(/\s+/).slice(0,-1); - var mapOut = {}; - aIn.map(function(value,idx){ - mapOut[keys[idx]] = value; - }); - info.push(mapOut); - - } - var args = [info].concat(Array.prototype.slice.call(arguments, 1)); - callback.apply(this, args); - }); + var info = {}; + data = data.replace(/\suse/ig, '').replace(/\sbytes/ig, '').split("\n").slice(0,-1); + for(var i in data){ + var temp = data[i].split(/\:\s+/); + info[temp[0].toLowerCase().trim()] = temp[1].trim(); + } + var args = [info].concat(Array.prototype.slice.call(arguments, 1)); + return callback.apply(this, args); + }); +}; + +Container.prototype.UpdateFromInfo = function(data){ + for(var key in Object.keys(data)){ + this[key] = data[key]; } + + return this; +} + + + + + + + + + + +var lxcORM = function(){ + this.containers = {} + lxc.list(function(data){ + for(var idx = data.length; idx--;){ + container[data[idx].name] = new Container(data[idx]); + } + }); + this.isReady = false; + this.whenReady = []; + }; -module.exports = lxc; +lxc.prototype.callReady = function(){ + for(var idx=0; idx Date: Sun, 7 Feb 2016 00:36:04 -0500 Subject: [PATCH 02/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index c6f7752..231a9db 100644 --- a/lxc.js +++ b/lxc.js @@ -45,7 +45,7 @@ var Container = function(config){ } Container.prototype.clone = function(callback){ - var overlayfs = this.overlayfs : ' -B overlayfs -s ' ? ''; + var overlayfs = this.overlayfs ? ' -B overlayfs -s ' : ''; return sysExec('lxc-clone -o '+this.orig+ ' -n '+this.name + overlayfs, callback); }; From c8a3d5c60d3e0f88db5f02213081905d019d4f05 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:36:31 -0500 Subject: [PATCH 03/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 231a9db..e7f8b6a 100644 --- a/lxc.js +++ b/lxc.js @@ -54,7 +54,7 @@ Container.prototype.start = function(callback){ args = parseArgs({ required: ['name'], takes: ['name'], - defaults: extend({}, this); + defaults: extend({}, this) }); From a8d53d5bc5d695d0b48888e07eca543a59c49e95 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:36:54 -0500 Subject: [PATCH 04/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index e7f8b6a..9cea3e2 100644 --- a/lxc.js +++ b/lxc.js @@ -196,7 +196,7 @@ var lxcORM = function(){ }; -lxc.prototype.callReady = function(){ +lxcORM.prototype.callReady = function(){ for(var idx=0; idx Date: Sun, 7 Feb 2016 00:37:28 -0500 Subject: [PATCH 05/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 9cea3e2..a610439 100644 --- a/lxc.js +++ b/lxc.js @@ -186,7 +186,7 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ this.containers = {} - lxc.list(function(data){ + this.list(function(data){ for(var idx = data.length; idx--;){ container[data[idx].name] = new Container(data[idx]); } From 303c80f601af1777956fb20a4a8cbe484cbf18da Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:37:46 -0500 Subject: [PATCH 06/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index a610439..19c5da0 100644 --- a/lxc.js +++ b/lxc.js @@ -253,7 +253,7 @@ lxcORM.prototype.list= function(callback){ // module.exports = lxc; var orm = new lxcORM() -lxc.ready(function(){ +orm.ready(function(){ console.log(arguments, this); }) // setTimeout(function(){console.log(orm)}, 5000) From b27f0d6bd9cca990dede1221ca7dcc7f6dc6d2be Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:38:38 -0500 Subject: [PATCH 07/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 19c5da0..6e3c708 100644 --- a/lxc.js +++ b/lxc.js @@ -207,7 +207,7 @@ lxcORM.prototype.ready = function(callback){ return callback.apply(this); } else{ - this.whenReady.append(callback); + this.whenReady.push(callback); } } From ee57ab01e1a9ca137d8849aa28bc22d54a6f66c7 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:38:55 -0500 Subject: [PATCH 08/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 6e3c708..9b151d0 100644 --- a/lxc.js +++ b/lxc.js @@ -188,7 +188,7 @@ var lxcORM = function(){ this.containers = {} this.list(function(data){ for(var idx = data.length; idx--;){ - container[data[idx].name] = new Container(data[idx]); + containers[data[idx].name] = new Container(data[idx]); } }); this.isReady = false; From 55813dc42214d1698120b79346bc5af199f4984d Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:39:34 -0500 Subject: [PATCH 09/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 9b151d0..b4fceb9 100644 --- a/lxc.js +++ b/lxc.js @@ -188,7 +188,7 @@ var lxcORM = function(){ this.containers = {} this.list(function(data){ for(var idx = data.length; idx--;){ - containers[data[idx].name] = new Container(data[idx]); + this.containers[data[idx].name] = new Container(data[idx]); } }); this.isReady = false; From 5df3ecd5af470c708c0664f223c8bce1aeec25eb Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:41:16 -0500 Subject: [PATCH 10/42] runner --- lxc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lxc.js b/lxc.js index b4fceb9..c0803cf 100644 --- a/lxc.js +++ b/lxc.js @@ -188,6 +188,7 @@ var lxcORM = function(){ this.containers = {} this.list(function(data){ for(var idx = data.length; idx--;){ + console.log(data[idx].name) this.containers[data[idx].name] = new Container(data[idx]); } }); From 0c891f62efa354d71b15caef78fa34b99a4aa8d7 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:42:45 -0500 Subject: [PATCH 11/42] runner --- lxc.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index c0803cf..01e9029 100644 --- a/lxc.js +++ b/lxc.js @@ -186,21 +186,24 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ this.containers = {} + this.isReady = false; + this.whenReady = []; + this.list(function(data){ for(var idx = data.length; idx--;){ console.log(data[idx].name) this.containers[data[idx].name] = new Container(data[idx]); } }); - this.isReady = false; - this.whenReady = []; + this.callReady(); }; lxcORM.prototype.callReady = function(){ for(var idx=0; idx Date: Sun, 7 Feb 2016 00:45:48 -0500 Subject: [PATCH 12/42] runner --- lxc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index 01e9029..703de8c 100644 --- a/lxc.js +++ b/lxc.js @@ -185,17 +185,17 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - this.containers = {} + containers = {} this.isReady = false; this.whenReady = []; this.list(function(data){ for(var idx = data.length; idx--;){ console.log(data[idx].name) - this.containers[data[idx].name] = new Container(data[idx]); + containers[data[idx].name] = new Container(data[idx]); } }); - + this.containers = containers this.callReady(); }; From 45bf9c67f6509a5be148b2876a99cfd5f5b46272 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:46:02 -0500 Subject: [PATCH 13/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 703de8c..373d0e6 100644 --- a/lxc.js +++ b/lxc.js @@ -185,7 +185,7 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - containers = {} + var containers = {} this.isReady = false; this.whenReady = []; From 85e0dcf729efef0b0aab1025e3032508b6b70204 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:47:07 -0500 Subject: [PATCH 14/42] runner --- lxc.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index 373d0e6..e1fe5dc 100644 --- a/lxc.js +++ b/lxc.js @@ -193,10 +193,13 @@ var lxcORM = function(){ for(var idx = data.length; idx--;){ console.log(data[idx].name) containers[data[idx].name] = new Container(data[idx]); + if(idx===0){ + this.containers = containers + this.callReady(); + } } }); - this.containers = containers - this.callReady(); + }; lxcORM.prototype.callReady = function(){ From 025205e34949c04f5111581520907ec131508607 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:47:32 -0500 Subject: [PATCH 15/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index e1fe5dc..4c53f90 100644 --- a/lxc.js +++ b/lxc.js @@ -194,11 +194,11 @@ var lxcORM = function(){ console.log(data[idx].name) containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - this.containers = containers this.callReady(); } } }); + this.containers = containers }; From 7c37aa2e8be8fb52b857e1ffbf9f914016b73cc2 Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:59:29 -0500 Subject: [PATCH 16/42] runner --- lxc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 4c53f90..84c70c9 100644 --- a/lxc.js +++ b/lxc.js @@ -188,13 +188,14 @@ var lxcORM = function(){ var containers = {} this.isReady = false; this.whenReady = []; + callReady = this.callReady; this.list(function(data){ for(var idx = data.length; idx--;){ console.log(data[idx].name) containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - this.callReady(); + callReady(); } } }); From 708c5ea5d391720b55ff2b794b97efae4c98c7bc Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 00:59:53 -0500 Subject: [PATCH 17/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 84c70c9..5ee14a8 100644 --- a/lxc.js +++ b/lxc.js @@ -188,7 +188,7 @@ var lxcORM = function(){ var containers = {} this.isReady = false; this.whenReady = []; - callReady = this.callReady; + var callReady = this.callReady; this.list(function(data){ for(var idx = data.length; idx--;){ From d438cdd249065d1cad1f6480da486d8ef0e1c70e Mon Sep 17 00:00:00 2001 From: william Date: Sun, 7 Feb 2016 01:01:07 -0500 Subject: [PATCH 18/42] runner --- lxc.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index 5ee14a8..c27e49c 100644 --- a/lxc.js +++ b/lxc.js @@ -188,14 +188,13 @@ var lxcORM = function(){ var containers = {} this.isReady = false; this.whenReady = []; - var callReady = this.callReady; + var callthis = this; this.list(function(data){ for(var idx = data.length; idx--;){ - console.log(data[idx].name) containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - callReady(); + callthis.callReady(); } } }); From a1a0ec8d02965e5d88b0c97247d9e47cecadc6f4 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:13:03 -0500 Subject: [PATCH 19/42] runner --- lxc.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lxc.js b/lxc.js index c27e49c..2738d60 100644 --- a/lxc.js +++ b/lxc.js @@ -188,17 +188,17 @@ var lxcORM = function(){ var containers = {} this.isReady = false; this.whenReady = []; - var callthis = this; + var that = this this.list(function(data){ for(var idx = data.length; idx--;){ containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - callthis.callReady(); + that.callReady; } } }); - this.containers = containers + this.containers = containers; }; @@ -207,7 +207,7 @@ lxcORM.prototype.callReady = function(){ this.whenReady[idx].apply(this); } this.isReady = true; -} +}; lxcORM.prototype.ready = function(callback){ if(this.isReady){ @@ -216,7 +216,7 @@ lxcORM.prototype.ready = function(callback){ else{ this.whenReady.push(callback); } -} +}; lxcORM.prototype.create = function(args, callback){ @@ -230,7 +230,7 @@ lxcORM.prototype.create = function(args, callback){ return sysExec('lxc-create '+args, callback); }; -lxcORM.prototype.list= function(callback){ +lxcORM.prototype.list = function(callback){ sysExec('lxc-ls --fancy', function(data){ var output = data.split("\n"); var keys = output.splice(0,1)[0].split(/\s+/).slice(0,-1); From b0ab1a5313e64a9a383870903a1c76a636effb0d Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:18:12 -0500 Subject: [PATCH 20/42] runner --- lxc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index 2738d60..65c894d 100644 --- a/lxc.js +++ b/lxc.js @@ -257,10 +257,10 @@ lxcORM.prototype.list = function(callback){ -// module.exports = lxc; +module.exports = lxcORM; var orm = new lxcORM() orm.ready(function(){ - console.log(arguments, this); + console.log('calling ready', arguments, this); }) // setTimeout(function(){console.log(orm)}, 5000) From f8ff072690273bbfb18ea0055688af72a9ef010e Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:25:48 -0500 Subject: [PATCH 21/42] runner --- lxc.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lxc.js b/lxc.js index 65c894d..02068ac 100644 --- a/lxc.js +++ b/lxc.js @@ -3,21 +3,21 @@ var exec = require('child_process').exec; var extend = require('node.extend'); -var parseArgs = function(required, takes, config){ - var all = Object.keys(config); +var parseArgs = function(config){ + var all = Object.keys(config.defaults); // console.log(all) - for(var i=required.length; i--;){ - if(all.indexOf(required[i]) !== -1){ - required.splice(i, 1); + for(var i=congif.required.length; i--;){ + if(all.indexOf(congif.required[i]) !== -1){ + congif.required.splice(i, 1); } } - if(required.length !== 0) return false; + if(congif.required.length !== 0) return false; var out = ''; - for(var i=0; i< takes.length; i++){ - if(all.indexOf(takes[i]) !== -1){ - out += '--'+takes[i]+' '+config[takes[i]]+' '; + for(var i=0; i< congif.takes.length; i++){ + if(all.indexOf(congif.takes[i]) !== -1){ + out += '--'+congif.takes[i]+' '+config.defaults[takes[i]]+' '; } } From e7987d8035abdce8ce3678b1e441c317f1dd19ce Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:30:01 -0500 Subject: [PATCH 22/42] runner --- lxc.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lxc.js b/lxc.js index 02068ac..de49a8e 100644 --- a/lxc.js +++ b/lxc.js @@ -6,18 +6,18 @@ var extend = require('node.extend'); var parseArgs = function(config){ var all = Object.keys(config.defaults); // console.log(all) - for(var i=congif.required.length; i--;){ - if(all.indexOf(congif.required[i]) !== -1){ - congif.required.splice(i, 1); + for(var i=config.required.length; i--;){ + if(all.indexOf(config.required[i]) !== -1){ + config.required.splice(i, 1); } } - if(congif.required.length !== 0) return false; + if(config.required.length !== 0) return false; var out = ''; - for(var i=0; i< congif.takes.length; i++){ - if(all.indexOf(congif.takes[i]) !== -1){ - out += '--'+congif.takes[i]+' '+config.defaults[takes[i]]+' '; + for(var i=0; i< config.takes.length; i++){ + if(all.indexOf(config.takes[i]) !== -1){ + out += '--'+config.takes[i]+' '+config.defaults[takes[i]]+' '; } } From 238cfd94b3359012057c7e598dde6a5d457d2d11 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:32:43 -0500 Subject: [PATCH 23/42] runner --- lxc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lxc.js b/lxc.js index de49a8e..b79ad06 100644 --- a/lxc.js +++ b/lxc.js @@ -4,6 +4,7 @@ var extend = require('node.extend'); var parseArgs = function(config){ + console.log(config) var all = Object.keys(config.defaults); // console.log(all) for(var i=config.required.length; i--;){ From f19c673764f8e2ca3a0734a44a6101a18685157b Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:34:26 -0500 Subject: [PATCH 24/42] runner --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index b79ad06..3bc7a91 100644 --- a/lxc.js +++ b/lxc.js @@ -18,7 +18,7 @@ var parseArgs = function(config){ var out = ''; for(var i=0; i< config.takes.length; i++){ if(all.indexOf(config.takes[i]) !== -1){ - out += '--'+config.takes[i]+' '+config.defaults[takes[i]]+' '; + out += '--'+config.takes[i]+' '+config.defaults[config.takes[i]]+' '; } } From c8d32de96d37952d39adb5a1a658497232dc6d47 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 10:39:55 -0500 Subject: [PATCH 25/42] runner --- lxc.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lxc.js b/lxc.js index 3bc7a91..6d70fe2 100644 --- a/lxc.js +++ b/lxc.js @@ -52,7 +52,7 @@ Container.prototype.clone = function(callback){ }; Container.prototype.start = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name'], defaults: extend({}, this) @@ -63,7 +63,7 @@ Container.prototype.start = function(callback){ }; Container.prototype.startEphemeral = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['orig'], takes: ['orig', 'name', 'key', 'union-type', 'keep-data'], defaults: extend({}, this) @@ -88,7 +88,7 @@ Container.prototype.startEphemeral = function(callback){ }; Container.prototype.destroy = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -103,7 +103,7 @@ Container.prototype.destroy = function(callback){ }, Container.prototype.stop = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -113,7 +113,7 @@ Container.prototype.stop = function(callback){ }; Container.prototype.freeze = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -127,7 +127,7 @@ Container.prototype.unfreeze = function(callback){ }; Container.prototype.info = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -137,7 +137,7 @@ Container.prototype.info = function(callback){ }; Container.prototype.freeze = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -186,28 +186,27 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - var containers = {} + var orm = this; + var containers = {}; this.isReady = false; this.whenReady = []; - var that = this this.list(function(data){ for(var idx = data.length; idx--;){ - containers[data[idx].name] = new Container(data[idx]); + orm.containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - that.callReady; + orm.callReady; } } }); - this.containers = containers; }; lxcORM.prototype.callReady = function(){ + this.isReady = true; for(var idx=0; idx Date: Mon, 8 Feb 2016 13:28:45 -0500 Subject: [PATCH 26/42] stuff --- lxc.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lxc.js b/lxc.js index 6d70fe2..3d6223f 100644 --- a/lxc.js +++ b/lxc.js @@ -256,11 +256,4 @@ lxcORM.prototype.list = function(callback){ }; - -module.exports = lxcORM; - -var orm = new lxcORM() -orm.ready(function(){ - console.log('calling ready', arguments, this); -}) -// setTimeout(function(){console.log(orm)}, 5000) +module.exports = new lxcORM(); From 46ad5ae25dcdca22f53f8f736287bbe97a6a6e8a Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 13:49:59 -0500 Subject: [PATCH 27/42] stuff --- lxc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index 3d6223f..5469af3 100644 --- a/lxc.js +++ b/lxc.js @@ -186,16 +186,16 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - var orm = this; + var that = this; var containers = {}; this.isReady = false; this.whenReady = []; this.list(function(data){ for(var idx = data.length; idx--;){ - orm.containers[data[idx].name] = new Container(data[idx]); + that.containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - orm.callReady; + that.callReady; } } }); From c77ee3a00731b1851e8eb247352bec8736485bb9 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 13:51:15 -0500 Subject: [PATCH 28/42] stuff --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 5469af3..9c2dd2b 100644 --- a/lxc.js +++ b/lxc.js @@ -186,10 +186,10 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - var that = this; var containers = {}; this.isReady = false; this.whenReady = []; + var that = this; this.list(function(data){ for(var idx = data.length; idx--;){ From ee7ff554e7ede418c192bce3748bce8947e6a176 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 13:52:31 -0500 Subject: [PATCH 29/42] stuff --- lxc.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lxc.js b/lxc.js index 9c2dd2b..902cef8 100644 --- a/lxc.js +++ b/lxc.js @@ -52,7 +52,7 @@ Container.prototype.clone = function(callback){ }; Container.prototype.start = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name'], defaults: extend({}, this) @@ -63,7 +63,7 @@ Container.prototype.start = function(callback){ }; Container.prototype.startEphemeral = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['orig'], takes: ['orig', 'name', 'key', 'union-type', 'keep-data'], defaults: extend({}, this) @@ -88,7 +88,7 @@ Container.prototype.startEphemeral = function(callback){ }; Container.prototype.destroy = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -103,7 +103,7 @@ Container.prototype.destroy = function(callback){ }, Container.prototype.stop = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -113,7 +113,7 @@ Container.prototype.stop = function(callback){ }; Container.prototype.freeze = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -127,7 +127,7 @@ Container.prototype.unfreeze = function(callback){ }; Container.prototype.info = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -137,7 +137,7 @@ Container.prototype.info = function(callback){ }; Container.prototype.freeze = function(callback){ - var args = parseArgs({ + args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -186,10 +186,10 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - var containers = {}; + var containers = {} this.isReady = false; this.whenReady = []; - var that = this; + var that = this this.list(function(data){ for(var idx = data.length; idx--;){ @@ -203,10 +203,10 @@ var lxcORM = function(){ }; lxcORM.prototype.callReady = function(){ - this.isReady = true; for(var idx=0; idx Date: Mon, 8 Feb 2016 13:53:25 -0500 Subject: [PATCH 30/42] stuff --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 902cef8..66a3038 100644 --- a/lxc.js +++ b/lxc.js @@ -186,7 +186,7 @@ Container.prototype.UpdateFromInfo = function(data){ var lxcORM = function(){ - var containers = {} + this.containers = {} this.isReady = false; this.whenReady = []; var that = this From 64af338a6c024ae8c626c20e5f7616662348883d Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 13:55:43 -0500 Subject: [PATCH 31/42] stuff --- lxc.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lxc.js b/lxc.js index 66a3038..7040135 100644 --- a/lxc.js +++ b/lxc.js @@ -257,10 +257,4 @@ lxcORM.prototype.list = function(callback){ -module.exports = lxcORM; - -var orm = new lxcORM() -orm.ready(function(){ - console.log('calling ready', arguments, this); -}) -// setTimeout(function(){console.log(orm)}, 5000) +module.exports = new lxcORM(); From 469d4deb7efc629358bef7e4014fe04d1f9330b3 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 13:57:37 -0500 Subject: [PATCH 32/42] stuff --- lxc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lxc.js b/lxc.js index 7040135..d20bd76 100644 --- a/lxc.js +++ b/lxc.js @@ -195,6 +195,7 @@ var lxcORM = function(){ for(var idx = data.length; idx--;){ that.containers[data[idx].name] = new Container(data[idx]); if(idx===0){ + console.log('call ready!') that.callReady; } } From 517690a4545c0fb9a320d6a29772782837bce665 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 14:00:19 -0500 Subject: [PATCH 33/42] stuff --- lxc.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lxc.js b/lxc.js index d20bd76..3c666e9 100644 --- a/lxc.js +++ b/lxc.js @@ -52,7 +52,7 @@ Container.prototype.clone = function(callback){ }; Container.prototype.start = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name'], defaults: extend({}, this) @@ -63,7 +63,7 @@ Container.prototype.start = function(callback){ }; Container.prototype.startEphemeral = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['orig'], takes: ['orig', 'name', 'key', 'union-type', 'keep-data'], defaults: extend({}, this) @@ -88,7 +88,7 @@ Container.prototype.startEphemeral = function(callback){ }; Container.prototype.destroy = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -103,7 +103,7 @@ Container.prototype.destroy = function(callback){ }, Container.prototype.stop = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -113,7 +113,7 @@ Container.prototype.stop = function(callback){ }; Container.prototype.freeze = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -127,7 +127,7 @@ Container.prototype.unfreeze = function(callback){ }; Container.prototype.info = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'reboot', 'nowait', 'timeout', 'kill'], defaults: extend({}, this) @@ -137,7 +137,7 @@ Container.prototype.info = function(callback){ }; Container.prototype.freeze = function(callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name'], takes: ['name', 'force'], defaults: extend({}, this) @@ -180,23 +180,18 @@ Container.prototype.UpdateFromInfo = function(data){ - - - - - var lxcORM = function(){ - this.containers = {} + this.containers = {}; this.isReady = false; this.whenReady = []; - var that = this + var that = this; this.list(function(data){ for(var idx = data.length; idx--;){ that.containers[data[idx].name] = new Container(data[idx]); if(idx===0){ console.log('call ready!') - that.callReady; + that.callReady(); } } }); @@ -221,7 +216,7 @@ lxcORM.prototype.ready = function(callback){ lxcORM.prototype.create = function(args, callback){ - args = parseArgs({ + var args = parseArgs({ required: ['name', 'template'], takes: ['name', 'template', ' ', 'd', 'r', 'a'], defaults: extend({template:'download', ' ': ' ', d: 'ubuntu', r: 'trusty', a: 'amd64'}, args) From 1e3f9a73029ca6742ef36f960fb1a66256870243 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 16:42:08 -0500 Subject: [PATCH 34/42] stuff --- lxc.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index 3c666e9..fcca587 100644 --- a/lxc.js +++ b/lxc.js @@ -52,13 +52,17 @@ Container.prototype.clone = function(callback){ }; Container.prototype.start = function(callback){ + var that = this; var args = parseArgs({ required: ['name'], takes: ['name'], defaults: extend({}, this) }); - + callback = function(callback){ + that.info(); + return callback; + }; return sysExec('lxc-start --daemon '+args, callback); }; @@ -151,6 +155,8 @@ Container.prototype.unfreeze = function(callback){ }; Container.prototype.info = function(callback){ + var that = this; + return sysExec('lxc-info --name '+this.name, function(data){ console.log('info', arguments); if(data.match("doesn't exist")){ @@ -163,6 +169,9 @@ Container.prototype.info = function(callback){ var temp = data[i].split(/\:\s+/); info[temp[0].toLowerCase().trim()] = temp[1].trim(); } + + that.UpdateFromInfo(info); + var args = [info].concat(Array.prototype.slice.call(arguments, 1)); return callback.apply(this, args); }); From 8ce30f1e604bb775cba627c985c78a0720a979bf Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 16:46:54 -0500 Subject: [PATCH 35/42] stuff --- lxc.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index fcca587..d245a0c 100644 --- a/lxc.js +++ b/lxc.js @@ -52,13 +52,14 @@ Container.prototype.clone = function(callback){ }; Container.prototype.start = function(callback){ - var that = this; var args = parseArgs({ required: ['name'], takes: ['name'], defaults: extend({}, this) }); + + var that = this; callback = function(callback){ that.info(); return callback; @@ -113,6 +114,11 @@ Container.prototype.stop = function(callback){ defaults: extend({}, this) }); + var that = this; + callback = function(callback){ + that.info(); + return callback; + }; return sysExec('lxc-stop '+args, callback); }; @@ -158,7 +164,7 @@ Container.prototype.info = function(callback){ var that = this; return sysExec('lxc-info --name '+this.name, function(data){ - console.log('info', arguments); + // console.log('info', arguments); if(data.match("doesn't exist")){ return callback({state: 'NULL'}); } @@ -199,7 +205,7 @@ var lxcORM = function(){ for(var idx = data.length; idx--;){ that.containers[data[idx].name] = new Container(data[idx]); if(idx===0){ - console.log('call ready!') + // console.log('call ready!') that.callReady(); } } From 99dcc47e00a6fa603c041e7e1b810d9516e621d3 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 16:48:45 -0500 Subject: [PATCH 36/42] stuff --- lxc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lxc.js b/lxc.js index d245a0c..25d8ae9 100644 --- a/lxc.js +++ b/lxc.js @@ -162,6 +162,7 @@ Container.prototype.unfreeze = function(callback){ Container.prototype.info = function(callback){ var that = this; + callback = callback || function(){} return sysExec('lxc-info --name '+this.name, function(data){ // console.log('info', arguments); From 1ee46f6d2cd3ec55d09a1a193f7487f8208f41c0 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 16:56:54 -0500 Subject: [PATCH 37/42] stuff --- lxc.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index 25d8ae9..4981e24 100644 --- a/lxc.js +++ b/lxc.js @@ -177,15 +177,16 @@ Container.prototype.info = function(callback){ info[temp[0].toLowerCase().trim()] = temp[1].trim(); } - that.UpdateFromInfo(info); + that.updateFromInfo(info); var args = [info].concat(Array.prototype.slice.call(arguments, 1)); - return callback.apply(this, args); + return callback.apply(that, args); }); }; -Container.prototype.UpdateFromInfo = function(data){ +Container.prototype.updateFromInfo = function(data){ for(var key in Object.keys(data)){ + console.log('update key:', key); this[key] = data[key]; } From a74d7130d7ad8a1950690a4b3f8f04bcff3bb42c Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 17:03:45 -0500 Subject: [PATCH 38/42] stuff --- lxc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lxc.js b/lxc.js index 4981e24..8424af9 100644 --- a/lxc.js +++ b/lxc.js @@ -185,9 +185,9 @@ Container.prototype.info = function(callback){ }; Container.prototype.updateFromInfo = function(data){ - for(var key in Object.keys(data)){ - console.log('update key:', key); - this[key] = data[key]; + var key = Object.keys(data); + for(var i=keys.length; i--;){ + this[key[i]] = data[key[i]]; } return this; From 3b89660ef15293f3bc1a34858ddf5c1c8e730572 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 17:05:18 -0500 Subject: [PATCH 39/42] stuff --- lxc.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index 8424af9..afcf1b6 100644 --- a/lxc.js +++ b/lxc.js @@ -4,7 +4,6 @@ var extend = require('node.extend'); var parseArgs = function(config){ - console.log(config) var all = Object.keys(config.defaults); // console.log(all) for(var i=config.required.length; i--;){ @@ -185,7 +184,7 @@ Container.prototype.info = function(callback){ }; Container.prototype.updateFromInfo = function(data){ - var key = Object.keys(data); + var keys = Object.keys(data); for(var i=keys.length; i--;){ this[key[i]] = data[key[i]]; } From 81bda27acdfc0ff4c2c110cd83986630d48390ec Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 17:06:46 -0500 Subject: [PATCH 40/42] stuff --- lxc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc.js b/lxc.js index afcf1b6..cdfa9bd 100644 --- a/lxc.js +++ b/lxc.js @@ -186,7 +186,7 @@ Container.prototype.info = function(callback){ Container.prototype.updateFromInfo = function(data){ var keys = Object.keys(data); for(var i=keys.length; i--;){ - this[key[i]] = data[key[i]]; + this[keys[i]] = data[keys[i]]; } return this; From 2dba8c9c4f32187cf0ed20ff37800539762f3bf7 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 17:19:18 -0500 Subject: [PATCH 41/42] stuff --- lxc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index cdfa9bd..9dddca5 100644 --- a/lxc.js +++ b/lxc.js @@ -113,7 +113,7 @@ Container.prototype.stop = function(callback){ defaults: extend({}, this) }); - var that = this; + var that = this; callback = function(callback){ that.info(); return callback; @@ -184,7 +184,7 @@ Container.prototype.info = function(callback){ }; Container.prototype.updateFromInfo = function(data){ - var keys = Object.keys(data); + var keys = ['state', 'ip', 'total', 'rx', 'tx', 'link', 'kmem', 'memory', 'blkio', 'cpu', 'pid']; for(var i=keys.length; i--;){ this[keys[i]] = data[keys[i]]; } From e481f1c071bdf4636f73b325e10cb9c09f9554fb Mon Sep 17 00:00:00 2001 From: william Date: Mon, 8 Feb 2016 17:22:51 -0500 Subject: [PATCH 42/42] stuff --- lxc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxc.js b/lxc.js index 9dddca5..1baa632 100644 --- a/lxc.js +++ b/lxc.js @@ -40,8 +40,8 @@ function sysExec(command, callback){ var Container = function(config){ this.name = config.name; this.state = config.state || 'STOPPED'; - this.ip = config.ip || (config.ipv4 || '').replace('-', '') || null ; - this.overlayfs = null + this.ip = config.ip || (config.ipv4 || '').replace('-', '') || null; + this.overlayfs = undefined; } Container.prototype.clone = function(callback){