5
0
mirror of git://git.proxmox.com/git/pve-zsync.git synced 2025-01-03 09:17:37 +03:00

add check_dataset_exists function

as a generalization and replacement of check_pool_exists.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-05-04 10:10:00 +02:00 committed by Thomas Lamprecht
parent 5a0499c91f
commit 1ae8a2136d

View File

@ -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});