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

Constructor

Parameters:



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

def initialize(settings)
  super()
  textdomain "network"

  @settings = settings
end

Instance Method Details

#contentsObject



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
99
100
# File 'src/lib/y2network/widgets/address_tab.rb', line 50

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 = ["ctc", "iucv"].include?(drvtype)
  # 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()
  )

  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
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

Parameters:

  • type (String)

    a type, as in Lan::type

Returns:

  • driver type, like formerly type2 for s390



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

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

#labelObject



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

def label
  _("&Address")
end