With this function you can download templates from the repositories.
---
 PVE/API2/Nodes.pm | 26 ++++++++++++++++++++++++--
 PVE/CLI/pveam.pm  |  2 ++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index aa1fa0b..434b936 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -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;
diff --git a/PVE/CLI/pveam.pm b/PVE/CLI/pveam.pm
index 407d629..e90a7d7 100644
--- a/PVE/CLI/pveam.pm
+++ b/PVE/CLI/pveam.pm
@@ -13,6 +13,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);
 
@@ -46,6 +47,7 @@ __PACKAGE__->register_method ({
 
 our $cmddef = {
     update => [ __PACKAGE__, 'update', []],
+    download => [ 'PVE::API2::Nodes::Nodeinfo', 'apl_download', [ 'storage', 
'template'], { node => $nodename } ],
 };
 
 1;
-- 
2.1.4


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to