[pve-devel] [PATCH v2 guest-common] Bash completion helper for snapshot name

Rhonda D'Vine rhonda at proxmox.com
Mon Nov 19 12:20:21 CET 2018


This is the bash completion helper function for completing the snapshot
name.  This is used both in qemu-server and pve-container.

Signed-off-by: Rhonda D'Vine <rhonda at proxmox.com>
---
 PVE/AbstractConfig.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index 4cfe9bc..1d8ca59 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -697,4 +697,22 @@ sub snapshot_rollback {
     $class->lock_config($vmid, $updatefn);
 }
 
+# bash completion helper
+
+sub snapshot_list {
+    my ($class, $vmid) = @_;
+
+    my $cfspath = $class->cfs_config_path($vmid, $nodename);
+
+    if (-r "/etc/pve/$cfspath") {
+	my $conf = $class->load_config($vmid);
+	my $snapshot = [ keys %{$conf->{snapshots}} ];
+	return $snapshot;
+
+    } else {
+	# no config file found, return an empty array
+	return [ ];
+    }
+}
+
 1;
-- 
2.11.0





More information about the pve-devel mailing list