From 5bcaff56f684c2e5c91b53a201db1b1bec57abbb Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 4 Sep 2015 09:08:30 +0200 Subject: [PATCH] vzdump: improve bash completion --- PVE/VZDump.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 70fefb11..138986eb 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -31,10 +31,12 @@ my $confdesc = { vmid => { type => 'string', format => 'pve-vmid-list', description => "The ID of the VM you want to backup.", + completion => \&PVE::Cluster::complete_local_vmid, optional => 1, }, node => get_standard_option('pve-node', { description => "Only run if executed on this node.", + completion => \&PVE::Cluster::get_nodelist, optional => 1, }), all => { @@ -115,6 +117,7 @@ my $confdesc = { }, storage => get_standard_option('pve-storage-id', { description => "Store resulting file to this storage.", + completion => \&complete_backup_storage, optional => 1, }), stop => { @@ -1296,4 +1299,23 @@ sub command_line { return $cmd; } +# bash completion helpers +sub complete_backup_storage { + + my $cfg = PVE::Storage::config(); + my $ids = $cfg->{ids}; + + my $nodename = PVE::INotify::nodename(); + + my $res = []; + foreach my $sid (keys %$ids) { + my $scfg = $ids->{$sid}; + next if !PVE::Storage::storage_check_enabled($cfg, $sid, $nodename, 1); + next if !$scfg->{content}->{backup}; + push @$res, $sid; + } + + return $res; +} + 1; -- 2.39.5