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
# File 'src/lib/y2network/widgets/bridge_ports.rb', line 35

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

Instance Method Details

#helpObject


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

def help
  # TODO: write it
  ""
end

#initObject

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


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

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


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

def label
  _("Bridged Devices")
end

#storeObject

Default function to store the value of port devices box.


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

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


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

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