Class: Y2Network::S390GroupDevice

Inherits:
Object
  • Object
show all
Includes:
Yast2::Equatable, Yast::Logger
Defined in:
src/lib/y2network/s390_group_device.rb

Overview

This class represents z Systems network devices which requires the use of multiple I/O subchannels as 'QETH', 'CTC' and 'LCS' devices.

Constant Summary collapse

CONFIGURE_CMD =

Command for configuring z Systems specific devices

"/sbin/chzdev".freeze
LIST_CMD =

Command for displaying configuration of z Systems specific devices

"/sbin/lszdev".freeze
SUPPORTED_TYPES =
["qeth", "lcs", "ctc"].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, id, online = false, interface = nil) ⇒ S390GroupDevice

Returns a new instance of S390GroupDevice.

Parameters:

  • type (String)
  • id (String)
  • online (Boolean) (defaults to: false)
  • interface (String, nil) (defaults to: nil)


56
57
58
59
60
61
# File 'src/lib/y2network/s390_group_device.rb', line 56

def initialize(type, id, online = false, interface = nil)
  @type = Y2Network::InterfaceType.from_short_name(type)
  @id = id
  @interface = interface
  @online = online
end

Instance Attribute Details

#idString Also known as: name

Returns the device id.

Returns:

  • (String)

    the device id



42
43
44
# File 'src/lib/y2network/s390_group_device.rb', line 42

def id
  @id
end

#interfaceY2Network::Interface?

Returns:



44
45
46
# File 'src/lib/y2network/s390_group_device.rb', line 44

def interface
  @interface
end

#onlineBoolean

Returns:

  • (Boolean)


46
47
48
# File 'src/lib/y2network/s390_group_device.rb', line 46

def online
  @online
end

#typeY2Network::InterfaceType



40
41
42
# File 'src/lib/y2network/s390_group_device.rb', line 40

def type
  @type
end

Class Method Details

.all(offline: false) ⇒ Array<Y2Network::S390GroupDevice>

Convenience method to obtain the all the supported types s390 group devices.

Parameters:

  • offline (Boolean) (defaults to: false)

    whether should return only offline devices or not

Returns:



96
97
98
# File 'src/lib/y2network/s390_group_device.rb', line 96

def all(offline: false)
  SUPPORTED_TYPES.map { |t| list(t, offline) }.flatten
end

.list(type, offline = true) ⇒ Array<Y2Network::S390GroupDevice>

Returns the list of S390 group devices of the given type

Parameters:

  • type (String)

    s390 group device type (qeth, ctc or lcs)

  • offline (Boolean) (defaults to: true)

    whether should return only offline devices or not

Returns:



80
81
82
83
84
85
86
87
88
# File 'src/lib/y2network/s390_group_device.rb', line 80

def list(type, offline = true)
  cmd = [LIST_CMD, type, "-c", "id,on,names", "-n"]
  cmd << "--offline" if offline

  Yast::Execute.stdout.locally!(*cmd).split("\n").map do |device|
    id, online, iface_name = device.split
    new(type, id, online == "yes", iface_name)
  end
end

.offlineObject

Convenience method to obtain the all the offline s390 network group devices.



102
103
104
# File 'src/lib/y2network/s390_group_device.rb', line 102

def offline
  all(offline: true)
end

Instance Method Details

#hardwareObject

Obtains the hwinfo associated with the read channel



64
65
66
# File 'src/lib/y2network/s390_group_device.rb', line 64

def hardware
  Y2Network::Hwinfo.netcards.find { |h| h.busid == id.to_s.split(":").first }
end

#offline?Boolean

Check whether the device is offline or not

Returns:

  • (Boolean)


69
70
71
# File 'src/lib/y2network/s390_group_device.rb', line 69

def offline?
  !online
end