Class: Y2Network::Widgets::BridgePorts

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

Instance Method Summary collapse

Methods included from SlaveItems

#physical_port_id, #physical_port_id?, #slave_items_from

Constructor Details

#initialize(settings) ⇒ 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 slave 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 = slave_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 slave 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


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

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