From c37bb2c6ac43bd6fb65affccd26961300555959c Mon Sep 17 00:00:00 2001
From: Stephen Shirley <diamond@google.com>
Date: Mon, 7 Feb 2011 16:35:34 +0100
Subject: [PATCH] Handle gnt-instance shutdown --all for empty clusters

The current code gives:
Failure: prerequisites not met for this operation:
error type: wrong_input, error details:
Selection filter does not match any instances

Signed-off-by: Stephen Shirley <diamond@google.com>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/client/gnt_instance.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py
index b6e5ce3d1..d710c5a2b 100644
--- a/lib/client/gnt_instance.py
+++ b/lib/client/gnt_instance.py
@@ -217,6 +217,9 @@ def GenericManyOps(operation, fn):
     cl = GetClient()
     inames = _ExpandMultiNames(opts.multi_mode, args, client=cl)
     if not inames:
+      if opts.multi_mode == _SHUTDOWN_CLUSTER:
+        ToStdout("Cluster is empty, no instances to shutdown")
+        return 0
       raise errors.OpPrereqError("Selection filter does not match"
                                  " any instances", errors.ECODE_INVAL)
     multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
-- 
GitLab