]> git.proxmox.com Git - pve-storage.git/commitdiff
pvesr: move destroy_job into API class, remove wrong permission checks.
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 5 May 2017 09:18:30 +0000 (11:18 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 5 May 2017 09:18:30 +0000 (11:18 +0200)
PVE/API2/Storage/Replication.pm
PVE/CLI/pvesr.pm

index ab52b01b48959e58f2a17b806ddef46cbe03127e..ba3d1609af81ebae2c9bcd3cf8d422f269434f05 100644 (file)
@@ -44,9 +44,6 @@ __PACKAGE__->register_method ({
     path => 'jobs',
     method => 'GET',
     description => "List replication jobs.",
-    permissions => {
-       user => 'all',
-    },
     protected => 1,
     proxyto => 'node',
     parameters => {
@@ -71,4 +68,28 @@ __PACKAGE__->register_method ({
        return PVE::RESTHandler::hash_to_array($jobs, 'vmid');
     }});
 
+__PACKAGE__->register_method ({
+    name => 'destroy_job',
+    path => 'jobs/vmid',
+    method => 'DELETE',
+    description => "Destroy replication job.",
+    protected => 1,
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           vmid => {
+               description => "The VMID of the guest.",
+               type => 'string', format => 'pve-vmid',
+           },
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       PVE::ReplicationTools::destroy_replica($param->{vmid});
+
+       return undef;
+    }});
+
 1;
index 72b18e5f090d3730567cbbb467e913d89206c11c..471bc2c2f508f38c85ef4d50eeb9fdd2ae658048 100644 (file)
@@ -121,44 +121,13 @@ __PACKAGE__->register_method ({
        return undef;
     }});
 
-__PACKAGE__->register_method ({
-    name => 'destroyjob',
-    path => 'destroyjob',
-    method => 'DELETE',
-    description => "Destroy an async replication job",
-    permissions => {
-       description => {
-           check => ['perm', '/storage', ['Datastore.Allocate']],
-       },
-    },
-    protected => 1,
-    parameters => {
-       additionalProperties => 0,
-       properties => {
-           vmid => {
-               type => 'string', format => 'pve-vmid',
-               description => "The VMID of the guest.",
-               completion => \&PVE::Cluster::complete_local_vmid,
-           },
-       },
-    },
-    returns => { type => 'null' },
-    code => sub {
-       my ($param) = @_;
-
-       my $vmid = extract_param($param, 'vmid');
-
-       PVE::ReplicationTools::destroy_replica($vmid);
-
-    }});
-
-
-
 our $cmddef = {
     jobs => [ 'PVE::API2::Storage::Replication', 'jobs' , [],
              {node => $nodename}, $print_job_list ],
+
+    destroyjob => [ 'PVE::API2::Storage::Replication', 'destroy_job' , ['vmid']],
+
     run => [ __PACKAGE__ , 'run'],
-    destroyjob => [ __PACKAGE__ , 'destroyjob', ['vmid']],
 };
 
 1;