Class: Y2Network::S390DeviceActivator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Yast::Logger
Defined in:
src/lib/y2network/s390_device_activator.rb

Overview

This class is responsable of activating the supported S390 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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ S390DeviceActivator

Constructor

Parameters:



51
52
53
# File 'src/lib/y2network/s390_device_activator.rb', line 51

def initialize(builder)
  @builder = builder
end

Instance Attribute Details

#builderObject

Returns the value of attribute builder.



36
37
38
# File 'src/lib/y2network/s390_device_activator.rb', line 36

def builder
  @builder
end

Class Method Details

.for(builder) ⇒ Object

Load fresh instace of device activator for given interface config builder



39
40
41
42
43
44
45
46
# File 'src/lib/y2network/s390_device_activator.rb', line 39

def self.for(builder)
  type = builder.type
  require "y2network/s390_device_activators/#{type.file_name}"
  S390DeviceActivators.const_get(type.class_name).new(builder)
rescue LoadError => e
  log.info "Specialized device activator for #{type.short_name} not found. #{e.inspect}"
  nil
end

Instance Method Details

#configureBoolean

It tries to enable the interface with the configured device id

Returns:

  • (Boolean)

    true when enabled



75
76
77
78
79
80
81
82
83
# File 'src/lib/y2network/s390_device_activator.rb', line 75

def configure
  return false unless device_id

  cmd = [CONFIGURE_CMD, type.short_name, device_id, "-e"].concat(configure_attributes)

  log.info("Activating s390 device: #{device_id}")
  Yast::Execute.on_target!(*cmd, stdout: :capture, stderr: :capture,
                           allowed_exitstatus: 0..255)
end

#configure_attributesArray<String>

Each s390 device type permits a set of attributes to be passed as extra options to the configuration command. This method return a list of each option in the form "attribute=value"

Examples:

qeth options

@activator.configure_attributes
#=> ["bridge_role=primary", "layer2=1", "portno=0", "ipa_takeover/enable=1"]

ctc options

@activator.configure_attributes
#=> ["protocol=1"]

Returns:

  • (Array<String>)


68
69
70
# File 'src/lib/y2network/s390_device_activator.rb', line 68

def configure_attributes
  []
end

#configured_interfaceString

Obtains the enabled interface name associated with the device id

Returns:

  • (String)

    device name



88
89
90
91
92
93
94
# File 'src/lib/y2network/s390_device_activator.rb', line 88

def configured_interface
  return "" unless device_id

  cmd = [LIST_CMD, device_id, "-c", "names", "-n"]

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

#propose!Object

Makes a new configuration proposal



97
# File 'src/lib/y2network/s390_device_activator.rb', line 97

def propose!; end