formating
This commit is contained in:
parent
74aea9100f
commit
980c703540
@ -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)})
|
//lxc.startEphemeral('ubuntu_template', 'ue0', function(){console.log('cb1', arguments)}, function(){console.log('cb2', arguments)})
|
||||||
|
|
||||||
router.get('/start/:name', function(req, res, next){
|
router.get('/start/:name', function(req, res, next){
|
||||||
lxc.start(req.params.name, function(status, message){
|
lxc.start(req.params.name, function(status, message){
|
||||||
if(status){
|
if(status){
|
||||||
res.json({status: 500, name: req.params.name, message: message});
|
res.json({status: 500, name: req.params.name, message: message});
|
||||||
}else{
|
}else{
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
lxc.info(req.params.name, null, function(data){
|
lxc.info(req.params.name, null, function(data){
|
||||||
var domain = req.query.domain || 'vm42.us';
|
var domain = req.query.domain || 'vm42.us';
|
||||||
domain = req.params.name+'.'+domain;
|
domain = req.params.name+'.'+domain;
|
||||||
client.SADD("hosts", domain, function(){});
|
client.SADD("hosts", domain, function(){});
|
||||||
|
|
||||||
var ip = data.ip + ':5000';
|
var ip = data.ip + ':5000';
|
||||||
client.HSET(domain, "ip", ip, redis.print);
|
client.HSET(domain, "ip", ip, redis.print);
|
||||||
client.HSET(domain, "updated", (new Date).getTime(), redis.print);
|
client.HSET(domain, "updated", (new Date).getTime(), redis.print);
|
||||||
client.hset(domain, "include", "proxy.include");
|
client.hset(domain, "include", "proxy.include");
|
||||||
res.json({status: 200, info: data});
|
res.json({status: 200, info: data});
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/live/:template/:name', function(req, res, next){
|
router.get('/live/:template/:name', function(req, res, next){
|
||||||
lxc.startEphemeral(req.params.name, req.params.template, function (data) {
|
lxc.startEphemeral(req.params.name, req.params.template, function (data) {
|
||||||
res.json(data);
|
res.json(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/stop/:name', function(req, res, next){
|
router.get('/stop/:name', function(req, res, next){
|
||||||
lxc.stop(req.params.name, function(data, message){
|
lxc.stop(req.params.name, function(data, message){
|
||||||
if(data){
|
if(data){
|
||||||
res.json({status: 500, name: req.params.name, message: message});
|
res.json({status: 500, name: req.params.name, message: message});
|
||||||
}else{
|
}else{
|
||||||
res.json({status: 200});
|
res.json({status: 200});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/clone/:template/:name', function(req, res, next){
|
router.get('/clone/:template/:name', function(req, res, next){
|
||||||
lxc.clone(req.params.name, req.params.template, function(message){
|
lxc.clone(req.params.name, req.params.template, function(message){
|
||||||
if( message.match(/Created container/) ){
|
if( message.match(/Created container/) ){
|
||||||
res.json({status: 200});
|
res.json({status: 200});
|
||||||
}else{
|
}else{
|
||||||
res.json({status: 500, message: message});
|
res.json({status: 500, message: message});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/destroy/:name', function(req, res, next){
|
router.get('/destroy/:name', function(req, res, next){
|
||||||
lxc.destroy(req.params.name, function(data){
|
lxc.destroy(req.params.name, function(data){
|
||||||
if(data){
|
if(data){
|
||||||
res.json({status: 500, message: data});
|
res.json({status: 500, message: data});
|
||||||
}else{
|
}else{
|
||||||
res.json({status: 200});
|
res.json({status: 200});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/info/:name', function(req, res, next){
|
router.get('/info/:name', function(req, res, next){
|
||||||
lxc.info(req.params.name, function(data){
|
lxc.info(req.params.name, function(data){
|
||||||
res.json(data);
|
res.json(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/list', function(req, res, next) {
|
router.get('/list', function(req, res, next) {
|
||||||
lxc.list(function(data){
|
lxc.list(function(data){
|
||||||
res.json(data);
|
res.json(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user