From 63a3aef4611e3040be0253f3bf7936bc57a3cc1f Mon Sep 17 00:00:00 2001 From: Zhu Lingshan Date: Thu, 30 Nov 2017 15:29:37 +0800 Subject: [PATCH] fix demo mode setting error and discovery auth err Fixed a discovery auth setting error, do not need to clear userid/pwd when disable discovery auth Fixed a demo mode widget status show error --- src/clients/target.rb | 29 +++++++++++++++-------------- src/lib/dialogs/UI_dialogs.rb | 19 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/clients/target.rb b/src/clients/target.rb index 911e3b4..280d808 100644 --- a/src/clients/target.rb +++ b/src/clients/target.rb @@ -43,24 +43,25 @@ def run mutual_password = $discovery_auth.fetch_mutual_password() cmd = 'targetcli' p1 = "iscsi/ set discovery_auth " - if userid.empty? != true - p1 += ("userid=" + userid + " ") - end - if password != nil - p1 += ("password=" + password + " ") - end - if mutual_userid != nil - p1 += ("mutual_userid=" + mutual_userid + " ") - end - if mutual_password != nil - p1 += ("mutual_password=" + mutual_password) - end - - if status == true + # status == false means "No discovery auth" is not checked, means we need enable discovery auth + if status == false + if userid.empty? != true + p1 += ("userid=" + userid + " ") + end + if password.empty? != true + p1 += ("password=" + password + " ") + end + if mutual_userid.empty? != true + p1 += ("mutual_userid=" + mutual_userid + " ") + end + if mutual_password.empty? != true + p1 += ("mutual_password=" + mutual_password) + end p1 += " enable=1" if (userid == mutual_userid) msg = _("It seems that Authentication by Initiators and Authentication by Targets using a same username") msg += _("This may cause a CHAP negotiation error, an authenticaiton failure.") + Yast::Popup.Error(msg) end else p1 = "iscsi/ set discovery_auth enable = 0" diff --git a/src/lib/dialogs/UI_dialogs.rb b/src/lib/dialogs/UI_dialogs.rb index f58839a..d0afc9d 100644 --- a/src/lib/dialogs/UI_dialogs.rb +++ b/src/lib/dialogs/UI_dialogs.rb @@ -43,7 +43,7 @@ def store end def handle - if self.value == false + if self.value == true @container_class.disable_discovery_auth_widgets() else @container_class.enable_discovery_auth_widgets() @@ -630,7 +630,7 @@ def initialize() else value = true end - @no_discovery_auth_checkbox = NoDiscoveryAuth_CheckBox.new(self, value) + @no_discovery_auth_checkbox = NoDiscoveryAuth_CheckBox.new(self, !value) @target_discovery_auth = TargetAuthDiscovery.new(value) @initiator_discovery_auth = InitiatorAuthDiscovery.new(value) self.handle_all_events = true @@ -681,7 +681,7 @@ def opt end def validate - if @no_discovery_auth_checkbox.value == true + if @no_discovery_auth_checkbox.value == false if (@target_discovery_auth.get_status == false) || (@initiator_discovery_auth.get_status ==false) err_msg = _("When Discovery Authentication is enabled.") err_msg += _("Plese use Authentication by initiator and Authentication by targets together.") @@ -2016,13 +2016,12 @@ def initialize(target_name) @target_portal_group_field = PortalGroupInput.new(1) else @mode = 'edit' - tpg_num = 0 + tpg_num = 1 target_list = $target_data.get_target_list target = target_list.fetch_target(target_name) tpg = target.get_default_tpg target = target_list.fetch_target(target_name) tpg_num = target.get_default_tpg.fetch_tpg_number - @tpg_num = tpg_num @target_tgp = tpg portals = tpg.fetch_portal ip = portals[0][0] @@ -2045,7 +2044,8 @@ def initialize(target_name) end if @mode == 'edit' - cmd = "targetcli iscsi/" + @target_name + "/tpg" + @tpg_num + "/ get attribute authentication" + tpg = @target_portal_group_field.value.to_s + cmd = "targetcli iscsi/" + @target_name + "/tpg" + tpg + "/ get attribute authentication" cmd_out = `#{cmd}` ret = cmd_out[15, cmd_out.length] if ret == "1 \n" @@ -2154,7 +2154,6 @@ def validate @lun_table_widget.set_target_info(@target_name, target_tpg) @target_info.push(@target_name) @target_info.push(target_tpg) - return true end if @mode == 'edit' @@ -2202,16 +2201,16 @@ def validate Yast::Popup.Error(err_msg + err) end end - end @target_info.push(@target_name) @target_info.push(target_tpg) auth = @use_login_auth.value + tpg = @target_portal_group_field.value.to_s if auth == true - p1 = "iscsi/" + @target_name + "/tpg" + @tpg_num + "/ set attribute authentication=1 " + \ + p1 = "iscsi/" + @target_name + "/tpg" + tpg + "/ set attribute authentication=1 " + \ " demo_mode_write_protect=1" + " cache_dynamic_acls=0" + " generate_node_acls=0" else - p1 = "iscsi/" + @target_name + "/tpg" + @tpg_num + "/ set attribute authentication=0 " + \ + p1 = "iscsi/" + @target_name + "/tpg" + tpg + "/ set attribute authentication=0 " + \ " demo_mode_write_protect=0" + " cache_dynamic_acls=1" + " generate_node_acls=1" end begin