[pve-devel] [PATCH storage 2/3] add 'format' parameter to storage list call
Dominik Csapak
d.csapak at proxmox.com
Wed Nov 8 10:53:13 CET 2017
we will use this for the gui to figure out if we have to show
a size selector, a file selector, which formats are there, etc.
we have to include this data even for not active storages, else
we cannot show the correct fields
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Storage/Status.pm | 8 +++++++-
PVE/Storage.pm | 10 ++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/PVE/API2/Storage/Status.pm b/PVE/API2/Storage/Status.pm
index c6e3b1a..d18da5b 100644
--- a/PVE/API2/Storage/Status.pm
+++ b/PVE/API2/Storage/Status.pm
@@ -63,6 +63,12 @@ __PACKAGE__->register_method ({
optional => 1,
completion => \&PVE::Cluster::get_nodelist,
}),
+ format => {
+ description => "Include information about formats",
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ },
},
},
returns => {
@@ -87,7 +93,7 @@ __PACKAGE__->register_method ({
my $cfg = PVE::Storage::config();
- my $info = PVE::Storage::storage_info($cfg, $param->{content});
+ my $info = PVE::Storage::storage_info($cfg, $param->{content}, $param->{format});
raise_param_exc({ storage => "No such storage." })
if $param->{storage} && !defined($info->{$param->{storage}});
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 94be04e..e47b845 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -1001,7 +1001,7 @@ sub deactivate_volumes {
}
sub storage_info {
- my ($cfg, $content) = @_;
+ my ($cfg, $content, $includeformat) = @_;
my $ids = $cfg->{ids};
@@ -1048,13 +1048,19 @@ sub storage_info {
next if !$info->{$storeid};
next if !$info->{$storeid}->{enabled};
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ if ($includeformat) {
+ my $pd = $plugin->plugindata();
+ $info->{$storeid}->{format} = $pd->{format} if $pd->{format};
+ $info->{$storeid}->{select} = $pd->{select} if $pd->{select};
+ }
+
eval { activate_storage($cfg, $storeid, $cache); };
if (my $err = $@) {
warn $err;
next;
}
- my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
my ($total, $avail, $used, $active);
eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
warn $@ if $@;
--
2.11.0
More information about the pve-devel
mailing list