Skip to content

Commit

Permalink
fix demo mode setting error and discovery auth err
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Zhu Lingshan committed Nov 30, 2017
1 parent 4e48322 commit 63a3aef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
29 changes: 15 additions & 14 deletions src/clients/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 9 additions & 10 deletions src/lib/dialogs/UI_dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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]
Expand All @@ -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"
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 63a3aef

Please sign in to comment.