die "Config already exists\n" if $cfg->{$job->{source}}->{$job->{name}};
#check if vm has zfs disks if not die;
- get_disks($source, 1) if $source->{vmid};
+ get_disks($source) if $source->{vmid};
update_cron($job);
update_state($job);
}
sub get_disks {
- my ($target, $get_err) = @_;
+ my ($target) = @_;
my $cmd = [];
push @$cmd, 'ssh', "root\@$target->{ip}", '--', if $target->{ip};
my $res = run_cmd($cmd);
- my $disks = parse_disks($res, $target->{ip}, $target->{vm_type}, $get_err);
+ my $disks = parse_disks($res, $target->{ip}, $target->{vm_type});
return $disks;
}
}
sub parse_disks {
- my ($text, $ip, $vm_type, $get_err) = @_;
+ my ($text, $ip, $vm_type) = @_;
my $disks;
my $num = 0;
while ($text && $text =~ s/^(.*?)(\n|$)//) {
my $line = $1;
- my $error = $vm_type eq 'qemu' ? 1 : 0 ;
next if $line =~ /cdrom|none/;
next if $line !~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): /;
last;
}
}
-
+ if (!defined($disk) || !defined($stor)) {
+ print "Disk: \"$line\" has no valid zfs dataset format and will not include in pve-sync\n";
+ next;
+ }
} else {
- print "Disk: \"$line\" will not include in pve-sync\n" if $get_err || $error;
+ print "Disk: \"$line\" has no valid zfs dataset format and will not include in pve-sync\n";
next;
}