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

View File

@ -9,6 +9,8 @@ var common = require('./common');
function do_delete_instance(subcmd, opts, args, callback) { function do_delete_instance(subcmd, opts, args, callback) {
var self = this; var self = this;
var now = Date.now();
if (opts.help) { if (opts.help) {
this.do_help('help', {}, [subcmd], callback); this.do_help('help', {}, [subcmd], callback);
return; return;
@ -43,6 +45,8 @@ function do_delete_instance(subcmd, opts, args, callback) {
} }
if (!opts.wait) { if (!opts.wait) {
console.log('Deleted (async) instance %s (id %s, %s)',
arg, uuid, common.humanDurationFromMs(Date.now() - now));
callback(); callback();
return; return;
} }
@ -53,13 +57,15 @@ function do_delete_instance(subcmd, opts, args, callback) {
}, function (err, machine, res) { }, function (err, machine, res) {
if (res && res.statusCode === 410) { if (res && res.statusCode === 410) {
// gone... success! // gone... success!
console.log('Deleted instance %s (id %s, %s)',
arg, uuid, common.humanDurationFromMs(Date.now() - now));
callback(); callback();
return; return;
} else if (err) { } else if (err) {
callback(err); callback(err);
return; 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) { function _do_instance(action, subcmd, opts, args, callback) {
var self = this; var self = this;
var now = Date.now();
var command, state; var command, state;
switch (action) { switch (action) {
case 'start': case 'start':
@ -94,6 +96,9 @@ function _do_instance(action, subcmd, opts, args, callback) {
} }
if (!opts.wait) { if (!opts.wait) {
console.log('%s (async) instance %s (id %s, %s)',
common.capitalize(action), arg, uuid,
common.humanDurationFromMs(Date.now() - now));
callback(); callback();
return; return;
} }
@ -106,6 +111,9 @@ function _do_instance(action, subcmd, opts, args, callback) {
callback(err); callback(err);
return; return;
} }
console.log('%s instance %s (id %s, %s)',
common.capitalize(action), arg, uuid,
common.humanDurationFromMs(Date.now() - now));
callback(); callback();
}); });
}); });