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
# File 'src/include/network/lan/s390.rb', line 25

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

#s390_DriverLoaded(devname) ⇒ Object

Checks if driver was successfully loaded for particular device.


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

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

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

#s390_ReadQethAttribute(devname, attrib) ⇒ Object

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


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

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

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

  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


67
68
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
# File 'src/include/network/lan/s390.rb', line 67

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

  result = {}

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

  qeth_portno = s390_ReadQethAttribute(devname, "portno")
  result = 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 = Builtins.mergestring(
    [read_chan, write_chan, ctrl_chan],
    " "
  )
  result = 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.

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

  deep_copy(result)
end