Module: Yast::NetworkLanComplexInclude

Defined in:
src/include/network/lan/complex.rb

Instance Method Summary collapse

Instance Method Details

#add_interfaceObject


137
138
139
# File 'src/include/network/lan/complex.rb', line 137

def add_interface
  @add_interface ||= Y2Network::Widgets::AddInterface.new
end

#Commit(builder:) ⇒ Object

Commit changes to internal structures


151
152
153
154
155
156
157
158
159
160
# File 'src/include/network/lan/complex.rb', line 151

def Commit(builder:)
  # 1) update NetworkInterfaces with corresponding devmap
  # FIXME: new item in NetworkInterfaces was created from handleOverview by
  # calling Lan.Add and named in HardwareDialog via NetworkInterfaces.Name=
  #  - all that stuff can (should) be moved here to have it isolated at one place
  #  and later moved to Interface object
  LanItems.Commit(builder)

  :next
end

#delete_interfaceObject


145
146
147
# File 'src/include/network/lan/complex.rb', line 145

def delete_interface
  @delete_interface ||= Y2Network::Widgets::DeleteInterface.new(interfaces_table)
end

#DeviceReady(devname) ⇒ Object

Returns true if the device can be used (means handled as normal linux device) or false otherwise (it is used mainly at s390 based systems where a special handling is needed to run linux device emulation)


207
208
209
# File 'src/include/network/lan/complex.rb', line 207

def DeviceReady(devname)
  !Arch.s390 || s390_DriverLoaded(devname)
end

#edit_interfaceObject


141
142
143
# File 'src/include/network/lan/complex.rb', line 141

def edit_interface
  @edit_interface ||= Y2Network::Widgets::EditInterface.new(interfaces_table)
end

#initialize_network_lan_complex(include_target) ⇒ Object


40
41
42
43
44
45
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
# File 'src/include/network/lan/complex.rb', line 40

def initialize_network_lan_complex(include_target)
  Yast.import "UI"

  textdomain "network"

  Yast.import "CWM"

  Yast.import "Lan"
  Yast.import "DNS"
  Yast.import "Mode"
  Yast.import "NetworkConfig"
  Yast.import "NetworkService"
  Yast.import "Wizard"
  Yast.import "Popup"
  Yast.import "Label"
  Yast.import "Package"
  Yast.import "TablePopup"
  Yast.import "CWMTab"
  Yast.import "Stage"
  Yast.import "LanItems"

  Yast.include include_target, "network/routines.rb"
  Yast.include include_target, "network/lan/help.rb"
  Yast.include include_target, "network/services/routing.rb"
  Yast.include include_target, "network/services/dns.rb"
  Yast.include include_target, "network/lan/dhcp.rb"
  Yast.include include_target, "network/lan/s390.rb"
  Yast.include include_target, "network/widgets.rb"

  @shown = false
end

#input_done?(ret) ⇒ Boolean

Evaluates if user should be asked again according dialogs result value

it is basically useful if user aborts dialog and he has done some changes already. Calling this function may results in confirmation popup.


240
241
242
243
244
245
246
247
248
# File 'src/include/network/lan/complex.rb', line 240

def input_done?(ret)
  return true if ret != :abort

  return Popup.ConfirmAbort(:painless) if Stage.initial

  return ReallyAbort() if LanItems.GetModified

  true
end

#interface_descriptionObject


133
134
135
# File 'src/include/network/lan/complex.rb', line 133

def interface_description
  @interface_description ||= Y2Network::Widgets::InterfaceDescription.new
end

#interfaces_tableObject


129
130
131
# File 'src/include/network/lan/complex.rb', line 129

def interfaces_table
  @interfaces_table ||= Y2Network::Widgets::InterfacesTable.new(interface_description)
end

#MainDialog(init_tab) ⇒ Object


250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'src/include/network/lan/complex.rb', line 250

def MainDialog(init_tab)
  caption = _("Network Settings")
  widget_descr = {
    "tab" => CWMTab.CreateWidget(
      "tab_order"    => if Stage.normal
                          ["global", "overview", "resolv", "route"]
                        else
                          ["overview", "resolv", "route"]
                        end,
      "tabs"         => tabs_descr,
      "widget_descr" => wd,
      "initial_tab"  => Stage.normal ? init_tab : "overview",
      "tab_help"     => ""
    )
  }
  contents = VBox("tab")

  w = CWM.CreateWidgets(
    ["tab"],
    Convert.convert(
      widget_descr,
      from: "map",
      to:   "map <string, map <string, any>>"
    )
  )

  help = CWM.MergeHelps(w)
  contents = CWM.PrepareDialog(contents, w)
  running_installer = Mode.installation || Mode.update

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    running_installer ? Label.NextButton : Label.OKButton
  )

  if running_installer
    Wizard.SetAbortButton(:abort, Label.AbortButton)
  else
    Wizard.SetAbortButton(:abort, Label.CancelButton)
    Wizard.HideBackButton
  end

  ret = nil
  loop do
    ret = CWM.Run(w, {})
    break if input_done?(ret)
  end

  ret
end

#ManagedDialogObject


211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'src/include/network/lan/complex.rb', line 211

def ManagedDialog
  contents = VBox(HSquash(VBox("MANAGED", VSpacing(0.5), "IPV6")))

  functions = { abort: fun_ref(method(:ReallyAbort), "boolean ()") }

  ret = CWM.ShowAndRun(
    "widget_descr"       => wd,
    "contents"           => contents,
    # Network setup method dialog caption
    "caption"            => _(
      "Network Setup Method"
    ),
    "back_button"        => Label.BackButton,
    "abort_button"       => Label.CancelButton,
    "next_button"        => Label.OKButton,
    # #54027
    "disable_buttons"    => ["back_button"],
    "fallback_functions" => functions
  )

  # #148485: always show the device overview
  ret
end

#ReadDialogObject

Read settings dialog


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'src/include/network/lan/complex.rb', line 164

def ReadDialog
  Wizard.RestoreHelp(Ops.get_string(@help, "read", ""))
  Lan.AbortFunction = -> { PollAbort() }
  ret = Lan.Read(:cache)
  # Currently just a smoketest for new config storage - something what should replace Lan module in the bright future
  # TODO: find a suitable place for this config storage
  Y2Network::Config.from(:sysconfig)

  if Lan.HaveXenBridge
    if !Popup.ContinueCancel(
      Builtins.sformat(
        # continue-cancel popup, #178848
        # %1 is a (long) path to a README file
        _(
          "A Xen network bridge was detected.\n" \
            "Due to the renaming of network interfaces by the bridge script,\n" \
            "network interfaces should not be configured or restarted.\n" \
            "See %1 for details."
        ),
        "/usr/share/doc/packages/xen/README.SuSE"
      )
    )
      ret = false
    end
  end

  ret ? :next : :abort
end

#tabs_descrObject


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'src/include/network/lan/complex.rb', line 101

def tabs_descr
  return @tabs_descr if @tabs_descr

  @tabs_descr = {
    "global"   => {
      "header"       => _("Global Options"),
      "contents"     => VBox(
        MarginBox(1, 0.49, "MANAGED"),
        MarginBox(1, 0.49, "IPV6"),
        MarginBox(1, 0.49, "DHCLIENT_OPTIONS"),
        VStretch()
      ),
      "widget_names" => ["MANAGED", "IPV6", "DHCLIENT_OPTIONS"]
    },
    "overview" => {
      "header"       => _("Overview"),
      "contents"     => VBox(
        interfaces_table.widget_id,
        interface_description.widget_id,
        Left(HBox(add_interface.widget_id, edit_interface.widget_id, delete_interface.widget_id))
      ),
      "widget_names" => [interfaces_table.widget_id, interface_description.widget_id, add_interface.widget_id, edit_interface.widget_id, delete_interface.widget_id]
    }
  }
  @tabs_descr = Builtins.union(@tabs_descr, route_td)
  @tabs_descr = Builtins.union(@tabs_descr, @dns_td)
end

#wdObject


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
# File 'src/include/network/lan/complex.rb', line 72

def wd
  return @wd if @wd
  @wd = {
    "MANAGED"                       => managed_widget,
    "IPV6"                          => ipv6_widget,
    interfaces_table.widget_id      => interfaces_table.cwm_definition,
    interface_description.widget_id => interface_description.cwm_definition,
    add_interface.widget_id         => add_interface.cwm_definition,
    edit_interface.widget_id        => edit_interface.cwm_definition,
    delete_interface.widget_id      => delete_interface.cwm_definition
  }

  @wd = Convert.convert(
    Builtins.union(@wd, @widget_descr_dns),
    from: "map",
    to:   "map <string, map <string, any>>"
  )
  @wd = Convert.convert(
    Builtins.union(@wd, widgets), # routing widgets
    from: "map",
    to:   "map <string, map <string, any>>"
  )
  @wd = Convert.convert(
    Builtins.union(@wd, @widget_descr_dhclient),
    from: "map",
    to:   "map <string, map <string, any>>"
  )
end

#WriteDialogObject

Write settings dialog


195
196
197
198
199
200
201
202
# File 'src/include/network/lan/complex.rb', line 195

def WriteDialog
  return :next if !Lan.Modified

  Wizard.RestoreHelp(Ops.get_string(@help, "write", ""))
  Lan.AbortFunction = -> { PollAbort() && ReallyAbort() }
  ret = Lan.Write
  ret ? :next : :abort
end