]> git.proxmox.com Git - pve-storage.git/commitdiff
prepare storage for lvmthin gui
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 19 Feb 2016 13:51:44 +0000 (14:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 20 Feb 2016 08:51:12 +0000 (09:51 +0100)
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@proxmox.com>
PVE/API2/Storage/Scan.pm
PVE/Storage/LvmThinPlugin.pm

index 7686e05182f2c95d98723cbffbb114045cca3d8d..3e3f2c3d3b1076d5c6e24d1d380262b9db5d52ff 100644 (file)
@@ -238,6 +238,41 @@ __PACKAGE__->register_method ({
        return PVE::RESTHandler::hash_to_array($res, 'vg');
     }});
 
+__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', 
index 5c440324837758d32b49f9d0bc87bfe567148b9c..a55fecd75cd0999a94342cdb909c4c207280f1e3 100644 (file)
@@ -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) = @_;