[lxc-devel] [lxd/master] Update Project Tab Complete Script

66hades on Github lxc-bot at linuxcontainers.org
Tue Feb 25 19:40:54 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 916 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200225/eef80700/attachment-0001.bin>
-------------- next part --------------
From 51ce584ca1422064bfccd726c789fd758b36002a Mon Sep 17 00:00:00 2001
From: Brian Neumeyer <bpneumey at oakland.edu>
Date: Tue, 25 Feb 2020 14:38:26 -0500
Subject: [PATCH] Update Project Tab Complete Script

-Add project list function
-Add project key list
-Add tab complete for "create delete edit get list rename set show switch unset " functions
-Add project list after above functions
-Add project key list after "get"|"set"|"unset" functions
-Add additional project list for "rename" function

Question: How would I test this functionality on my local computer? I tried to make a copy of /snap/lxd/current/etc/bash_completion.d/snap.lxd.lxc on my local server then replace it with my edited version, but the file is in use. I'm guessing that's due to lxd running, how would one hot swap the file?
---
 scripts/bash/lxd-client | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/scripts/bash/lxd-client b/scripts/bash/lxd-client
index 65de585d16..f12ec1b553 100644
--- a/scripts/bash/lxd-client
+++ b/scripts/bash/lxd-client
@@ -32,6 +32,11 @@ _have lxc && {
     {
       COMPREPLY=( $( compgen -W "$( lxc profile list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" ) )
     }
+	
+    _lxd_projects()
+    {
+      COMPREPLY=( $( compgen -W "$( lxc project list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" ) )
+    }	
 
     _lxd_networks()
     {
@@ -124,6 +129,8 @@ _have lxc && {
       ipv4.routes ipv4.routing ipv6.address ipv6.dhcp ipv6.dhcp.expiry ipv6.dhcp.ranges \
       ipv6.dhcp.stateful ipv6.firewall ipv6.nat ipv6.nat.address ipv6.nat.order \
       ipv6.routes ipv6.routing raw.dnsmasq"
+	  
+	project_keys="features.images features.profiles"
 
     storage_pool_keys="source size btrfs.mount_options ceph.cluster_name \
       ceph.osd.force_reuse ceph.osd.pg_num ceph.osd.pool_name ceph.osd.data_pool_name \
@@ -304,6 +311,33 @@ _have lxc && {
             ;;
         esac
         ;;
+      "project")
+        case $pos in
+          2)
+            COMPREPLY=( $(compgen -W "create delete edit get list rename set show switch unset " -- $cur) )
+            ;;
+			
+          3)
+            case ${no_dashargs[2]} in
+              "get"|"set"|"unset"|"create"|"delete"|"edit"|"list"|"show"|"switch"|"rename")
+                _lxd_projects
+                ;;
+            esac
+            ;;
+          4)
+            case ${no_dashargs[2]} in
+              "get"|"set"|"unset")
+				COMPREPLY=( $(compgen -W "$project_keys" -- $cur) )
+				;;
+				esac
+		  5)
+			case ${no_dashargs[2]} in
+              "rename")
+				_lxd_projects
+				;;
+				esac
+        esac
+        ;;
       "publish")
         _lxd_names
         ;;


More information about the lxc-devel mailing list