[pve-devel] [PATCH] - add ssl / https support for nexenta - die with content for json errors
Stefan Priebe
s.priebe at profihost.ag
Tue Aug 7 22:14:18 CEST 2012
From: spriebe <git at profihost.ag>
Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
---
PVE/Storage/NexentaPlugin.pm | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/PVE/Storage/NexentaPlugin.pm b/PVE/Storage/NexentaPlugin.pm
index 6ad92d9..34de7ef 100644
--- a/PVE/Storage/NexentaPlugin.pm
+++ b/PVE/Storage/NexentaPlugin.pm
@@ -16,7 +16,7 @@ use base qw(PVE::Storage::Plugin);
sub nexenta_request {
my ($scfg, $json) = @_;
- my $uri = "http://".$scfg->{portal}.":2000/rest/nms/";
+ my $uri = ( $scfg->{ssl} ? "https" : "http" ) . "://" . $scfg->{portal} . ":2000/rest/nms/";
my $req = HTTP::Request->new( 'POST', $uri );
$req->header( 'Content-Type' => 'application/json' );
@@ -29,9 +29,12 @@ sub nexenta_request {
if (!$res->is_success) {
die $res->content;
}
- my $obj = from_json($res->content);
- print $obj->{error}->{message} if $obj->{error}->{message};
- return undef if $obj->{error}->{message};
+
+ my $obj = eval { from_json($res->content); };
+ die "JSON not valid. Content: " . $res->content if ($@);
+
+ die "Nexenta API Error: " . $obj->{error}->{message} if $obj->{error}->{message};
+
return $obj->{result} if $obj->{result};
return 1;
}
@@ -139,6 +142,10 @@ sub plugindata {
sub properties {
return {
+ ssl => {
+ description => "ssl",
+ type => 'bool',
+ },
login => {
description => "login",
type => 'string',
@@ -156,6 +163,7 @@ sub properties {
sub options {
return {
+ ssl => { fixed => 1 },
target => { fixed => 1 },
portal => { fixed => 1 },
login => { fixed => 1 },
--
1.7.2.5
More information about the pve-devel
mailing list