Class: Y2Network::Widgets::BridgePorts

Inherits:
CWM::MultiSelectionBox
  • Object
show all
Includes:
PortItems
Defined in:
src/lib/y2network/widgets/bridge_ports.rb

Instance Method Summary collapse

Methods included from PortItems

#physical_port_id, #physical_port_id?, #port_items_from

Constructor Details

#initialize(settings) ⇒ BridgePorts

Returns a new instance of BridgePorts.



35
36
37
38
39
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 35

def initialize(settings)
  super()
  textdomain "network"
  @settings = settings
end

Instance Method Details

#helpObject



45
46
47
48
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 45

def help
  # TODO: write it
  ""
end

#initObject

Default function to init the value of port devices box for bridging.



51
52
53
54
55
56
57
58
59
60
61
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 51

def init
  br_ports = @settings.ports
  items = port_items_from(
    @settings.bridgeable_interfaces.map(&:name),
    br_ports,
    Yast::Lan.yast_config # ideally get it from builder?
  )

  # it is list of Items, so cannot use `change_items` helper
  Yast::UI.ChangeWidget(Id(widget_id), :Items, items)
end

#labelObject



41
42
43
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 41

def label
  _("Bridged Devices")
end

#storeObject

Default function to store the value of port devices box.



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

def store
  @settings.ports = value
end

#validateObject

Validates created bridge. Currently just prevent the user to create a bridge with already configured interfaces

Returns:

  • true if valid or user decision if not



72
73
74
75
76
77
78
79
80
81
82
83
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 72

def validate
  if @settings.require_adaptation?(value || [])
    Yast::Popup.ContinueCancel(
      _(
        "At least one selected device is already configured.\n" \
        "Adapt the configuration for bridge?\n"
      )
    )
  else
    true
  end
end