Bash completion: Add function to get all iallocators
authorMichael Hanselmann <hansmi@google.com>
Thu, 27 Aug 2009 17:26:36 +0000 (19:26 +0200)
committerMichael Hanselmann <hansmi@google.com>
Fri, 28 Aug 2009 15:24:57 +0000 (17:24 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>

autotools/build-bash-completion

index 1695e84..838b9f6 100755 (executable)
@@ -112,16 +112,20 @@ def WritePreamble(sw):
     sw.DecIndent()
   sw.Write("}")
 
-  sw.Write("_ganeti_os() {")
-  sw.IncIndent()
-  try:
-    # FIXME: Make querying the master for all OSes cheap
-    for path in constants.OS_SEARCH_PATH:
-      sw.Write("( shopt -s nullglob && cd %s 2>/dev/null && echo * || : )",
-               utils.ShellQuote(path))
-  finally:
-    sw.DecIndent()
-  sw.Write("}")
+  for (fnname, paths) in [
+      ("os", constants.OS_SEARCH_PATH),
+      ("iallocator", constants.IALLOCATOR_SEARCH_PATH),
+      ]:
+    sw.Write("_ganeti_%s() {", fnname)
+    sw.IncIndent()
+    try:
+      # FIXME: Make querying the master for all OSes cheap
+      for path in paths:
+        sw.Write("( shopt -s nullglob && cd %s 2>/dev/null && echo * || : )",
+                 utils.ShellQuote(path))
+    finally:
+      sw.DecIndent()
+    sw.Write("}")
 
   # Params: <offset> <options with values> <options without values>
   # Result variable: $first_arg_idx