add tagged_only option to LVM storage
to filter volumes by the 'pve-vm-ID' tag, which is set on all volumes created via the PVE storage layer.
This commit is contained in:
committed by
Wolfgang Bumiller
parent
4a7d222204
commit
7a9dd1195d
@ -140,6 +140,7 @@ sub lvm_list_volumes {
|
|||||||
lv_type => $lv_type,
|
lv_type => $lv_type,
|
||||||
};
|
};
|
||||||
$d->{pool_lv} = $pool_lv if $pool_lv;
|
$d->{pool_lv} = $pool_lv if $pool_lv;
|
||||||
|
$d->{tags} = $tags if $tags;
|
||||||
|
|
||||||
if ($lv_type eq 't') {
|
if ($lv_type eq 't') {
|
||||||
$data_percent ||= 0;
|
$data_percent ||= 0;
|
||||||
@ -183,6 +184,10 @@ sub properties {
|
|||||||
description => "Wipe throughput (cstream -t parameter value).",
|
description => "Wipe throughput (cstream -t parameter value).",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
|
tagged_only => {
|
||||||
|
description => "Only use logical volumes tagged with 'pve-vm-ID'.",
|
||||||
|
type => 'boolean',
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +201,7 @@ sub options {
|
|||||||
saferemove_throughput => { optional => 1 },
|
saferemove_throughput => { optional => 1 },
|
||||||
content => { optional => 1 },
|
content => { optional => 1 },
|
||||||
base => { fixed => 1, optional => 1 },
|
base => { fixed => 1, optional => 1 },
|
||||||
|
tagged_only => { optional => 1 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,6 +345,12 @@ sub free_image {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $check_tags = sub {
|
||||||
|
my ($tags) = @_;
|
||||||
|
|
||||||
|
return defined($tags) && $tags =~ /(^|,)pve-vm-\d+(,|$)/;
|
||||||
|
};
|
||||||
|
|
||||||
sub list_images {
|
sub list_images {
|
||||||
my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
|
my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
|
||||||
|
|
||||||
@ -357,6 +369,8 @@ sub list_images {
|
|||||||
|
|
||||||
my $info = $dat->{$volname};
|
my $info = $dat->{$volname};
|
||||||
|
|
||||||
|
next if $scfg->{tagged_only} && !&$check_tags($info->{tags});
|
||||||
|
|
||||||
next if $info->{lv_type} ne '-';
|
next if $info->{lv_type} ne '-';
|
||||||
|
|
||||||
my $volid = "$storeid:$volname";
|
my $volid = "$storeid:$volname";
|
||||||
|
|||||||
Reference in New Issue
Block a user