Module: Yast::NetworkLanS390Include

Defined in:
src/include/network/lan/s390.rb

Overview

Functions for accessing and handling s390 specific needs.

Constant Summary collapse

SYS_DIR =
"/sys/class/net".freeze

Instance Method Summary collapse

Instance Method Details

#initialize_network_lan_s390(_include_target) ⇒ Object



25
26
27
28
# File 'src/include/network/lan/s390.rb', line 25

def initialize_network_lan_s390(_include_target)
  Yast.import "FileUtils"
  Yast.import "Arch"
end

#s390_DriverLoaded(devname) ⇒ Object

Checks if driver was successfully loaded for particular device.



31
32
33
34
35
36
# File 'src/include/network/lan/s390.rb', line 31

def s390_DriverLoaded(devname)
  return false if !Yast::Arch.s390
  return false if devname.empty?

  Yast::FileUtils.IsDirectory("#{SYS_DIR}/#{devname}") == true
end

#s390_ReadQethAttribute(devname, attrib) ⇒ Object

Reads particular qeth attribute and returns its value as a string.

Parameters:

  • attrib (String)

    attribute name as exported by qeth module

Returns:

  • attribute value or nil in case of error.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'src/include/network/lan/s390.rb', line 42

def s390_ReadQethAttribute(devname, attrib)
  return nil if !s390_DriverLoaded(devname)

  result = Yast::Convert.to_string(
    Yast::SCR.Read(
      Yast.path(".target.string"),
      Yast::Builtins.sformat("%1/%2/device/%3", SYS_DIR, devname, attrib)
    )
  )

  Yast::Builtins.regexpsub(result, "(.*)\n", "\\1")
end

#s390_ReadQethConfig(devname) ⇒ Object

Reads attributes for particular qeth based network device.

Returned map is compatible with similar map used for storing sysconfig values used elswhere in the code. As a consequence, boolean values are stored as strings with yes/no value.

Currently loaded attributes are: QETH_LAYER2 yes/no string. QETH_PORTNUMBER portnumber or empty string QETH_CHANIDS read/write/control channel ids separated by space (compatibility requirement)

see lsqeth for inspiration

Returns:

  • a map with keys QETH_LAYER2, QETH_PORTNAME, QETH_PORTNUMBER, QETH_CHANIDS



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'src/include/network/lan/s390.rb', line 69

def s390_ReadQethConfig(devname)
  return {} if devname.empty?
  return {} if !s390_DriverLoaded(devname)

  result = {}

  qeth_layer2 = (s390_ReadQethAttribute(devname, "layer2") == "1") ? "yes" : "no"
  result = Yast::Builtins.add(result, "QETH_LAYER2", qeth_layer2)

  qeth_portno = s390_ReadQethAttribute(devname, "portno")
  result = Yast::Builtins.add(result, "QETH_PORTNUMBER", qeth_portno)

  # FIXME: another code handles chanids merged in one string separated by spaces.
  read_chan = s390_ReadQethAttribute(devname, "cdev0")
  write_chan = s390_ReadQethAttribute(devname, "cdev1")
  ctrl_chan = s390_ReadQethAttribute(devname, "cdev2")
  qeth_chanids = Yast::Builtins.mergestring(
    [read_chan, write_chan, ctrl_chan],
    " "
  )
  result = Yast::Builtins.add(result, "QETH_CHANIDS", qeth_chanids)

  # TODO: ipa_takover. study a bit. It cannot be read from /sys. Not visible using lsqeth,
  # qethconf configures it.

  Yast::Builtins.y2debug("s390_ReadQethConfig: %1", result)

  Yast.deep_copy(result)
end