[pve-devel] [PATCH] - add ssl / https support for nexenta - die with content for json errors

Alexandre DERUMIER aderumier at odiso.com
Wed Aug 8 09:26:44 CEST 2012


I'm just testing with ssl, I have an ssl error. Does it works for you ?

----- Mail original ----- 

De: "Alexandre DERUMIER" <aderumier at odiso.com> 
À: "Stefan Priebe" <s.priebe at profihost.ag> 
Cc: pve-devel at pve.proxmox.com 
Envoyé: Mercredi 8 Août 2012 09:18:29 
Objet: Re: [pve-devel] [PATCH] - add ssl / https support for nexenta - die with content for json errors 

For ssl,I think we can use ssl by default.(no need to have a new property). 

for try/catch, yes indeed, we can do this way. 

(just put eval on 
1)nexenta_create_zvol($name, $size, $scfg); 
2)nexenta_create_lu($name, $scfg); 

> 1)nexenta_delete_lu($name, $scfg); 
) 

Thanks for your comments, I'll do a patch today. 


----- Mail original ----- 

De: "Stefan Priebe" <s.priebe at profihost.ag> 
À: "Alexandre DERUMIER" <aderumier at odiso.com> 
Cc: pve-devel at pve.proxmox.com 
Envoyé: Mercredi 8 Août 2012 08:36:22 
Objet: Re: [pve-devel] [PATCH] - add ssl / https support for nexenta - die with content for json errors 

OK. 

The SSL patch ist still needed ;-) Should i make a seperate patch just 
for https? 

In general we need some useful error messages if something goes wrong. 
Your print goes to /dev/null so nobody can use it. 

Why not use something like try catch in case we know an error might be 
raised? 

Greets, 
Stefan 

Am 08.08.2012 06:15, schrieb Alexandre DERUMIER: 
> about 
> 
> "- my $obj = from_json($res->content); 
> - print $obj->{error}->{message} if $obj->{error}->{message}; 
> - return undef if $obj->{error}->{message};" 
> 
> I don't die here, because in alloc_image for exemple: 
> 
> 1)nexenta_create_zvol($name, $size, $scfg); 
> 2)nexenta_create_lu($name, $scfg); 
> 3)die "error create zvol" if !nexenta_add_lun_mapping_entry($name, $scfg); 
> 
> or free_image 
> 
> 1)nexenta_delete_lu($name, $scfg); 
> 2)die "error deleting volume" if !nexenta_delete_zvol($name, $scfg); 
> 
> 
> if something goes wrong in last step, and that we wan't retry again to add/remove, 
> It'll retry the firsts steps and die. 
> So I never die on the firsts steps. 
> (I could manage some kind of rollback if something goes wrong, but if something hang in the rollback, this is difficult to manage) 
> 
> 
> ----- Mail original ----- 
> 
> De: "Stefan Priebe" <s.priebe at profihost.ag> 
> À: pve-devel at pve.proxmox.com 
> Cc: "spriebe" <git at profihost.ag> 
> Envoyé: Mardi 7 Août 2012 22:14:18 
> Objet: [pve-devel] [PATCH] - add ssl / https support for nexenta - die with content for json errors 
> 
> 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 }, 
> 



-- 

-- 





Alexandre D e rumier 

Ingénieur Systèmes et Réseaux 


Fixe : 03 20 68 88 85 

Fax : 03 20 68 90 88 


45 Bvd du Général Leclerc 59100 Roubaix 
12 rue Marivaux 75002 Paris 
_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 



-- 

-- 



	

Alexandre D e rumier 

Ingénieur Systèmes et Réseaux 


Fixe : 03 20 68 88 85 

Fax : 03 20 68 90 88 


45 Bvd du Général Leclerc 59100 Roubaix 
12 rue Marivaux 75002 Paris 



More information about the pve-devel mailing list