Python autotool to print socket constants
[ganeti-local] / autotools / build-bash-completion
index 42e020d..731e93d 100755 (executable)
@@ -33,15 +33,17 @@ import itertools
 import optparse
 from cStringIO import StringIO
 
+# _constants shouldn't be imported from anywhere except constants.py, but we're
+# making an exception here because this script is only used at build time.
+from ganeti import _constants
+
 from ganeti import constants
 from ganeti import cli
 from ganeti import utils
 from ganeti import build
 from ganeti import pathutils
 
-# _autoconf shouldn't be imported from anywhere except constants.py, but we're
-# making an exception here because this script is only used at build time.
-from ganeti import _autoconf
+from ganeti.tools import burnin
 
 #: Regular expression describing desired format of option names. Long names can
 #: contain lowercase characters, numbers and dashes only.
@@ -103,10 +105,10 @@ def WritePreamble(sw, support_debug):
   sw.IncIndent()
   try:
     # FIXME: this is really going into the internals of the job queue
-    sw.Write(("local jlist=$( shopt -s nullglob &&"
-              " cd %s 2>/dev/null && echo job-* || : )"),
+    sw.Write(("local jlist=($( shopt -s nullglob &&"
+              " cd %s 2>/dev/null && echo job-* || : ))"),
              utils.ShellQuote(pathutils.QUEUE_DIR))
-    sw.Write('echo "${jlist//job-/}"')
+    sw.Write('echo "${jlist[@]/job-/}"')
   finally:
     sw.DecIndent()
   sw.Write("}")
@@ -357,6 +359,8 @@ class CompletionWriter:
           WriteCompReply(sw, "-W \"$(_ganeti_instances)\"", cur=cur)
         elif suggest == cli.OPT_COMPL_ONE_OS:
           WriteCompReply(sw, "-W \"$(_ganeti_os)\"", cur=cur)
+        elif suggest == cli.OPT_COMPL_ONE_EXTSTORAGE:
+          WriteCompReply(sw, "-W \"$(_ganeti_extstorage)\"", cur=cur)
         elif suggest == cli.OPT_COMPL_ONE_IALLOCATOR:
           WriteCompReply(sw, "-W \"$(_ganeti_iallocator)\"", cur=cur)
         elif suggest == cli.OPT_COMPL_ONE_NODEGROUP:
@@ -467,6 +471,8 @@ class CompletionWriter:
           choices = "$(_ganeti_jobs)"
         elif isinstance(arg, cli.ArgOs):
           choices = "$(_ganeti_os)"
+        elif isinstance(arg, cli.ArgExtStorage):
+          choices = "$(_ganeti_extstorage)"
         elif isinstance(arg, cli.ArgFile):
           choices = ""
           compgenargs.append("-f")
@@ -755,7 +761,7 @@ def WriteHaskellCompletion(sw, script, htools=True, debug=True):
 
   """
   if htools:
-    cmd = "./htools/htools"
+    cmd = "./src/htools"
     env = {"HTOOLS": script}
     script_name = script
     func_name = "htools_%s" % script
@@ -826,7 +832,7 @@ def main():
   WritePreamble(sw, debug)
 
   # gnt-* scripts
-  for scriptname in _autoconf.GNT_SCRIPTS:
+  for scriptname in _constants.GNT_SCRIPTS:
     filename = "scripts/%s" % scriptname
 
     WriteCompletion(sw, scriptname, GetFunctionName(scriptname), debug,
@@ -834,7 +840,6 @@ def main():
                                          build.LoadModule(filename)))
 
   # Burnin script
-  burnin = build.LoadModule("tools/burnin")
   WriteCompletion(sw, "%s/burnin" % pathutils.TOOLSDIR, "_ganeti_burnin",
                   debug,
                   opts=burnin.OPTIONS, args=burnin.ARGUMENTS)
@@ -844,18 +849,18 @@ def main():
                          debug=not options.compact)
 
   # htools, if enabled
-  if _autoconf.HTOOLS:
-    for script in _autoconf.HTOOLS_PROGS:
+  if _constants.HTOOLS:
+    for script in _constants.HTOOLS_PROGS:
       WriteHaskellCompletion(sw, script, htools=True, debug=debug)
 
   # ganeti-confd, if enabled
-  if _autoconf.ENABLE_CONFD:
-    WriteHaskellCompletion(sw, "htools/ganeti-confd", htools=False,
+  if _constants.ENABLE_CONFD:
+    WriteHaskellCompletion(sw, "src/ganeti-confd", htools=False,
                            debug=debug)
 
   # mon-collector, if monitoring is enabled
-  if _autoconf.ENABLE_MONITORING:
-    WriteHaskellCmdCompletion(sw, "htools/mon-collector", debug=debug)
+  if _constants.ENABLE_MOND:
+    WriteHaskellCmdCompletion(sw, "src/mon-collector", debug=debug)
 
   # Reset extglob to original value
   sw.Write("[[ -n \"$gnt_shopt_extglob\" ]] && $gnt_shopt_extglob")