Skip to content

Commit

Permalink
improve implementation and usage of GetIpAndPort
Browse files Browse the repository at this point in the history
  • Loading branch information
gabi2 committed Oct 17, 2013
1 parent d964e29 commit 6962763
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/include/iscsi-lio-server/widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -883,16 +883,17 @@ def initModify(key)
""
)
Builtins.y2milestone("initModify ipp:%1", ipp)
ip, port = IscsiLioData.GetIpAndPort(ipp)
UI.ChangeWidget(
Id(:ipaddr),
:Value,
Ops.get(IscsiLioData.GetIpAndPort(ipp), 0, "")
ip || ""
)
UI.ChangeWidget(Id(:ipaddr), :Enabled, true)
UI.ChangeWidget(
Id(:port),
:Value,
Ops.get(IscsiLioData.GetIpAndPort(ipp), 1, "3260")
port || ""
)
UI.ChangeWidget(Id(:port), :Enabled, true)
UI.ChangeWidget(
Expand Down
7 changes: 5 additions & 2 deletions src/modules/IscsiLioData.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ def SplitStringNE(str, delim)
end

def GetIpAndPort(np)
return [] if !np || np.empty?

if !np.start_with?("[")
ret = Builtins.splitstring(np, ":")
else
match_data = np.match(/\[([:\w]+)\]:(\d+)/)
elsif match_data = np.match(/\[([:\w]+)\]:(\d+)/)
ret = [match_data[1] || "", match_data[2] || ""]
else
ret = []
end
ret
end
Expand Down

0 comments on commit 6962763

Please sign in to comment.