From 40c710d601290879453812d070bf1d60bc29ab4c Mon Sep 17 00:00:00 2001 From: Dave Eddy Date: Wed, 26 Aug 2015 01:57:27 -0400 Subject: [PATCH] add output to start/stop/reboot/delete --- lib/common.js | 7 ++++++- lib/do_delete_instance.js | 8 +++++++- lib/do_startstop_instance.js | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/common.js b/lib/common.js index 7c6c5e9..15e87e5 100755 --- a/lib/common.js +++ b/lib/common.js @@ -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: diff --git a/lib/do_delete_instance.js b/lib/do_delete_instance.js index 464d7e5..ba24839 100644 --- a/lib/do_delete_instance.js +++ b/lib/do_delete_instance.js @@ -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')); }); }); } diff --git a/lib/do_startstop_instance.js b/lib/do_startstop_instance.js index 8b333a6..174e554 100644 --- a/lib/do_startstop_instance.js +++ b/lib/do_startstop_instance.js @@ -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(); }); });