[pve-devel] [PATCH storage] prepare storage for lvmthin gui
Dominik Csapak
d.csapak at proxmox.com
Fri Feb 19 14:51:44 CET 2016
this patch adds an lvmthin scan to the api, so that we can get a list
of thinpools for a specific vg via an api call
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Storage/Scan.pm | 35 +++++++++++++++++++++++++++++++++++
PVE/Storage/LvmThinPlugin.pm | 14 ++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/PVE/API2/Storage/Scan.pm b/PVE/API2/Storage/Scan.pm
index 7686e05..3e3f2c3 100644
--- a/PVE/API2/Storage/Scan.pm
+++ b/PVE/API2/Storage/Scan.pm
@@ -239,6 +239,41 @@ __PACKAGE__->register_method ({
}});
__PACKAGE__->register_method ({
+ name => 'thinlvmscan',
+ path => 'lvmthin',
+ method => 'GET',
+ description => "List local LVM Thin Pools.",
+ protected => 1,
+ proxyto => "node",
+ permissions => {
+ check => ['perm', '/storage', ['Datastore.Allocate']],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ vg => {
+ type => 'string',
+ pattern => '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
+ maxLength => 100,
+ },
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ lv => { type => 'string'},
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+ return PVE::Storage::LvmThinPlugin::list_thinpools($param->{vg});
+ }});
+
+__PACKAGE__->register_method ({
name => 'usbscan',
path => 'usb',
method => 'GET',
diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index 5c44032..a55fecd 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -163,6 +163,20 @@ sub list_images {
return $res;
}
+sub list_thinpools {
+ my ($vg) = @_;
+
+ my $lvs = PVE::Storage::LVMPlugin::lvm_list_volumes($vg);
+ my $thinpools = [];
+
+ foreach my $lvname (keys %{$lvs->{$vg}}) {
+ next if $lvs->{$vg}->{$lvname}->{lv_type} ne 't';
+ push @$thinpools, { lv => $lvname };
+ }
+
+ return $thinpools;
+}
+
sub status {
my ($class, $storeid, $scfg, $cache) = @_;
--
2.1.4
More information about the pve-devel
mailing list