Skip to content

Commit

Permalink
do not regard wwpn, lun for device activation. Remove deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Jun 11, 2015
1 parent c1022bb commit 44c1496
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 343 deletions.
4 changes: 1 addition & 3 deletions src/autoyast-rnc/zfcp.rnc
Expand Up @@ -6,9 +6,7 @@ zfcp = element zfcp {
element devices {
LIST,
element listentry {
element controller_id { text } &
element wwpn { text } &
element fcp_lun { text }
element controller_id { text }
}*
}?
}
8 changes: 4 additions & 4 deletions src/clients/zfcp_auto.rb
Expand Up @@ -82,15 +82,15 @@ def main
@ret = ZFCPController.AutoPackages
when "Read"
Yast.import "Progress"
Progress.off
Progress.set(false)
@ret = ZFCPController.Read
Progress.on
Progress.set(true)
ZFCPController.SetModified(true)
when "Write"
Yast.import "Progress"
Progress.off
Progress.set(false)
@ret = ZFCPController.Write
Progress.on
Progress.set(true)
else
Builtins.y2error("Unknown function: %1", @func)
@ret = false # Unknown function
Expand Down
165 changes: 9 additions & 156 deletions src/include/s390/zfcp/dialogs.rb
Expand Up @@ -162,7 +162,6 @@ def DisplayZFCPDialog
Table(Id(:table), Opt(:multiSelection), header, []),
HBox(
PushButton(Id(:add), Label.AddButton),
PushButton(Id(:delete), Label.DeleteButton),
HStretch()
)
)
Expand All @@ -172,9 +171,10 @@ def DisplayZFCPDialog
content,
help,
Label.BackButton,
Label.NextButton
Label.OKButton
)
Wizard.HideBackButton
Wizard.HideNextButton
Wizard.SetAbortButton(:abort, Label.CancelButton)

UI.ChangeWidget(Id(:min_chan), :ValidChars, "0123456789abcdefABCDEF.")
Expand Down Expand Up @@ -232,16 +232,6 @@ def ZFCPDialog
elsif ret == :table
ret = nil
next
elsif ret == :abort || ret == :cancel
# yes-no popup
if !Popup.YesNo(
_(
"Really leave the ZFCP device configuration without saving?\nAll changes will be lost."
)
)
ret = nil
end
next
end
end

Expand All @@ -259,35 +249,15 @@ def AddZFCPDiskDialog
caption = _("Add New ZFCP Device")

channels = []
wwpns = []
luns = []

if Mode.config
channels = Builtins.maplist(ZFCPController.devices) do |index, d|
Ops.get_string(d, ["detail", "controller_id"], "")
end
channels = Builtins.toset(channels)

wwpns = Builtins.maplist(ZFCPController.devices) do |index, d|
Ops.get_string(d, ["detail", "wwpn"], "")
end
wwpns = Builtins.toset(wwpns)

luns = Builtins.maplist(ZFCPController.devices) do |index, d|
Ops.get_string(d, ["detail", "fcp_lun"], "")
end
luns = Builtins.toset(luns)
else
channels = Builtins.maplist(ZFCPController.GetControllers) do |c|
Ops.get_string(c, "sysfs_bus_id", "")
end

wwpns = [Ops.get_string(ZFCPController.previous_settings, "wwpn", "")]

lun = Ops.get_string(ZFCPController.previous_settings, "fcp_lun", "")
lun = ZFCPController.GetNextLUN(lun) if !Builtins.isempty(lun)

luns = [lun]
end

content = HBox(
Expand All @@ -301,24 +271,6 @@ def AddZFCPDiskDialog
_("&Channel ID"),
channels
),
VSpacing(2),
HBox(
# combo box
ComboBox(Id(:wwpn), Opt(:hstretch, :editable), _("&WWPN"), wwpns),
# push button
Mode.config ?
Empty() :
PushButton(Id(:get_wwpn), _("Get WWPNs"))
),
VSpacing(2),
HBox(
# combobox
ComboBox(Id(:lun), Opt(:hstretch, :editable), _("&LUN"), luns),
# push button
Mode.config ?
Empty() :
PushButton(Id(:get_lun), _("Get LUNs"))
),
VStretch()
),
HStretch()
Expand All @@ -328,60 +280,17 @@ def AddZFCPDiskDialog
Wizard.SetContents(caption, content, help, true, true)
Wizard.RestoreBackButton
Wizard.RestoreAbortButton
Wizard.RestoreNextButton
Wizard.SetNextButton(:next, Label.OKButton)

UI.ChangeWidget(Id(:channel), :ValidChars, "0123456789abcdefABCDEF.")
UI.ChangeWidget(Id(:wwpn), :ValidChars, "0123456789abcdefABCDEFx")
UI.ChangeWidget(Id(:lun), :ValidChars, "0123456789abcdefABCDEFx")

UI.SetFocus(Id(:channel))

ret = nil
while ret == nil
ret = Convert.to_symbol(UI.UserInput)

if ret == :get_wwpn
channel = Convert.to_string(UI.QueryWidget(:channel, :Value))

if !ZFCPController.IsValidChannel(channel)
# error popup
Popup.Error(_("Not a valid channel ID."))
UI.SetFocus(:channel)
ret = nil
next
end

channel = ZFCPController.FormatChannel(channel)

wwpns = ZFCPController.GetWWPNs(channel)
UI.ChangeWidget(:wwpn, :Items, wwpns)
ret = nil
elsif ret == :get_lun
channel = Convert.to_string(UI.QueryWidget(:channel, :Value))
wwpn = Convert.to_string(UI.QueryWidget(:wwpn, :Value))

if !ZFCPController.IsValidChannel(channel)
# error popup
Popup.Error(_("Not a valid channel ID."))
UI.SetFocus(:channel)
ret = nil
next
end

if !ZFCPController.IsValidWWPN(wwpn)
# error popup
Report.Error(_("The entered WWPN is invalid."))
UI.SetFocus(:wwpn)
ret = nil
next
end

channel = ZFCPController.FormatChannel(channel)
wwpn = ZFCPController.FormatWWPN(wwpn)

luns = ZFCPController.GetLUNs(channel, wwpn)
UI.ChangeWidget(:lun, :Items, luns)
ret = nil
elsif ret == :abort || ret == :cancel
if ret == :abort || ret == :cancel
# yes-no popup
if !Popup.YesNo(
_(
Expand All @@ -392,8 +301,6 @@ def AddZFCPDiskDialog
end
elsif ret == :next
channel = Convert.to_string(UI.QueryWidget(Id(:channel), :Value))
wwpn = Convert.to_string(UI.QueryWidget(Id(:wwpn), :Value))
lun = Convert.to_string(UI.QueryWidget(Id(:lun), :Value))

if !ZFCPController.IsValidChannel(channel)
# error popup
Expand All @@ -403,27 +310,8 @@ def AddZFCPDiskDialog
next
end

if !ZFCPController.IsValidWWPN(wwpn)
# error popup
Report.Error(_("The entered WWPN is invalid."))
UI.SetFocus(:wwpn)
ret = nil
next
end

if !ZFCPController.IsValidLUN(lun)
# error popup
Report.Error(_("The entered LUN is invalid."))
UI.SetFocus(:lun)
ret = nil
next
end

channel = ZFCPController.FormatChannel(channel)
wwpn = ZFCPController.FormatWWPN(wwpn)
lun = ZFCPController.FormatLUN(lun)

if ZFCPController.GetDeviceIndex(channel, wwpn, lun) != nil
if ZFCPController.GetDeviceIndex(channel) != nil
# error popup
Popup.Error(_("Device already exists."))
ret = nil
Expand All @@ -434,60 +322,25 @@ def AddZFCPDiskDialog

if ret == :next
channel = Convert.to_string(UI.QueryWidget(Id(:channel), :Value))
wwpn = Convert.to_string(UI.QueryWidget(Id(:wwpn), :Value))
lun = Convert.to_string(UI.QueryWidget(Id(:lun), :Value))

channel = ZFCPController.FormatChannel(channel)
wwpn = ZFCPController.FormatWWPN(wwpn)
lun = ZFCPController.FormatLUN(lun)

Ops.set(ZFCPController.previous_settings, "channel", channel)
Ops.set(ZFCPController.previous_settings, "wwpn", wwpn)
Ops.set(ZFCPController.previous_settings, "fcp_lun", lun)

if Mode.config
m = { "controller_id" => channel, "wwpn" => wwpn, "fcp_lun" => lun }
m = { "controller_id" => channel}

m = { "detail" => m }

ZFCPController.AddDevice(m)
else
ZFCPController.ActivateDisk(channel, wwpn, lun)

ZFCPController.ActivateDisk(channel)
WriteDialog()
ZFCPController.ProbeDisks
end
end

ret
end


# Run the dialog for deleting ZFCPs
# @return [Symbol] from DeleteZFCPDiskDialog
def DeleteZFCPDiskDialog
selected = ListSelectedZFCP()
if Builtins.isempty(selected)
# error popup message
Popup.Message(_("No disk selected."))
else
if Mode.config
Builtins.foreach(selected) do |index|
ZFCPController.RemoveDevice(index)
end
else
Builtins.foreach(selected) do |index|
d = Ops.get(ZFCPController.devices, index, {})
channel = Ops.get_string(d, ["detail", "controller_id"], "")
wwpn = Ops.get_string(d, ["detail", "wwpn"], "")
lun = Ops.get_string(d, ["detail", "fcp_lun"], "")
ZFCPController.DeactivateDisk(channel, wwpn, lun)
end

ZFCPController.ProbeDisks
end
end

:next
end
end
end
10 changes: 2 additions & 8 deletions src/include/s390/zfcp/helps.rb
Expand Up @@ -70,18 +70,12 @@ def initialize_s390_zfcp_helps(include_target)
# Disk add help 1/2
"disk_add" => _(
"<p><b><big>Add New ZFCP Device</big></b><br>\n" +
"Enter the identifier of the device to add, the\n" +
"<b>Channel ID</b> of the ZFCP controller, the worldwide port number\n" +
"(<b>WWPN</b>) and the <b>LUN</b> number.</p>\n"
"Enter the <b>Channel ID</b> of the ZFCP controller.\n"
) +
# Disk add help 2/2, This is HTML, so finally "&lt;devno&gt;" is displayed as "<devno>"
_(
"<p>The <b>Channel ID</b> must be entered with lowercase letters in a sysfs conforming\n" +
"format 0.0.&lt;devno&gt;, such as <tt>0.0.5c51</tt>.</p>\n" +
"<p>The WWPN must be entered with lowercase letters as a 16-digit hex value, such as\n" +
"<tt>0x5005076300c40e5a</tt>.</p>\n" +
"<p>The LUN must be entered with lowercase letters as a 16-digit hex value with\n" +
"all trailing zeros, such as <tt>0x52ca000000000000</tt>.</p>"
"format 0.0.&lt;devno&gt;, such as <tt>0.0.5c51</tt>.</p>\n"
) +
# Disk selection dialog Warning
_("<h1>Warning</h1>") +
Expand Down
15 changes: 5 additions & 10 deletions src/include/s390/zfcp/wizards.rb
Expand Up @@ -41,20 +41,17 @@ def initialize_s390_zfcp_wizards(include_target)
def MainZFCPSequence
aliases = {
"main" => lambda { ZFCPDialog() },
"add" => lambda { AddZFCPDiskDialog() },
"delete" => lambda { DeleteZFCPDiskDialog() }
"add" => lambda { AddZFCPDiskDialog() }
}

sequence = {
"ws_start" => "main",
"main" => {
:abort => :abort,
:next => :next,
:add => "add",
:delete => "delete"
:add => "add"
},
"add" => { :abort => :abort, :next => "main" },
"delete" => { :abort => :abort, :next => "main" }
"add" => { :abort => :abort, :next => "main" }
}

Sequencer.Run(aliases, sequence)
Expand All @@ -66,15 +63,13 @@ def MainZFCPSequence
def ZFCPSequence
aliases = {
"read" => [lambda { ReadDialog() }, true],
"main" => lambda { MainZFCPSequence() },
"write" => [lambda { WriteDialog() }, true]
"main" => lambda { MainZFCPSequence() }
}

sequence = {
"ws_start" => "read",
"read" => { :abort => :abort, :next => "main" },
"main" => { :abort => :abort, :next => "write" },
"write" => { :abort => :abort, :next => :next }
"main" => { :abort => :abort, :next => :next }
}

Wizard.CreateDialog
Expand Down

0 comments on commit 44c1496

Please sign in to comment.