]> git.proxmox.com Git - pmg-api.git/commitdiff
pmgbackup: rework CLI for pbs integration
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 18 Nov 2020 07:54:21 +0000 (08:54 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 18 Nov 2020 09:04:44 +0000 (10:04 +0100)
Update to new params.

The job is something different than the snapshots itself, so keep
that split.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/CLI/pmgbackup.pm

index e40da25f3a497b8aedae8e04cdf2f492f230c83e..24f5275950fdfc29ad03bdd9d8e347713712b532 100644 (file)
@@ -2,15 +2,12 @@ package PMG::CLI::pmgbackup;
 
 use strict;
 use warnings;
-use Data::Dumper;
-use POSIX qw(strftime);
 
 use PVE::Tools;
 use PVE::SafeSyslog;
 use PVE::INotify;
 use PVE::CLIHandler;
 use PVE::CLIFormatter;
-use PVE::JSONSchema qw(get_standard_option);
 use PVE::PTY;
 
 use PMG::RESTEnvironment;
@@ -68,30 +65,32 @@ our $cmddef = {
     backup => [ 'PMG::API2::Backup', 'backup', undef, { node => $nodename } ],
     restore => [ 'PMG::API2::Backup', 'restore', undef, { node => $nodename } ],
     list => [ 'PMG::API2::Backup', 'list', undef, { node => $nodename }, $format_backup_list ],
-    remote => {
-       list => ['PMG::API2::PBS::Remote', 'list', undef, undef,  sub {
-           my ($data, $schema, $options) = @_;
-           PVE::CLIFormatter::print_api_result($data, $schema, ['remote', 'server', 'datastore', 'username' ], $options);
-       }, $PVE::RESTHandler::standard_output_options ],
-       add => ['PMG::API2::PBS::Remote', 'create', ['remote'] ],
-       remove => ['PMG::API2::PBS::Remote', 'delete', ['remote'] ],
-       set => ['PMG::API2::PBS::Remote', 'update_config', ['remote'] ],
-    },
-    pbsjob => {
-       list_backups => ['PMG::API2::PBS::Job', 'get_snapshots', ['remote'] , { node => $nodename },  sub {
-           my ($data, $schema, $options) = @_;
-           PVE::CLIFormatter::print_api_result($data, $schema, ['time', 'size'], $options);
-       }, $PVE::RESTHandler::standard_output_options ],
-       forget => ['PMG::API2::PBS::Job', 'forget_snapshot', ['remote', 'time'], { node => $nodename} ],
-       run => ['PMG::API2::PBS::Job', 'run_backup', ['remote'], { node => $nodename} ],
-       restore => ['PMG::API2::PBS::Job', 'restore', ['remote'], { node => $nodename} ],
-       create => ['PMG::API2::PBS::Job', 'create_timer', ['remote'], { node => $nodename }],
-       delete => ['PMG::API2::PBS::Job', 'delete_timer', ['remote'], { node => $nodename }],
-       schedule => ['PMG::API2::PBS::Job', 'list_timer', ['remote'], { node => $nodename },  sub {
+    'proxmox-backup' => {
+       remote => {
+           list => ['PMG::API2::PBS::Remote', 'list', undef, undef,  sub {
+               my ($data, $schema, $options) = @_;
+               PVE::CLIFormatter::print_api_result($data, $schema, ['remote', 'server', 'datastore', 'username' ], $options);
+           }, $PVE::RESTHandler::standard_output_options ],
+           add => ['PMG::API2::PBS::Remote', 'create', ['remote'] ],
+           remove => ['PMG::API2::PBS::Remote', 'delete', ['remote'] ],
+           set => ['PMG::API2::PBS::Remote', 'update_config', ['remote'] ],
+       },
+       job => {
+           create => ['PMG::API2::PBS::Job', 'create_timer', ['remote'], { node => $nodename }],
+           delete => ['PMG::API2::PBS::Job', 'delete_timer', ['remote'], { node => $nodename }],
+           show => ['PMG::API2::PBS::Job', 'list_timer', ['remote'], { node => $nodename },  sub {
+               my ($data, $schema, $options) = @_;
+               PVE::CLIFormatter::print_api_result($data, $schema, ['remote', 'schedule', 'delay'], $options);
+           }, $PVE::RESTHandler::standard_output_options ],
+       },
+       list => ['PMG::API2::PBS::Job', 'get_snapshots', ['remote'] , { node => $nodename },  sub {
            my ($data, $schema, $options) = @_;
-           PVE::CLIFormatter::print_api_result($data, $schema, ['remote', 'schedule', 'delay'], $options);
+           PVE::CLIFormatter::print_api_result($data, $schema, ['backup-id', 'backup-time', 'size'], $options);
        }, $PVE::RESTHandler::standard_output_options ],
-    },
+       forget => ['PMG::API2::PBS::Job', 'forget_snapshot', ['remote', 'backup-id', 'backup-time'], { node => $nodename} ],
+       backup => ['PMG::API2::PBS::Job', 'run_backup', ['remote'], { node => $nodename} ],
+       restore => ['PMG::API2::PBS::Job', 'restore', ['remote', 'backup-id', 'backup-time'], { node => $nodename} ],
+    }
 };
 
 1;