Skip to content

Commit

Permalink
Added s390 device activator classes (based on CR).
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Aug 28, 2019
1 parent 8c7691c commit 6b80151
Show file tree
Hide file tree
Showing 30 changed files with 771 additions and 504 deletions.
6 changes: 3 additions & 3 deletions src/include/network/lan/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

include Yast::UIShortcuts

require "y2network/dialogs/s390"
require "y2network/dialogs/s390_device_activation"

module Yast
module NetworkLanHardwareInclude
Expand Down Expand Up @@ -75,8 +75,8 @@ def initHelp
# S/390 devices configuration dialog
# @return dialog result
def S390Dialog(builder:)
dialog = Y2Network::Dialogs::S390DeviceActivation.for(builder.type)
ret = dialog ? dialog.run(builder) : :abort
dialog = Y2Network::Dialogs::S390DeviceActivation.for(builder)
ret = dialog ? dialog.run : :abort

if ret == :next
configured = builder.configure
Expand Down
7 changes: 6 additions & 1 deletion src/lib/y2network/connection_config/ctc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,18 @@ class Ctc < Base
# @return [String] write device bus id
attr_accessor :write_channel
# @return [Integer] connection protocol (0, 1, 3, or 4)
# 0 Compatibility with peers other than OS/390®.
# 0 Compatibility with peers other than OS/390®. (default)
# 1 Enhanced package checking for Linux peers.
# 3 For compatibility with OS/390 or z/OS peers.
# 4 For MPC connections to VTAM on traditional mainframe operating systems.
# @see https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.ljdd/ljdd_t_ctcm_wrk_protocol.html
# @see https://github.com/SUSE/s390-tools/blob/master/ctc_configure#L16
attr_accessor :protocol

def initialize
super()
@protocol = 0
end
end
end
end
11 changes: 0 additions & 11 deletions src/lib/y2network/connection_config/lcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ class Lcs < Base
attr_accessor :read_channel
# @return [String] write device bus id
attr_accessor :write_channel
# @return [Integer] connection protocol (0, 1, 3, or 4)
# 0 Compatibility with peers other than OS/390®.
# 1 Enhanced package checking for Linux peers.
# 3 For compatibility with OS/390 or z/OS peers.
# 4 For MPC connections to VTAM on traditional mainframe operating systems.
# @see https://github.com/SUSE/s390-tools/blob/master/ctc_configure#L16
#
# # FIXME: At lease in linuxrc the protocol is not needed anymore for lcs
# interfaces (once replaced ctc_configure by chzdev)
attr_accessor :protocol
# The time the driver wait for a reply issuing a LAN command.
#
# @return [Integer] lcs lancmd timeout (default 5s)
Expand All @@ -62,7 +52,6 @@ class Lcs < Base
# Constructor
def initialize
super()
@protocol = 0
@timeout = 5
end
end
Expand Down
2 changes: 0 additions & 2 deletions src/lib/y2network/dialogs/s390.rb

This file was deleted.

6 changes: 3 additions & 3 deletions src/lib/y2network/dialogs/s390_ctc_activation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def contents
private

def protocol_widget
Y2Network::Widgets::S390Protocol.new(@settings)
Y2Network::Widgets::S390Protocol.new(builder)
end

def read_channel_widget
Y2Network::Widgets::S390ReadChannel.new(@settings)
Y2Network::Widgets::S390ReadChannel.new(builder)
end

def write_channel_widget
Y2Network::Widgets::S390WriteChannel.new(@settings)
Y2Network::Widgets::S390WriteChannel.new(builder)
end
end
end
Expand Down
51 changes: 41 additions & 10 deletions src/lib/y2network/dialogs/s390_device_activation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,48 @@
# find current contact information at www.suse.com.

require "cwm/dialog"
require "y2network/s390_device_activator"
require "y2network/widgets/s390_common"
require "y2network/widgets/s390_channels"

module Y2Network
module Dialogs
# Base class dialog for activating S390 devices
class S390DeviceActivation < CWM::Dialog
# @param type [Y2Network::InterfaceType] type of device
# @param builder [Y2Network::InterfaceConfigBuilder]
# @return [S390DeviceActivation, nil]
def self.for(type)
case type.short_name
def self.for(builder)
return nil unless builder.type
case builder.type.short_name
when "qeth", "hsi"
require "y2network/dialogs/s390_qeth_activation"
Y2Network::Dialogs::S390QethActivation
require "y2network/s390_device_activators/qeth"
activator = S390DeviceActivators::Qeth.new(builder)
Y2Network::Dialogs::S390QethActivation.new(activator)
when "ctc"
require "y2network/dialogs/s390_ctc_activation"
Y2Network::Dialogs::S390CtcActivation
require "y2network/s390_device_activators/ctc"
activator = S390DeviceActivators::Ctc.new(builder)
Y2Network::Dialogs::S390CtcActivation.new(activator)
when "lcs"
require "y2network/dialogs/s390_lcs_activation"
Y2Network::Dialogs::S390LcsActivation
require "y2network/s390_device_activators/lcs"
activator = S390DeviceActivators::Lcs.new(builder)
Y2Network::Dialogs::S390LcsActivation.new(activator)
end
end

attr_reader :builder
attr_reader :activator

# Constructor
#
# @param settings [Y2Network::InterfaceConfigBuilder]
def initialize(settings)
# @param activator [Y2Network::S390DeviceActivator]
def initialize(activator)
textdomain "network"

@settings = settings
@settings.proposal
@activator = activator
@builder = activator.builder
end

def title
Expand All @@ -59,6 +70,26 @@ def contents
Empty()
end

def run
ret = super
if ret == :next
configured = activator.configure
builder.name = activator.configured_interface if configured
builder.interface.name = builder.name if configured && builder.interface
if !configured || builder.name.empty?
Yast::Popup.Error(
_(
"An error occurred while creating device.\nSee YaST log for details."
)
)

ret = nil
end
end

ret
end

def abort_handler
Yast::Popup.ReallyAbort(true)
end
Expand Down
8 changes: 4 additions & 4 deletions src/lib/y2network/dialogs/s390_lcs_activation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ def contents
private

def protocol_widget
Y2Network::Widgets::S390Protocol.new(@settings)
Y2Network::Widgets::S390Protocol.new(builder)
end

def read_channel_widget
Y2Network::Widgets::S390ReadChannel.new(@settings)
Y2Network::Widgets::S390ReadChannel.new(builder)
end

def write_channel_widget
Y2Network::Widgets::S390WriteChannel.new(@settings)
Y2Network::Widgets::S390WriteChannel.new(builder)
end

def timeout_widget
Y2network::Widgets::S390LanCmdTimeout.new(@settings)
Y2network::Widgets::S390LanCmdTimeout.new(builder)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions src/lib/y2network/dialogs/s390_qeth_activation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ def contents
private

def s390_port_number
Y2Network::Widgets::S390PortNumber.new(@settings)
Y2Network::Widgets::S390PortNumber.new(builder)
end

def s390_attributes
Y2Network::Widgets::S390Attributes.new(@settings)
Y2Network::Widgets::S390Attributes.new(builder)
end

def s390_ip_takeover
Y2Network::Widgets::S390IPAddressTakeover.new(@settings)
Y2Network::Widgets::S390IPAddressTakeover.new(builder)
end

def s390_channels
Y2Network::Widgets::S390Channels.new(@settings)
Y2Network::Widgets::S390Channels.new(builder)
end

def s390_layer2
Y2Network::Widgets::S390Layer2.new(@settings)
Y2Network::Widgets::S390Layer2.new(builder)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions src/lib/y2network/interface_config_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ def hwinfo_from(info)
@hwinfo = Hwinfo.new(hwinfo: info)
end

def hwinfo
@hwinfo ||= Hwinfo.new(name: name)
end

private

# Initializes device configuration map with default values when needed
Expand Down Expand Up @@ -568,10 +572,6 @@ def hotplug_interface?
hwinfo.hotplug
end

def hwinfo
@hwinfo ||= Hwinfo.new(name: name)
end

def lan_items_format_aliases
aliases.each_with_index.each_with_object({}) do |(a, i), res|
res[i] = {
Expand Down
36 changes: 0 additions & 36 deletions src/lib/y2network/interface_config_builders/ctc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,6 @@ def initialize(config: nil)
:read_channel, :read_channel=,
:write_channel, :write_channel=,
:protocol, :protocol=

def device_id
return if read_channel.to_s.empty?

"#{read_channel}:#{write_channel}"
end

def device_id_from(channel)
cmd = "/sbin/lszdev ctc -c id -n".split(" ")

Yast::Execute.stdout.on_target!(cmd).split("\n").find do |d|
d.include? channel
end
end

def configure
cmd = "/sbin/chzdev ctc #{device_id} -e protocol=#{protocol}".split(" ")

Yast::Execute.on_target!(*cmd, allowed_exitstatus: 0..255).zero?
end

def configured_interface
cmd = "/sbin/lszdev #{device_id} -c names -n".split(" ")

Yast::Execute.stdout.on_target!(cmd).chomp
end

def propose_channels
id = device_id_from(hwinfo.busid)
return unless id
self.read_channel, self.write_channel = id.split(":")
end

def proposal
propose_channels unless device_id
end
end
end
end
40 changes: 0 additions & 40 deletions src/lib/y2network/interface_config_builders/lcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,6 @@ def initialize(config: nil)
:write_channel, :write_channel=,
:protocol, :protocol=,
:timeout, :timeout=

def device_id
return if read_channel.to_s.empty?

"#{read_channel}:#{write_channel}"
end

def device_id_from(busid)
cmd = "/sbin/lszdev lcs -c id -n".split(" ")

Yast::Execute.stdout.on_target!(cmd).split("\n").find do |d|
d.include? busid
end
end

def configure_attributes
"protocol=#{protocol} lancmd_timeout=#{timeout.to_i}".split(" ")
end

def configure
cmd = "/sbin/chzdev lcs #{device_id} -e ".split(" ").concat(configure_attributes)

Yast::Execute.on_target!(*cmd, allowed_exitstatus: 0..255).zero?
end

def configured_interface
cmd = "/sbin/lszdev #{device_id} -c names -n".split(" ")

Yast::Execute.stdout.on_target!(cmd).chomp
end

def propose_channels
id = device_id_from(hwinfo.busid)
return unless id
self.read_channel, self.write_channel = id.split(":")
end

def proposal
propose_channels unless device_id
end
end
end
end
Loading

0 comments on commit 6b80151

Please sign in to comment.