Small improvements to multi-instance selections
authorIustin Pop <iustin@google.com>
Wed, 31 Oct 2007 14:57:05 +0000 (14:57 +0000)
committerIustin Pop <iustin@google.com>
Wed, 31 Oct 2007 14:57:05 +0000 (14:57 +0000)
This patch fixes the documentation in a few cases and adds handling of
the situation where no instance is selected due to too restrictive
options given.

Reviewed-by: imsnah

man/gnt-instance.sgml
scripts/gnt-instance

index 3ce0a99..af3e26d 100644 (file)
         </cmdsynopsis>
 
         <para>
-          Starts one or more instances, depending on the
-          <option>--by-*</option> mode. The four available modes are:
+          Starts one or more instances, depending on the following
+          options. The four available modes are:
           <variablelist>
             <varlistentry>
               <term><option>--instance</option></term>
         </para>
 
         <para>
-          Note that although you can pass more than one
-          <option>--by-</option> option, the last one wins, so in
-          order to guarantee the desired result, don't pass more than
-          one such option.
+          Note that although you can pass more than one selection
+          option, the last one wins, so in order to guarantee the
+          desired result, don't pass more than one such option.
         </para>
 
         <para>
           <screen>
 # gnt-instance start instance1.example.com
 # gnt-instance start --extra single test1.example.com
-# gnt-instance start --by-node node1.example.com node2.example.com
-# gnt-instance start --by-cluster
+# gnt-instance start --node node1.example.com node2.example.com
+# gnt-instance start --all
           </screen>
         </para>
       </refsect3>
           Example:
           <screen>
 # gnt-instance shutdown instance1.example.com
-# gnt-instance shutdown --by-cluster
+# gnt-instance shutdown --all
           </screen>
         </para>
       </refsect3>
index 9838b41..231ea19 100755 (executable)
@@ -333,6 +333,8 @@ def StartupInstance(opts, args):
   if opts.multi_mode is None:
     opts.multi_mode = _SHUTDOWN_INSTANCES
   inames = _ExpandMultiNames(opts.multi_mode, args)
+  if not inames:
+    raise errors.OpPrereqError("Selection filter does not match any instances")
   multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
   if not (opts.force_multi or not multi_on
           or _ConfirmOperation(inames, "startup")):
@@ -357,6 +359,8 @@ def RebootInstance(opts, args):
   if opts.multi_mode is None:
     opts.multi_mode = _SHUTDOWN_INSTANCES
   inames = _ExpandMultiNames(opts.multi_mode, args)
+  if not inames:
+    raise errors.OpPrereqError("Selection filter does not match any instances")
   multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
   if not (opts.force_multi or not multi_on
           or _ConfirmOperation(inames, "reboot")):
@@ -380,6 +384,8 @@ def ShutdownInstance(opts, args):
   if opts.multi_mode is None:
     opts.multi_mode = _SHUTDOWN_INSTANCES
   inames = _ExpandMultiNames(opts.multi_mode, args)
+  if not inames:
+    raise errors.OpPrereqError("Selection filter does not match any instances")
   multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
   if not (opts.force_multi or not multi_on
           or _ConfirmOperation(inames, "shutdown")):
@@ -469,8 +475,7 @@ def FailoverInstance(opts, args):
     opts.multi_mode = _SHUTDOWN_INSTANCES
   inames = _ExpandMultiNames(opts.multi_mode, args)
   if not inames:
-    logger.ToStderr("No instances match the selected options")
-    return 1
+    raise errors.OpPrereqError("Selection filter does not match any instances")
   multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
   if not (opts.force_multi or not multi_on
           or _ConfirmOperation(inames, "failover (including shutdown)")):