From af42dfd008411053c7cc0a8990a236f012fe50b8 Mon Sep 17 00:00:00 2001 From: Kevin Scott Adams Date: Wed, 18 Apr 2018 13:53:29 -0400 Subject: [PATCH] Change iscsi_lunid values of 'undef' to 0 (zero) - In FreeNAS 11.1 it seems like a Lun of 0 becomes 'Auto'. When the API returns the targent_to_extent data any Lun of "Auto" become 'undef' and causes issues and errors in the syslog. This change corrects this behavior. Have tested with adding, detaching, removing and "Moving Disk" functions of Proxmox version 5.1-51. --- perl5/PVE/Storage/LunCmd/FreeNAS.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/perl5/PVE/Storage/LunCmd/FreeNAS.pm b/perl5/PVE/Storage/LunCmd/FreeNAS.pm index 6ec21d7..95ffe4a 100644 --- a/perl5/PVE/Storage/LunCmd/FreeNAS.pm +++ b/perl5/PVE/Storage/LunCmd/FreeNAS.pm @@ -359,6 +359,15 @@ sub freenas_iscsi_get_target_to_extent { if ($code == 200) { my $result = decode_json($client->responseContent()); syslog("info","FreeNAS::API::get_target_to_extent() : sucessfull"); + # If 'iscsi_lunid' is undef then it is set to 'Auto' in FreeNAS + # which should be '0' in our eyes. + # This gave Proxmox 5.x and FreeNAS 11.1 a few issues. + foreach my $item (@$result) { + if (!defined($item->{'iscsi_lunid'})) { + $item->{'iscsi_lunid'} = 0; + syslog("info", "FreeNAS::API::get_target_to_extent() : change undef iscsi_lunid to 0"); + } + } return $result; } else { freenas_api_log_error($client, "get_target_to_extent");