]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
add pveam download
authorWolfgang Link <w.link@proxmox.com>
Wed, 24 Feb 2016 11:11:06 +0000 (12:11 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 26 Feb 2016 10:37:11 +0000 (11:37 +0100)
With this function you can download templates from the repositories.

PVE/API2/Nodes.pm
PVE/CLI/pveam.pm

index aa1fa0b8566db24c2cd9231b605fefbc687670c7..434b9366052e3e0412db2a895546da4bc26a026d 100644 (file)
@@ -1040,8 +1040,15 @@ __PACKAGE__->register_method({
        additionalProperties => 0,
        properties => {
            node => get_standard_option('pve-node'),
-           storage => get_standard_option('pve-storage-id'),
-           template => { type => 'string', maxLength => 255 },
+           storage => get_standard_option('pve-storage-id', {
+               description => "Only list status for  specified storage",
+               completion => \&PVE::Storage::complete_storage_enabled,
+           }),
+           template => { type => 'string',
+                         description => "The template wich will downloaded",
+                         maxLength => 255,
+                         completion => \&complete_templet_repo,
+           },
        },
     },
     returns => { type => "string" },
@@ -1519,6 +1526,21 @@ __PACKAGE__->register_method ({
 
     }});
 
+# bash completion helper
+
+sub complete_templet_repo {
+    my ($cmdname, $pname, $cvalue) = @_;
+
+    my $repo = PVE::APLInfo::load_data();
+    my $res = [];
+    foreach my $templ (keys %{$repo->{all}}) {
+       next if $templ !~ m/^$cvalue/;
+       push @$res, $templ;
+    }
+
+    return $res;
+}
+
 package PVE::API2::Nodes;
 
 use strict;
index f1b691ebb1b02dcd3ce1c90204e94e47f228734b..772c05d918957da9ba1cc66f60561855ab9f93ed 100644 (file)
@@ -12,6 +12,7 @@ use PVE::INotify;
 use PVE::RPCEnvironment;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::CLIHandler;
+use PVE::API2::Nodes;
 
 use base qw(PVE::CLIHandler);
 
@@ -44,6 +45,7 @@ __PACKAGE__->register_method ({
 
 our $cmddef = {
     update => [ __PACKAGE__, 'update', []],
+    download => [ 'PVE::API2::Nodes::Nodeinfo', 'apl_download', [ 'storage', 'template'], { node => $nodename } ],
 };
 
 1;