]> git.proxmox.com Git - pve-zsync.git/commitdiff
add check_dataset_exists function
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 4 May 2021 08:10:00 +0000 (10:10 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 4 May 2021 10:12:51 +0000 (12:12 +0200)
as a generalization and replacement of check_pool_exists.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
pve-zsync

index 93b0d0d52bbba848e8773e5db83a8dade3e9155d..a327d423a6b7269604dd31b4b405c2c7eb04b558 100755 (executable)
--- a/pve-zsync
+++ b/pve-zsync
@@ -152,15 +152,15 @@ sub get_status {
     return undef;
 }
 
-sub check_pool_exists {
-    my ($target, $user) = @_;
+sub check_dataset_exists {
+    my ($dataset, $ip, $user) = @_;
 
     my $cmd = [];
 
-    if ($target->{ip}) {
-       push @$cmd, 'ssh', "$user\@$target->{ip}", '--';
+    if ($ip) {
+       push @$cmd, 'ssh', "$user\@$ip", '--';
     }
-    push @$cmd, 'zfs', 'list', '-H', '--', $target->{all};
+    push @$cmd, 'zfs', 'list', '-H', '--', $dataset;
     eval {
        run_cmd($cmd);
     };
@@ -517,10 +517,12 @@ sub init {
            run_cmd(['ssh-copy-id', '-i', '/root/.ssh/id_rsa.pub', "$param->{source_user}\@$ip"]);
        }
 
-       die "Pool $dest->{all} does not exists\n" if !check_pool_exists($dest, $param->{dest_user});
+       die "Pool $dest->{all} does not exist\n"
+           if !check_dataset_exists($dest->{all}, $dest->{ip}, $param->{dest_user});
 
        if (!defined($source->{vmid})) {
-           die "Pool $source->{all} does not exists\n" if !check_pool_exists($source, $param->{source_user});
+           die "Pool $source->{all} does not exist\n"
+               if !check_dataset_exists($source->{all}, $source->{ip}, $param->{source_user});
        }
 
        my $vm_type = vm_exists($source, $param->{source_user});