[pve-devel] applied: [PATCH storage 4/5] LVMPlugin: factor out the lv creation
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jun 4 10:27:18 CEST 2019
On 6/4/19 9:21 AM, Dominik Csapak wrote:
> we will want to create lvs manually for ceph nautilus db/wal devices
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
applied
> ---
> PVE/Storage/LVMPlugin.pm | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
> index 9ad7979..50a4f64 100644
> --- a/PVE/Storage/LVMPlugin.pm
> +++ b/PVE/Storage/LVMPlugin.pm
> @@ -296,6 +296,22 @@ sub lvm_find_free_diskname {
> return PVE::Storage::Plugin::get_next_vm_diskname($disk_list, $storeid, $vmid, undef, $scfg);
> }
>
> +sub lvcreate {
> + my ($vg, $name, $size, $tags) = @_;
> +
> + if ($size =~ m/\d$/) { # no unit is given
> + $size .= "k"; # default to kilobytes
> + }
> +
> + my $cmd = ['/sbin/lvcreate', '-aly', '--size', $size, '--name', $name];
> + for my $tag (@$tags) {
> + push @$cmd, '--addtag', $tag;
> + }
> + push @$cmd, $vg;
> +
> + run_command($cmd, errmsg => "lvcreate '$vg/$name' error");
> +}
> +
> sub alloc_image {
> my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
>
> @@ -317,9 +333,7 @@ sub alloc_image {
> $name = lvm_find_free_diskname(lvm_list_volumes($vg), $vg, $storeid, $vmid, $scfg)
> if !$name;
>
> - my $cmd = ['/sbin/lvcreate', '-aly', '--addtag', "pve-vm-$vmid", '--size', "${size}k", '--name', $name, $vg];
> -
> - run_command($cmd, errmsg => "lvcreate '$vg/pve-vm-$vmid' error");
> + lvcreate($vg, $name, $size, ["pve-vm-$vmid"]);
>
> return $name;
> }
>
More information about the pve-devel
mailing list