From 389d44f97313d20183e7816031ac43af651e8e78 Mon Sep 17 00:00:00 2001 From: Anu Chandy Date: Wed, 20 Jun 2012 11:23:46 -0700 Subject: [PATCH 1/3] Fixed bug of not showing empty list [] for --json when there is no VM --- lib/cli/commands/vm.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cli/commands/vm.js b/lib/cli/commands/vm.js index 5d65db7d1d..7a2e29ab93 100644 --- a/lib/cli/commands/vm.js +++ b/lib/cli/commands/vm.js @@ -1028,7 +1028,11 @@ exports.init = function(cli) { cmdCallback(); } else { - logger.info('No VMs found'); + if (logger.format().json) { + logger.json([]); + } else { + logger.info('No VMs found'); + } cmdCallback(); } }); From 8e21bf4a1dc637d6befd00ea9af39c5d59b4e5a6 Mon Sep 17 00:00:00 2001 From: Anu Chandy Date: Wed, 20 Jun 2012 12:35:50 -0700 Subject: [PATCH 2/3] Fixed bug of not stopping spinning control in case of vm disk list when there is no deployment or VM --- lib/cli/iaas/image.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/cli/iaas/image.js b/lib/cli/iaas/image.js index d5d63ca952..fe5b4c82c9 100644 --- a/lib/cli/iaas/image.js +++ b/lib/cli/iaas/image.js @@ -342,7 +342,7 @@ function listDisks(cli, options, cmdCallback) { } } - // got unique role under a deployment and service, list the endpoints + // got unique role under a deployment and service, list the disks if (found) { var osDiskName = foundDisks[0].DiskName; logger.verbose('Getting info for OS disk ' + osDiskName); @@ -359,8 +359,12 @@ function listDisks(cli, options, cmdCallback) { cmdCallback(error); }); } else { - cmdCallback('No VMs found'); + progress.end(); + cmdCallback('VM ' + options.name + ' not found'); } + } else { + progress.end(); + cmdCallback('VM ' + options.name + ' not found'); } }); } From 04bea4710aeb6ddcbda1f3179da0d031c8ed0708 Mon Sep 17 00:00:00 2001 From: Anu Chandy Date: Wed, 20 Jun 2012 16:18:31 -0700 Subject: [PATCH 3/3] Incorporated review comments --- lib/cli/commands/vm.js | 21 +++++++-------------- lib/cli/iaas/image.js | 10 ++++------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/cli/commands/vm.js b/lib/cli/commands/vm.js index 7a2e29ab93..192b34b99f 100644 --- a/lib/cli/commands/vm.js +++ b/lib/cli/commands/vm.js @@ -1018,23 +1018,16 @@ exports.init = function(cli) { row.cell('VM Name', item.VMName); row.cell('Status', item.InstanceStatus); }); - } else { - if (logger.format().json) { - logger.json([]); - } else { - logger.info('No VMs found'); - } + return; } - - cmdCallback(); + } + + if (logger.format().json) { + logger.json([]); } else { - if (logger.format().json) { - logger.json([]); - } else { - logger.info('No VMs found'); - } - cmdCallback(); + logger.info('No VMs found'); } + cmdCallback(); }); } diff --git a/lib/cli/iaas/image.js b/lib/cli/iaas/image.js index fe5b4c82c9..60c87dc3bd 100644 --- a/lib/cli/iaas/image.js +++ b/lib/cli/iaas/image.js @@ -358,14 +358,12 @@ function listDisks(cli, options, cmdCallback) { }); cmdCallback(error); }); - } else { - progress.end(); - cmdCallback('VM ' + options.name + ' not found'); + return } - } else { - progress.end(); - cmdCallback('VM ' + options.name + ' not found'); } + + progress.end(); + cmdCallback('VM ' + options.name + ' not found'); }); }