Class: Y2Network::Widgets::AddressTab

Inherits:
CWM::Tab
  • Object
show all
Defined in:
src/lib/y2network/widgets/address_tab.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ AddressTab


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

def initialize(settings)
  textdomain "network"

  @settings = settings
end

Instance Method Details

#contentsObject


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'src/lib/y2network/widgets/address_tab.rb', line 46

def contents
  type = @settings.type

  drvtype = driver_type(type.short_name)
  # TODO: check if this kind of device is still valid and used
  is_ptp = drvtype == "ctc" || drvtype == "iucv"
  # TODO: dynamic for dummy. or add dummy from outside?
  no_dhcp =
    is_ptp ||
    type.dummy?

  address_p2p_contents = Frame(
    "", # labelless frame
    VBox(IPAddress.new(@settings), RemoteIP.new(@settings))
  )

  address_static_contents = Frame(
    "", # labelless frame
    VBox(
      IPAddress.new(@settings),
      Netmask.new(@settings),
      # TODO: new widget, add logic
      # "GATEWAY"
      Empty()
    )
  )

  address_dhcp_contents = VBox(BootProtocol.new(@settings))
  just_address_contents = if is_ptp
    address_p2p_contents
  elsif no_dhcp
    address_static_contents
  else
    address_dhcp_contents
  end

  label = HBox(
    type.vlan? ? VBox(HBox(VlanInterface.new(@settings), VlanID.new(@settings))) : Empty()
  )

  address_contents = if type.tun? || type.tap?
    # TODO: move it to own tab or general as it does not fit here
    VBox(Left(label), Tunnel.new(@settings))
  else
    VBox(
      Left(label),
      just_address_contents,
      AdditionalAddresses.new(@settings)
    )
  end

  address_contents
end

#driver_type(type) ⇒ Object

For s390 hwinfo gives us a multitude of types but some are handled the same, mostly acording to the driver which is used. So let's group them under the name Driver Type. TODO: move outside


106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'src/lib/y2network/widgets/address_tab.rb', line 106

def driver_type(type)
  drvtype = type
  # handle HSI like qeth, bsc#55692 #c15
  if type == "hsi"
    drvtype = "qeth"
  # Should eth occur on s390?
  elsif type == "tr" || type == "eth"
    drvtype = "lcs"
  # N#82891
  elsif type == "escon" || type == "ficon"
    drvtype = "ctc"
  end
  drvtype
end

#labelObject


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

def label
  _("&Address")
end