From 5eec1276ab5f924f0b628c20944a1adf45647f18 Mon Sep 17 00:00:00 2001 From: Mike Hibler Date: Wed, 7 Oct 2015 18:01:22 -0600 Subject: [PATCH] More API changes (or else I didn't test this very well last time!) Pass authinit index, not tag, to targetgroup. Set serial number via extent, not target. --- .../tmcc/freenas9/libvnode_blockstore.pm | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/clientside/tmcc/freenas9/libvnode_blockstore.pm b/clientside/tmcc/freenas9/libvnode_blockstore.pm index ec7aac01d..7ab8ac632 100644 --- a/clientside/tmcc/freenas9/libvnode_blockstore.pm +++ b/clientside/tmcc/freenas9/libvnode_blockstore.pm @@ -140,6 +140,7 @@ sub getVlan($); sub getNextAuthITag(); sub genSerial(); sub findAuthITag($;$); +sub findAuthIId($); sub createVlanInterface($$); sub removeVlanInterface($$); sub setupIPAlias($;$); @@ -789,6 +790,7 @@ sub exportSlice($$$$) { my $res = freenasRequest($FREENAS_API_RESOURCE_IST_EXTENT, "POST", undef, {"iscsi_target_extent_name" => $iqn, + "iscsi_target_extent_serial" => genSerial(), "iscsi_target_extent_type" => "Disk", "iscsi_target_extent_disk" => "zvol/$pool/$volume"}); if (!$res) { @@ -851,10 +853,13 @@ sub exportSlice($$$$) { } my $tindex = $res->{'id'}; + # XXX we need the authinit index, not tag + my $aindex = findAuthIId($tag); + $res = freenasRequest($FREENAS_API_RESOURCE_IST_TGTGROUP, "POST", undef, {"iscsi_target" => $tindex, - "iscsi_target_initiatorgroup" => $tag, + "iscsi_target_initiatorgroup" => $aindex, "iscsi_target_portalgroup" => $ISCSI_GLOBAL_PORTAL, "iscsi_target_authgroup" => undef, "iscsi_target_authtype" => "None"}); @@ -975,6 +980,26 @@ sub findAuthITag($;$) { return undef; } +# Helper function. +# Locate and return ID for given auth tag, if it exists +sub findAuthIId($) { + my ($tag) = @_; + + return undef + if !defined($tag); + + my $aiinfo = freenasAuthInitList(); + + foreach my $ai (keys %{$aiinfo}) { + my $aient = $aiinfo->{$ai}; + if (exists($aient->{'tag'}) && $aient->{'tag'} eq $tag) { + return $aient->{'id'}; + } + } + + return undef; +} + # Helper function. # Locate and return next unused tag ID for iSCSI initiator groups. sub getNextAuthITag() { -- 2.22.0