add output to start/stop/reboot/delete

This commit is contained in:
Dave Eddy 2015-08-26 01:57:27 -04:00
parent e9cf0b37eb
commit 40c710d601
3 changed files with 21 additions and 2 deletions

View File

@ -189,6 +189,10 @@ function humanSizeFromBytes(bytes) {
return format('%s %s', precision1, sizes[i]);
}
function capitalize(s) {
return s[0].toUpperCase() + s.substr(1);
}
//---- exports
@ -203,6 +207,7 @@ module.exports = {
longAgo: longAgo,
isUUID: isUUID,
humanDurationFromMs: humanDurationFromMs,
humanSizeFromBytes: humanSizeFromBytes
humanSizeFromBytes: humanSizeFromBytes,
capitalize: capitalize
};
// vim: set softtabstop=4 shiftwidth=4:

View File

@ -9,6 +9,8 @@ var common = require('./common');
function do_delete_instance(subcmd, opts, args, callback) {
var self = this;
var now = Date.now();
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return;
@ -43,6 +45,8 @@ function do_delete_instance(subcmd, opts, args, callback) {
}
if (!opts.wait) {
console.log('Deleted (async) instance %s (id %s, %s)',
arg, uuid, common.humanDurationFromMs(Date.now() - now));
callback();
return;
}
@ -53,13 +57,15 @@ function do_delete_instance(subcmd, opts, args, callback) {
}, function (err, machine, res) {
if (res && res.statusCode === 410) {
// gone... success!
console.log('Deleted instance %s (id %s, %s)',
arg, uuid, common.humanDurationFromMs(Date.now() - now));
callback();
return;
} else if (err) {
callback(err);
return;
}
callback();
callback(new Error('unknown state'));
});
});
}

View File

@ -44,6 +44,8 @@ function do_startstop_instance(action) {
function _do_instance(action, subcmd, opts, args, callback) {
var self = this;
var now = Date.now();
var command, state;
switch (action) {
case 'start':
@ -94,6 +96,9 @@ function _do_instance(action, subcmd, opts, args, callback) {
}
if (!opts.wait) {
console.log('%s (async) instance %s (id %s, %s)',
common.capitalize(action), arg, uuid,
common.humanDurationFromMs(Date.now() - now));
callback();
return;
}
@ -106,6 +111,9 @@ function _do_instance(action, subcmd, opts, args, callback) {
callback(err);
return;
}
console.log('%s instance %s (id %s, %s)',
common.capitalize(action), arg, uuid,
common.humanDurationFromMs(Date.now() - now));
callback();
});
});