• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-network / 13674608242

05 Mar 2025 11:09AM UTC coverage: 79.781% (-1.1%) from 80.833%
13674608242

Pull #1374

github

teclator
Make rubocop happy
Pull Request #1374: Added dialog for changing the bond ports naming schema to BusID (bsc#1233653) - master

11 of 139 new or added lines in 5 files covered. (7.91%)

40 existing lines in 16 files now uncovered.

9403 of 11786 relevant lines covered (79.78%)

20.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.28
/src/include/network/lan/complex.rb
1
# ***************************************************************************
2
#
3
# Copyright (c) 2012 Novell, Inc.
4
# All Rights Reserved.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of version 2 of the GNU General Public License as
8
# published by the Free Software Foundation.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail,
19
# you may find current contact information at www.novell.com
20
#
21
# **************************************************************************
22
# File:  include/network/lan/dialogs.ycp
23
# Package:  Network configuration
24
# Summary:  Summary, overview and IO dialogs for network cards config
25
# Authors:  Michal Svec <msvec@suse.cz>
26
#
27

28
require "y2network/interface_config_builder"
1✔
29
require "y2network/sequences/interface"
1✔
30
require "y2network/widgets/interfaces_table"
1✔
31
require "y2network/widgets/interface_description"
1✔
32
require "y2network/widgets/add_interface"
1✔
33
require "y2network/widgets/edit_interface"
1✔
34
require "y2network/widgets/delete_interface"
1✔
35

36
module Yast
1✔
37
  module NetworkLanComplexInclude
1✔
38
    def initialize_network_lan_complex(include_target)
1✔
39
      Yast.import "UI"
37✔
40

41
      textdomain "network"
37✔
42

43
      Yast.import "CWM"
37✔
44

45
      Yast.import "Lan"
37✔
46
      Yast.import "DNS"
37✔
47
      Yast.import "Mode"
37✔
48
      Yast.import "NetworkConfig"
37✔
49
      Yast.import "NetworkService"
37✔
50
      Yast.import "Wizard"
37✔
51
      Yast.import "Popup"
37✔
52
      Yast.import "Label"
37✔
53
      Yast.import "Package"
37✔
54
      Yast.import "TablePopup"
37✔
55
      Yast.import "CWMTab"
37✔
56
      Yast.import "Stage"
37✔
57
      Yast.import "Systemd"
37✔
58
      Yast.import "GetInstArgs"
37✔
59

60
      Yast.include include_target, "network/routines.rb"
37✔
61
      Yast.include include_target, "network/lan/help.rb"
37✔
62
      Yast.include include_target, "network/services/routing.rb"
37✔
63
      Yast.include include_target, "network/services/dns.rb"
37✔
64
      Yast.include include_target, "network/lan/dhcp.rb"
37✔
65
      Yast.include include_target, "network/lan/s390.rb"
37✔
66
      Yast.include include_target, "network/widgets.rb"
37✔
67

68
      @shown = false
37✔
69
    end
70

71
    def wd
1✔
72
      return @wd if @wd
×
73

74
      @wd = {
75
        "MANAGED"                       => managed_widget,
×
76
        "IPV6"                          => ipv6_widget,
77
        interfaces_table.widget_id      => interfaces_table.cwm_definition,
78
        interface_description.widget_id => interface_description.cwm_definition,
79
        add_interface.widget_id         => add_interface.cwm_definition,
80
        edit_interface.widget_id        => edit_interface.cwm_definition,
81
        delete_interface.widget_id      => delete_interface.cwm_definition
82
      }
83

84
      @wd = Convert.convert(
×
85
        Builtins.union(@wd, @widget_descr_dns),
86
        from: "map",
87
        to:   "map <string, map <string, any>>"
88
      )
89
      @wd = Convert.convert(
×
90
        Builtins.union(@wd, widgets), # routing widgets
91
        from: "map",
92
        to:   "map <string, map <string, any>>"
93
      )
94
      @wd = Convert.convert(
×
95
        Builtins.union(@wd, @widget_descr_dhclient),
96
        from: "map",
97
        to:   "map <string, map <string, any>>"
98
      )
99
    end
100

101
    def tabs_descr
1✔
102
      return @tabs_descr if @tabs_descr
×
103

104
      @tabs_descr = {
105
        "global"   => {
×
106
          "header"       => _("Global Options"),
107
          "contents"     => VBox(
108
            MarginBox(1, 0.49, "MANAGED"),
109
            MarginBox(1, 0.49, "IPV6"),
110
            MarginBox(1, 0.49, "DHCLIENT_OPTIONS"),
111
            VStretch()
112
          ),
113
          "widget_names" => ["MANAGED", "IPV6", "DHCLIENT_OPTIONS"]
114
        },
115
        "overview" => {
116
          "header"       => _("Overview"),
117
          "contents"     => VBox(
118
            interfaces_table.widget_id,
119
            interface_description.widget_id,
120
            Left(
121
              HBox(
122
                add_interface.widget_id, edit_interface.widget_id, delete_interface.widget_id
123
              )
124
            )
125
          ),
126
          "widget_names" => [
127
            interfaces_table.widget_id, interface_description.widget_id, add_interface.widget_id,
128
            edit_interface.widget_id, delete_interface.widget_id
129
          ]
130
        }
131
      }
132
      @tabs_descr = Builtins.union(@tabs_descr, route_td)
×
133
      @tabs_descr = Builtins.union(@tabs_descr, @dns_td)
×
134
    end
135

136
    def interfaces_table
1✔
137
      @interfaces_table ||= Y2Network::Widgets::InterfacesTable.new(interface_description)
×
138
    end
139

140
    def interface_description
1✔
141
      @interface_description ||= Y2Network::Widgets::InterfaceDescription.new
×
142
    end
143

144
    def add_interface
1✔
145
      @add_interface ||= Y2Network::Widgets::AddInterface.new
×
146
    end
147

148
    def edit_interface
1✔
149
      return @edit_interface if @edit_interface
×
150

151
      @edit_interface = Y2Network::Widgets::EditInterface.new(interfaces_table)
×
152
      interfaces_table.add_handler(@edit_interface)
×
153
      @edit_interface
×
154
    end
155

156
    def delete_interface
1✔
157
      return @delete_interface if @delete_interface
×
158

159
      @delete_interface = Y2Network::Widgets::DeleteInterface.new(interfaces_table)
×
160
      interfaces_table.add_handler(@delete_interface)
×
161
      @delete_interface
×
162
    end
163

164
    # Commit changes to internal structures
165
    # @return always `next
166
    def Commit(builder:)
1✔
167
      builder.save
×
168

169
      :next
×
170
    end
171

172
    # Read settings dialog
173
    # @return `abort if aborted and `next otherwise
174
    def ReadDialog
1✔
175
      Wizard.RestoreHelp(Ops.get_string(@help, "read", ""))
×
176
      Lan.AbortFunction = -> { PollAbort() }
×
177
      ret = Lan.Read(:cache)
×
178

179
      if Lan.HaveXenBridge && !Popup.ContinueCancel(
×
180
          Builtins.sformat(
181
            # continue-cancel popup, #178848
182
            # %1 is a (long) path to a README file
183
            _(
184
              "A Xen network bridge was detected.\n" \
185
              "Due to the renaming of network interfaces by the bridge script,\n" \
186
              "network interfaces should not be configured or restarted.\n" \
187
              "See %1 for details."
188
            ),
189
            "/usr/share/doc/packages/xen/README.SuSE"
190
          )
191
        )
192
        ret = false
×
193
      end
194

NEW
195
      bonding_fix.run if ret && bonding_fix.needs_to_be_run?
×
196

UNCOV
197
      ret ? :next : :abort
×
198
    end
199

200
    def bonding_fix
1✔
NEW
201
      require "y2network/dialogs/bonding_fix"
×
NEW
202
      @bonding_fix ||= Y2Network::Dialogs::BondingFix.new(Lan.yast_config)
×
203
    end
204

205
    # Write settings dialog
206
    # @return `abort if aborted and `next otherwise
207
    def WriteDialog
1✔
208
      return :next if !Lan.Modified
×
209

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

216
    # Evaluates if user should be asked again according dialogs result value
217
    #
218
    # it is basically useful if user aborts dialog and he has done some
219
    # changes already. Calling this function may results in confirmation
220
    # popup.
221
    def input_done?(ret)
1✔
222
      return true if ret != :abort
4✔
223

224
      return Popup.ConfirmAbort(:painless) if Stage.initial
3✔
225

226
      return ReallyAbort() if Lan.yast_config != Lan.system_config
2✔
227

228
      true
1✔
229
    end
230

231
    def MainDialog(init_tab)
1✔
232
      caption = _("Network Settings")
×
233
      widget_descr = {
234
        "tab" => CWMTab.CreateWidget(
×
235
          "tab_order"    => if Systemd.Running
×
236
                              ["global", "overview", "resolv", "route"]
×
237
                            else
238
                              ["overview", "resolv", "route"]
×
239
                            end,
240
          "tabs"         => tabs_descr,
241
          "widget_descr" => wd,
242
          "initial_tab"  => Stage.normal ? init_tab : "overview",
×
243
          "tab_help"     => ""
244
        )
245
      }
246
      contents = VBox("tab")
×
247

248
      w = CWM.CreateWidgets(
×
249
        ["tab"],
250
        Convert.convert(
251
          widget_descr,
252
          from: "map",
253
          to:   "map <string, map <string, any>>"
254
        )
255
      )
256

257
      help = CWM.MergeHelps(w)
×
258
      contents = CWM.PrepareDialog(contents, w)
×
259

260
      Wizard.SetContentsButtons(
×
261
        caption,
262
        contents,
263
        help,
264
        Label.BackButton,
265
        next_button_label
266
      )
267

268
      Wizard.SetAbortButton(:abort, abort_button_label)
×
269
      Wizard.HideAbortButton if hide_abort_button?
×
270
      Wizard.HideBackButton unless running_installer?
×
271

272
      ret = nil
×
273

274
      loop do
×
275
        ret = CWM.Run(w, {})
×
276
        break if input_done?(ret)
×
277
      end
278

279
      ret
×
280
    end
281

282
    # The label for the next/ok button
283
    #
284
    # @return [String]
285
    def next_button_label
1✔
286
      running_installer? ? Label.NextButton : Label.OKButton
×
287
    end
288

289
    # The label for the abort/quit button
290
    #
291
    # @return [String]
292
    def abort_button_label
1✔
293
      running_installer? ? Label.AbortButton : Label.CancelButton
×
294
    end
295

296
    # Whether abort button should be hide
297
    #
298
    # @return [Boolean] true if running during installation and disable_abort_button inst argument
299
    # is present and true; false otherwise
300
    def hide_abort_button?
1✔
301
      return false unless running_installer?
×
302

303
      GetInstArgs.argmap["hide_abort_button"] == true
×
304
    end
305

306
    # Whether running during installation
307
    #
308
    # @return [Boolean] true when running during installation, false otherwise
309
    def running_installer?
1✔
310
      Mode.installation || Mode.update
×
311
    end
312
  end
313
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc