]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
vzdump: improve bash completion
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 07:08:30 +0000 (09:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 07:12:10 +0000 (09:12 +0200)
PVE/VZDump.pm

index 70fefb11c8fc14577f4e368b5a0d96c0f5c52ec8..138986eb4f440ac3c9f1c918ec264e46f79d65a9 100644 (file)
@@ -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;