mirror of
git://git.proxmox.com/git/pve-zsync.git
synced 2024-12-22 21:33:48 +03:00
add disk parser for LXC
This commit is contained in:
parent
ce6b324074
commit
9e7685c240
33
pve-zsync
33
pve-zsync
@ -699,11 +699,18 @@ sub get_disks {
|
|||||||
|
|
||||||
my $cmd = [];
|
my $cmd = [];
|
||||||
push @$cmd, 'ssh', "root\@$target->{ip}", '--', if $target->{ip};
|
push @$cmd, 'ssh', "root\@$target->{ip}", '--', if $target->{ip};
|
||||||
|
|
||||||
|
if ($target->{vm_type} eq 'qemu') {
|
||||||
push @$cmd, 'qm', 'config', $target->{vmid};
|
push @$cmd, 'qm', 'config', $target->{vmid};
|
||||||
|
} elsif ($target->{vm_type} eq 'lxc') {
|
||||||
|
push @$cmd, 'pct', 'config', $target->{vmid};
|
||||||
|
} else {
|
||||||
|
die "VM Type unknown\n";
|
||||||
|
}
|
||||||
|
|
||||||
my $res = run_cmd($cmd);
|
my $res = run_cmd($cmd);
|
||||||
|
|
||||||
my $disks = parse_disks($res, $target->{ip});
|
my $disks = parse_disks($res, $target->{ip}, $target->{vm_type});
|
||||||
|
|
||||||
return $disks;
|
return $disks;
|
||||||
}
|
}
|
||||||
@ -735,13 +742,13 @@ sub parse_disks {
|
|||||||
my $line = $1;
|
my $line = $1;
|
||||||
|
|
||||||
next if $line =~ /cdrom|none/;
|
next if $line =~ /cdrom|none/;
|
||||||
next if $line !~ m/^(?:virtio|ide|scsi|sata)\d+: /;
|
next if $line !~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): /;
|
||||||
|
|
||||||
my $disk = undef;
|
my $disk = undef;
|
||||||
my $stor = undef;
|
my $stor = undef;
|
||||||
if($line =~ m/^(?:virtio|ide|scsi|sata)\d+: (.+:)([A-Za-z0-9\-]+),(.*)$/) {
|
if($line =~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): (.+:)([A-Za-z0-9\-]+),(.*)$/) {
|
||||||
$disk = $2;
|
$disk = $3;
|
||||||
$stor = $1;
|
$stor = $2;
|
||||||
} else {
|
} else {
|
||||||
die "disk is not on ZFS Storage\n";
|
die "disk is not on ZFS Storage\n";
|
||||||
}
|
}
|
||||||
@ -751,7 +758,7 @@ sub parse_disks {
|
|||||||
push @$cmd, 'pvesm', 'path', "$stor$disk";
|
push @$cmd, 'pvesm', 'path', "$stor$disk";
|
||||||
my $path = run_cmd($cmd);
|
my $path = run_cmd($cmd);
|
||||||
|
|
||||||
if ($path =~ m/^\/dev\/zvol\/(\w+.*)(\/$disk)$/) {
|
if ($vm_type eq 'qemu' && $path =~ m/^\/dev\/zvol\/(\w+.*)(\/$disk)$/) {
|
||||||
|
|
||||||
my @array = split('/', $1);
|
my @array = split('/', $1);
|
||||||
$disks->{$num}->{pool} = shift(@array);
|
$disks->{$num}->{pool} = shift(@array);
|
||||||
@ -763,6 +770,20 @@ sub parse_disks {
|
|||||||
$disks->{$num}->{last_part} = $disk;
|
$disks->{$num}->{last_part} = $disk;
|
||||||
$disks->{$num}->{all} .= "\/$disk";
|
$disks->{$num}->{all} .= "\/$disk";
|
||||||
|
|
||||||
|
$num++;
|
||||||
|
} elsif ($vm_type eq 'lxc' && $path =~ m/^\/(\w+.+)\/(\w+.*)(\/$disk)$/) {
|
||||||
|
|
||||||
|
$disks->{$num}->{pool} = $1;
|
||||||
|
$disks->{$num}->{all} = $disks->{$num}->{pool};
|
||||||
|
|
||||||
|
if ($2) {
|
||||||
|
$disks->{$num}->{path} = $2;
|
||||||
|
$disks->{$num}->{all} .= "\/$disks->{$num}->{path}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$disks->{$num}->{last_part} = $disk;
|
||||||
|
$disks->{$num}->{all} .= "\/$disk";
|
||||||
|
|
||||||
$num++;
|
$num++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user