Include networks in Makefile and bash completion
authorDimitris Aragiorgis <dimara@grnet.gr>
Mon, 4 Jun 2012 20:52:31 +0000 (23:52 +0300)
committerDimitris Aragiorgis <dimara@grnet.gr>
Wed, 22 Aug 2012 14:11:17 +0000 (17:11 +0300)
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

Makefile.am
autotools/build-bash-completion

index 2e2b92f..2df24ff 100644 (file)
@@ -233,6 +233,7 @@ pkgpython_PYTHON = \
        lib/ssh.py \
        lib/storage.py \
        lib/uidpool.py \
+       lib/network.py \
        lib/workerpool.py
 
 client_PYTHON = \
@@ -244,6 +245,7 @@ client_PYTHON = \
        lib/client/gnt_instance.py \
        lib/client/gnt_job.py \
        lib/client/gnt_node.py \
+       lib/client/gnt_network.py \
        lib/client/gnt_os.py
 
 hypervisor_PYTHON = \
@@ -482,6 +484,7 @@ gnt_scripts = \
        scripts/gnt-group \
        scripts/gnt-instance \
        scripts/gnt-job \
+       scripts/gnt-network \
        scripts/gnt-node \
        scripts/gnt-os
 
@@ -691,6 +694,7 @@ man_MANS = \
        man/gnt-cluster.8 \
        man/gnt-debug.8 \
        man/gnt-group.8 \
+       man/gnt-network.8 \
        man/gnt-instance.8 \
        man/gnt-job.8 \
        man/gnt-node.8 \
index 365dad9..d2ec27d 100755 (executable)
@@ -131,6 +131,15 @@ def WritePreamble(sw):
     sw.DecIndent()
   sw.Write("}")
 
+  sw.Write("_ganeti_network() {")
+  sw.IncIndent()
+  try:
+    networks_path = os.path.join(constants.DATA_DIR, "ssconf_networks")
+    sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(networks_path))
+  finally:
+    sw.DecIndent()
+  sw.Write("}")
+
   # Params: <offset> <options with values> <options without values>
   # Result variable: $first_arg_idx
   sw.Write("_ganeti_find_first_arg() {")
@@ -345,6 +354,8 @@ class CompletionWriter:
           WriteCompReply(sw, "-W \"$(_ganeti_iallocator)\"", cur=cur)
         elif suggest == cli.OPT_COMPL_ONE_NODEGROUP:
           WriteCompReply(sw, "-W \"$(_ganeti_nodegroup)\"", cur=cur)
+        elif suggest == cli.OPT_COMPL_ONE_NETWORK:
+          WriteCompReply(sw, "-W \"$(_ganeti_network)\"", cur=cur)
         elif suggest == cli.OPT_COMPL_INST_ADD_NODES:
           sw.Write("local tmp= node1= pfx= curvalue=\"${optcur#*:}\"")
 
@@ -442,6 +453,8 @@ class CompletionWriter:
           choices = "$(_ganeti_nodes)"
         elif isinstance(arg, cli.ArgGroup):
           choices = "$(_ganeti_nodegroup)"
+        elif isinstance(arg, cli.ArgNetwork):
+          choices = "$(_ganeti_network)"
         elif isinstance(arg, cli.ArgJobId):
           choices = "$(_ganeti_jobs)"
         elif isinstance(arg, cli.ArgOs):