diff --git a/routes/index.js b/routes/index.js index 138ef40..4d34f64 100644 --- a/routes/index.js +++ b/routes/index.js @@ -7,74 +7,74 @@ var lxc = require('../lxc')({sshBind: false/*['/usr/bin/ssh', 'virt@127.0.0.1']* //lxc.startEphemeral('ubuntu_template', 'ue0', function(){console.log('cb1', arguments)}, function(){console.log('cb2', arguments)}) router.get('/start/:name', function(req, res, next){ - lxc.start(req.params.name, function(status, message){ - if(status){ - res.json({status: 500, name: req.params.name, message: message}); - }else{ - setTimeout(function() { - lxc.info(req.params.name, null, function(data){ - var domain = req.query.domain || 'vm42.us'; - domain = req.params.name+'.'+domain; - client.SADD("hosts", domain, function(){}); - - var ip = data.ip + ':5000'; - client.HSET(domain, "ip", ip, redis.print); - client.HSET(domain, "updated", (new Date).getTime(), redis.print); - client.hset(domain, "include", "proxy.include"); - res.json({status: 200, info: data}); - }); - }, 5000); + lxc.start(req.params.name, function(status, message){ + if(status){ + res.json({status: 500, name: req.params.name, message: message}); + }else{ + setTimeout(function() { + lxc.info(req.params.name, null, function(data){ + var domain = req.query.domain || 'vm42.us'; + domain = req.params.name+'.'+domain; + client.SADD("hosts", domain, function(){}); + + var ip = data.ip + ':5000'; + client.HSET(domain, "ip", ip, redis.print); + client.HSET(domain, "updated", (new Date).getTime(), redis.print); + client.hset(domain, "include", "proxy.include"); + res.json({status: 200, info: data}); + }); + }, 5000); - } - }); + } + }); }); router.get('/live/:template/:name', function(req, res, next){ - lxc.startEphemeral(req.params.name, req.params.template, function (data) { - res.json(data); - }); + lxc.startEphemeral(req.params.name, req.params.template, function (data) { + res.json(data); + }); }); router.get('/stop/:name', function(req, res, next){ - lxc.stop(req.params.name, function(data, message){ - if(data){ - res.json({status: 500, name: req.params.name, message: message}); - }else{ - res.json({status: 200}); - } - }); + lxc.stop(req.params.name, function(data, message){ + if(data){ + res.json({status: 500, name: req.params.name, message: message}); + }else{ + res.json({status: 200}); + } + }); }); router.get('/clone/:template/:name', function(req, res, next){ - lxc.clone(req.params.name, req.params.template, function(message){ - if( message.match(/Created container/) ){ - res.json({status: 200}); - }else{ - res.json({status: 500, message: message}); - } - }); + lxc.clone(req.params.name, req.params.template, function(message){ + if( message.match(/Created container/) ){ + res.json({status: 200}); + }else{ + res.json({status: 500, message: message}); + } + }); }); router.get('/destroy/:name', function(req, res, next){ - lxc.destroy(req.params.name, function(data){ - if(data){ - res.json({status: 500, message: data}); - }else{ - res.json({status: 200}); - } - }); + lxc.destroy(req.params.name, function(data){ + if(data){ + res.json({status: 500, message: data}); + }else{ + res.json({status: 200}); + } + }); }); router.get('/info/:name', function(req, res, next){ - lxc.info(req.params.name, function(data){ - res.json(data); - }); + lxc.info(req.params.name, function(data){ + res.json(data); + }); }); router.get('/list', function(req, res, next) { - lxc.list(function(data){ - res.json(data); - }); + lxc.list(function(data){ + res.json(data); + }); }); module.exports = router;