Module: Yast::NetworkLanComplexInclude

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

Instance Method Summary collapse

Instance Method Details

#abort_button_labelString

The label for the abort/quit button

Returns:

  • (String)


279
280
281
# File 'src/include/network/lan/complex.rb', line 279

def abort_button_label
  running_installer? ? Label.AbortButton : Label.CancelButton
end

#add_interfaceObject



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

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

#Commit(builder:) ⇒ Object

Commit changes to internal structures

Returns:

  • always `next



158
159
160
161
162
# File 'src/include/network/lan/complex.rb', line 158

def Commit(builder:)
  builder.save

  :next
end

#delete_interfaceObject



152
153
154
# File 'src/include/network/lan/complex.rb', line 152

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

#edit_interfaceObject



148
149
150
# File 'src/include/network/lan/complex.rb', line 148

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

#hide_abort_button?Boolean

Whether abort button should be hide

is present and true; false otherwise

Returns:

  • (Boolean)

    true if running during installation and disable_abort_button inst argument



287
288
289
290
291
# File 'src/include/network/lan/complex.rb', line 287

def hide_abort_button?
  return false unless running_installer?

  GetInstArgs.argmap["hide_abort_button"] == true
end

#initialize_network_lan_complex(include_target) ⇒ Object



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

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 "Systemd"
  Yast.import "GetInstArgs"

  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.

Returns:

  • (Boolean)


208
209
210
211
212
213
214
215
216
# File 'src/include/network/lan/complex.rb', line 208

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

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

  return ReallyAbort() if Lan.yast_config != Lan.system_config

  true
end

#interface_descriptionObject



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

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

#interfaces_tableObject



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

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

#MainDialog(init_tab) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'src/include/network/lan/complex.rb', line 218

def MainDialog(init_tab)
  caption = _("Network Settings")
  widget_descr = {
    "tab" => CWMTab.CreateWidget(
      "tab_order"    => if Systemd.Running
                          ["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)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    next_button_label
  )

  Wizard.SetAbortButton(:abort, abort_button_label)
  Wizard.HideAbortButton if hide_abort_button?
  Wizard.HideBackButton unless running_installer?

  ret = nil

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

  ret
end

#next_button_labelString

The label for the next/ok button

Returns:

  • (String)


272
273
274
# File 'src/include/network/lan/complex.rb', line 272

def next_button_label
  running_installer? ? Label.NextButton : Label.OKButton
end

#ReadDialogObject

Read settings dialog

Returns:

  • abort if aborted andnext otherwise



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

def ReadDialog
  Wizard.RestoreHelp(Ops.get_string(@help, "read", ""))
  Lan.AbortFunction = -> { PollAbort() }
  ret = Lan.Read(:cache)

  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

#running_installer?Boolean

Whether running during installation

Returns:

  • (Boolean)

    true when running during installation, false otherwise



296
297
298
# File 'src/include/network/lan/complex.rb', line 296

def running_installer?
  Mode.installation || Mode.update
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
128
129
130
131
132
133
134
# 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



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

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

Returns:

  • abort if aborted andnext otherwise



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

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