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

yast / yast-network / 13565031182

27 Feb 2025 11:10AM UTC coverage: 79.763% (-0.8%) from 80.591%
13565031182

Pull #1372

github

teclator
Prevent to use a MAC address when adding a bond port
Pull Request #1372: Added dialog for changing the bond ports naming schema to BusID (bsc#1233653) - SLE-15-SP6

11 of 138 new or added lines in 5 files covered. (7.97%)

2 existing lines in 2 files now uncovered.

9294 of 11652 relevant lines covered (79.76%)

19.82 hits per line

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

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

NEW
197
      if ret
×
NEW
198
        bonding_fix.run if bonding_fix.needs_to_be_run?
×
199
      end
200

UNCOV
201
      ret ? :next : :abort
×
202
    end
203

204
    def bonding_fix
1✔
NEW
205
      require "y2network/dialogs/bonding_fix"
×
NEW
206
      @bonding_fix ||= Y2Network::Dialogs::BondingFix.new(Lan.yast_config)
×
207
    end
208

209
    # Write settings dialog
210
    # @return `abort if aborted and `next otherwise
211
    def WriteDialog
1✔
212
      return :next if !Lan.Modified
×
213

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

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

228
      return Popup.ConfirmAbort(:painless) if Stage.initial
3✔
229

230
      return ReallyAbort() if Lan.yast_config != Lan.system_config
2✔
231

232
      true
1✔
233
    end
234

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

252
      w = CWM.CreateWidgets(
×
253
        ["tab"],
254
        Convert.convert(
255
          widget_descr,
256
          from: "map",
257
          to:   "map <string, map <string, any>>"
258
        )
259
      )
260

261
      help = CWM.MergeHelps(w)
×
262
      contents = CWM.PrepareDialog(contents, w)
×
263

264
      Wizard.SetContentsButtons(
×
265
        caption,
266
        contents,
267
        help,
268
        Label.BackButton,
269
        next_button_label
270
      )
271

272
      Wizard.SetAbortButton(:abort, abort_button_label)
×
273
      Wizard.HideAbortButton if hide_abort_button?
×
274
      Wizard.HideBackButton unless running_installer?
×
275

276
      ret = nil
×
277

278
      loop do
×
279
        ret = CWM.Run(w, {})
×
280
        break if input_done?(ret)
×
281
      end
282

283
      ret
×
284
    end
285

286
    # The label for the next/ok button
287
    #
288
    # @return [String]
289
    def next_button_label
1✔
290
      running_installer? ? Label.NextButton : Label.OKButton
×
291
    end
292

293
    # The label for the abort/quit button
294
    #
295
    # @return [String]
296
    def abort_button_label
1✔
297
      running_installer? ? Label.AbortButton : Label.CancelButton
×
298
    end
299

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

307
      GetInstArgs.argmap["hide_abort_button"] == true
×
308
    end
309

310
    # Whether running during installation
311
    #
312
    # @return [Boolean] true when running during installation, false otherwise
313
    def running_installer?
1✔
314
      Mode.installation || Mode.update
×
315
    end
316
  end
317
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

© 2025 Coveralls, Inc