Class: Yast::LanClass

Inherits:
Module
  • Object
show all
Includes:
UI::TextHelpers, Wicked
Defined in:
src/modules/Lan.rb

Constant Summary collapse

NM_DHCP_TIMEOUT =
45

Constants included from Wicked

Wicked::BASH_OUTPUT_PATH, Wicked::BASH_PATH, Wicked::IBFT_CMD, Wicked::WICKED_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Wicked

#firmware_configured_by?, #firmware_interfaces, #firmware_interfaces_by_extension, #ibft_interfaces, #parse_hostname, #parse_ntp_servers, #query_wicked, #reload_config

Instance Attribute Details

#autoinstObject



534
535
536
# File 'src/modules/Lan.rb', line 534

def autoinst
  @autoinst ||= Y2Network::Autoinst::Config.new
end

#write_onlyBoolean

Returns:

  • (Boolean)


110
111
112
# File 'src/modules/Lan.rb', line 110

def write_only
  @write_only
end

Instance Method Details

#add_config(id, config) ⇒ Object

Adds the configuration

Parameters:

  • id (Symbol)

    Configuration ID

  • config (Y2Network::Config)

    Network configuration



737
738
739
# File 'src/modules/Lan.rb', line 737

def add_config(id, config)
  Y2Network::Config.add(id, config)
end

#AutoPackagesArray

mode

Returns:

  • (Array)

    of packages needed when writing the config in autoinst



683
684
685
# File 'src/modules/Lan.rb', line 683

def AutoPackages
  { "install" => Packages(), "remove" => [] }
end

#clear_configsObject

Clears the network configurations list



742
743
744
# File 'src/modules/Lan.rb', line 742

def clear_configs
  Y2Network::Config.reset
end

#dhcp_ntp_serversArray<String>

Note:

parsing dhcp ntp servers when NetworkManager is in use is not supported yet (bsc#798886)

Note:

called from installer

Provides a list with the NTP servers obtained via any of dhcp aware interfaces

Returns:

  • (Array<String>)

    list of ntp servers obtained byg DHCP



704
705
706
707
708
709
710
# File 'src/modules/Lan.rb', line 704

def dhcp_ntp_servers
  # Used before the config has been read
  return [] if !NetworkService.isNetworkRunning || Yast::NetworkService.is_network_manager

  ReadWithCacheNoGUI()
  ifaces_dhcp_ntp_servers.values.flatten.uniq
end

#ExportObject

Export data. They need to be converted to become what networking.rnc describes. Most prominently, instead of a flat list called "interfaces" we export a 2-level map of typed "devices"

Returns:

  • dumped settings

See Also:

  • Y2Network::Clients::Auto.adapt_for_autoyast


619
620
621
622
623
624
625
626
627
# File 'src/modules/Lan.rb', line 619

def Export
  profile = Y2Network::AutoinstProfile::NetworkingSection.new_from_network(yast_config)
  ay = profile.to_hashes
  ay["ipv6"] = @ipv6
  ay["config"] = NetworkConfig.Export unless ay["managed"]

  log.info("Exported map: #{ay}")
  deep_copy(ay)
end

#find_config(id) ⇒ Y2Network::Config?

Returns the network configuration with the given ID

Parameters:

  • id (Symbol)

    Network configuration ID

Returns:

  • (Y2Network::Config, nil)

    Network configuration with the given ID or nil if not found



729
730
731
# File 'src/modules/Lan.rb', line 729

def find_config(id)
  Y2Network::Config.find(id)
end

#find_set_hostname_ifacesArray<String>

Finds all devices which has DHCLIENT_SET_HOSTNAME set to "yes"

Returns:

  • (Array<String>)

    list of NIC names which has the option set to "yes"



341
342
343
344
345
# File 'src/modules/Lan.rb', line 341

def find_set_hostname_ifaces
  yast_config.connections.map do |conn|
    conn.interface if conn.dhclient_set_hostname == "yes"
  end.compact
end

#FromAY(input) ⇒ Hash

Convert data from autoyast to structure used by module. FIXME: massive refactoring required

Parameters:

  • input (Hash)

    autoyast settings

Returns:

  • (Hash)

    native network settings



551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'src/modules/Lan.rb', line 551

def FromAY(input)
  input = deep_copy(input)
  Builtins.y2debug("input %1", input)

  input["interfaces"] ||= []
  # DHCP:: config: some of it is in the DNS part of the profile
  dhcp = {}
  dhcpopts = Ops.get_map(input, "dhcp_options", {})
  dns = Ops.get_map(input, "dns", {})

  if Builtins.haskey(dns, "dhcp_hostname")
    Ops.set(
      dhcp,
      "DHCLIENT_SET_HOSTNAME",
      Ops.get_boolean(dns, "dhcp_hostname", false)
    )
  end

  dhcp = UpcaseCondSet(dhcp, dhcpopts, "dhclient_client_id")
  dhcp = UpcaseCondSet(dhcp, dhcpopts, "dhclient_additional_options")
  dhcp = UpcaseCondSet(dhcp, dhcpopts, "dhclient_hostname_option")

  Ops.set(input, "config", "dhcp" => dhcp)
  if !Ops.get(input, "strict_IP_check_timeout").nil?
    input["strict_ip_check_timeout"] = input.delete("strict_IP_check_timeout")
    Ops.set(input, ["config", "config"], "CHECK_DUPLICATE_IP" => true)
  end

  Builtins.y2milestone("input=%1", input)
  input
end

#HaveXenBridgeObject

Xen bridging confuses us (#178848)

Returns:

  • whether xenbr* exists



689
690
691
692
693
694
# File 'src/modules/Lan.rb', line 689

def HaveXenBridge
  # adapted test for xen bridged network (bnc#553794)
  have_br = FileUtils.Exists("/dev/.sysconfig/network/xenbridges")
  Builtins.y2milestone("Have Xen bridge: %1", have_br)
  have_br
end

#ifaces_dhcp_ntp_serversHash<String, Array<String>] key is device name, value is list of ntp servers obtained from the device

Returns hash of NTP servers

Provides map with NTP servers obtained via any of dhcp aware interfaces

Returns:

  • (Hash<String, Array<String>] key is device name, value is list of ntp servers obtained from the device)

    Hash] key is device name, value is list of ntp servers obtained from the device



718
719
720
721
722
723
# File 'src/modules/Lan.rb', line 718

def ifaces_dhcp_ntp_servers
  dhcp_ifaces = yast_config.connections.select(&:dhcp?).map(&:interface).compact

  result = dhcp_ifaces.map { |iface| [iface, parse_ntp_servers(iface)] }.to_h
  result.delete_if { |_, ntps| ntps.empty? }
end

#Import(settings) ⇒ Object

Import data. It expects data described networking.rnc and then passed through #FromAY. Most prominently, instead of a flat list called "interfaces" we import a 2-level map of typed "devices"

Parameters:

  • settings (Hash)

    settings to be imported

Returns:

  • true on success



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'src/modules/Lan.rb', line 590

def Import(settings)
  settings = {} if settings.nil?
  if Arch.s390
    NetworkAutoYast.instance.activate_s390_devices(settings.fetch("s390-devices", {}))
  end

  Read(:cache)
  profile = Y2Network::AutoinstProfile::NetworkingSection.new_from_hashes(settings)
  result = Y2Network::Config.from(:autoinst, profile, system_config)
  add_config(:yast, result.config)
  @autoinst = autoinst_config(profile)

  NetworkConfig.Import(settings["config"] || {})
  # Ensure that the /etc/hosts has been read to no blank out it in case of
  # not defined <host> section (bsc#1058396)
  Host.Read

  @ipv6 = settings.fetch("ipv6", true)

  true
end

#invalid_dhcp_cfgsArray

Creates a list of config files which contain corrupted DHCLIENT_SET_HOSTNAME setup

Returns:

  • (Array)

    list of config file names



321
322
323
324
325
326
327
328
329
# File 'src/modules/Lan.rb', line 321

def invalid_dhcp_cfgs
  devs = find_set_hostname_ifaces
  dev_ifcfgs = devs.map { |d| "ifcfg-#{d}" }

  return dev_ifcfgs if devs.size > 1
  return dev_ifcfgs << "dhcp" if !devs.empty? && DNS.dhcp_hostname

  []
end

#isAnyInterfaceDownObject

function for use from autoinstallation (Fate #301032)



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'src/modules/Lan.rb', line 136

def isAnyInterfaceDown
  down = false
  link_status = devices_link_status

  log.info("link_status #{link_status}")
  configurations = (Yast::Lan.system_config&.interfaces&.map(&:name) || [])
  configurations.each do |devname|
    address_file = "/sys/class/net/#{devname}/address"
    mac = ::File.read(address_file).chomp if ::File.file?(address_file)
    log.info("confname #{mac}")
    if !link_status.keys.include?(mac)
      log.error("Mac address #{mac} not found in map #{link_status}!")
    elsif link_status[mac] == false
      log.warn("Interface with mac #{mac} is down!")
      down = true
    else
      log.debug("Interface with mac #{mac} is up")
    end
  end
  down
end

#mainObject



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
101
102
103
104
105
106
107
# File 'src/modules/Lan.rb', line 57

def main
  Yast.import "UI"
  textdomain "network"

  Yast.import "Arch"
  Yast.import "NetHwDetection"
  Yast.import "Host"
  Yast.import "IP"
  Yast.import "Map"
  Yast.import "Mode"
  Yast.import "NetworkConfig"
  Yast.import "NetworkService"
  Yast.import "Package"
  Yast.import "ProductFeatures"
  Yast.import "Progress"
  Yast.import "String"
  Yast.import "FileUtils"
  Yast.import "Package"
  Yast.import "ModuleLoading"
  Yast.import "Linuxrc"

  Yast.include self, "network/complex.rb"
  Yast.include self, "network/runtime.rb"

  #-------------
  # GLOBAL DATA

  # gui or cli mode
  @gui = true

  @write_only = false

  # ipv6 module
  @ipv6 = true

  # Hotplug type ("" if not hot pluggable)

  # Abort function
  # return boolean return true if abort
  @AbortFunction = nil

  # Lan::Read (`cache) will do nothing if initialized already.
  @initialized = false

  @backend = nil

  @modified = false

  # Y2Network::Config objects
  @configs = {}
end

#ModifiedObject

Return a modification status

Returns:

  • true if data was modified



120
121
122
123
124
125
126
127
128
# File 'src/modules/Lan.rb', line 120

def Modified
  return true if @modified
  return true unless system_config == yast_config
  return true if NetworkConfig.Modified
  return true if NetworkService.Modified
  return true if Host.GetModified

  false
end

#PackagesArray

Proposes additional packages when needed by current networking setup

Returns:

  • (Array)

    of packages needed when writing the config



652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'src/modules/Lan.rb', line 652

def Packages
  backend = if Mode.autoinst
    Y2Network::Backend.all.find { |b| b.id == proposal_settings.current_backend }
  else
    yast_config&.backend
  end
  return [] unless backend

  target = Mode.autoinst ? :autoinst : :system
  needed_packages = backend.packages.reject { |p| Package.Installed(p, target: target) }

  if (backend.id == :wicked) && !Package.Installed("wpa_supplicant", target: target)
    # we have to add wpa_supplicant when wlan is in game, wicked relies on it
    wlan_present = yast_config.interfaces.any? do |iface|
      iface.type == Y2Network::InterfaceType::WIRELESS
    end

    needed_packages << "wpa_supplicant" if wlan_present
  end

  needed_packages.uniq!

  unless needed_packages.empty?
    log.info("Additional packages requested by yast2-network: #{needed_packages.inspect}")
  end

  needed_packages
end

#ProposeVirtualizedObject



644
645
646
647
# File 'src/modules/Lan.rb', line 644

def ProposeVirtualized
  read_config unless yast_config
  Y2Network::VirtualizationConfig.new(yast_config).create
end

#Read(cache) ⇒ Object

Read all network settings from the SCR

Parameters:

  • cache (Symbol)

    :cache=use cached data, :nocache=reread from disk TODO: pass to submodules

Returns:

  • true on success



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'src/modules/Lan.rb', line 191

def Read(cache)
  if cache == :cache && @initialized
    Builtins.y2milestone("Using cached data")
    return true
  end

  # Read dialog caption
  caption = _("Initializing Network Configuration")

  sl = 0 # 1000; /* TESTING
  Builtins.sleep(sl)

  if @gui
    Progress.New(
      caption,
      " ",
      read_step_labels.size,
      read_step_labels,
      [],
      ""
    )
  end

  return false if Abort()

  ProgressNextStage(_("Detecting ndiswrapper...")) if @gui
  # modprobe ndiswrapper before hwinfo when needed (#343893)
  if !Mode.autoinst && Package.Installed("ndiswrapper")
    Builtins.y2milestone("ndiswrapper: installed")
    if Ops.greater_than(
      Builtins.size(
        Convert.convert(
          SCR.Read(path(".target.dir"), "/etc/ndiswrapper"),
          from: "any",
          to:   "list <string>"
        )
      ),
      0
    )
      Builtins.y2milestone("ndiswrapper: configuration found")
      if Convert.to_integer(
        SCR.Execute(path(".target.bash"), "/usr/sbin/lsmod | /usr/bin/grep -q ndiswrapper")
      ) != 0 &&
          Popup.YesNo(
            _(
              "Detected a ndiswrapper configuration,\n" \
              "but the kernel module was not modprobed.\n" \
              "Do you want to modprobe ndiswrapper?\n"
            )
          ) && (ModuleLoading.Load("ndiswrapper", "", "", "", false, true) == :fail)
        Popup.Error(
          _(
            "ndiswrapper kernel module has not been loaded.\nCheck configuration manually.\n"
          )
        )
      end
    end
  end

  Builtins.sleep(sl)

  return false if Abort()

  ProgressNextStage(_("Detecting network devices...")) if @gui
  # Dont read hardware data in config mode
  NetHwDetection.Start if !Mode.config

  Builtins.sleep(sl)

  return false if Abort()

  begin
    ProgressNextStage(_("Detecting current status...")) if @gui
    NetworkService.Read
    Builtins.sleep(sl)

    return false if Abort()

    ProgressNextStage(_("Reading device configuration...")) if @gui
    return false unless read_config

    Builtins.sleep(sl)

    return false if Abort()

    ProgressNextStage(_("Reading network configuration...")) if @gui
    NetworkConfig.Read

    @ipv6 = readIPv6

    Builtins.sleep(sl)

    Host.Read
    Builtins.sleep(sl)

    return false if Abort()

    if firewalld.installed? && !firewalld.read?
      ProgressNextStage(_("Reading firewall configuration...")) if @gui
      firewalld.read
      Builtins.sleep(sl)
    end

    return false if Abort()
  rescue IOError, SystemCallError, RuntimeError => e
    msg = format(_("Network configuration is corrupted.\n"\
                   "If you continue resulting configuration can be malformed."\
                   "\n\n%s"), wrap_text(e.message))
    return false if !@gui
    return false if !Popup.ContinueCancel(msg)
  end

  # Final progress step
  ProgressNextStage(_("Finished")) if @gui
  Builtins.sleep(sl)

  return false if Abort()

  @initialized = true

  fix_dhclient_warning(invalid_dhcp_cfgs) if @gui && !valid_dhcp_cfg?

  Progress.Finish if @gui

  true
end

#read_config(report: true) ⇒ Boolean

Reads system configuration

It resets the already read configuration. If some issue is detected while reading the configuration, it is reported to the user.

Parameters:

  • report (Boolean) (defaults to: true)

    Report any found issue if set to true

Returns:

  • (Boolean)

    Returns whether the configuration was read.



771
772
773
774
775
776
777
778
779
780
# File 'src/modules/Lan.rb', line 771

def read_config(report: true)
  result = Y2Network::Config.from(:wicked)
  return false if result.issues? && report && !Y2Issues.report(result.issues)

  system_config = result.config
  system_config.backend = (NetworkService.cached_name || :none)
  Yast::Lan.add_config(:system, system_config)
  Yast::Lan.add_config(:yast, system_config.copy)
  true
end

#read_step_labelsObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'src/modules/Lan.rb', line 169

def read_step_labels
  steps = [
    # Progress stage 1/5
    _("Detect network devices"),
    # Progress stage 2/5
    _("Read driver information"),
    # Progress stage 3/5
    _("Detect current status"),
    # Progress stage 4/5 - multiple devices may be present, really plural
    _("Read device configuration"),
    # Progress stage 5/5
    _("Read network configuration")
  ]

  steps << _("Read firewall configuration") if firewalld.installed?
  steps
end

#readIPv6Object

Checks local configuration if IPv6 is allowed

return [Boolean] true when IPv6 is enabled in the system



161
162
163
164
165
166
167
# File 'src/modules/Lan.rb', line 161

def readIPv6
  sysctl_config_file = CFA::SysctlConfig.new
  sysctl_config_file.load
  ipv6 = !sysctl_config_file.disable_ipv6
  log.info("readIPv6: IPv6 is #{ipv6 ? "enabled" : "disabled"}")
  ipv6
end

#ReadWithCacheBoolean

(a specialization used when a parameterless function is needed)

Returns:

  • (Boolean)

    true on success



349
350
351
# File 'src/modules/Lan.rb', line 349

def ReadWithCache
  Read(:cache)
end

#ReadWithCacheNoGUIObject



353
354
355
356
# File 'src/modules/Lan.rb', line 353

def ReadWithCacheNoGUI
  @gui = false
  ReadWithCache()
end

#SetIPv6(status) ⇒ Object



358
359
360
361
362
363
364
365
366
# File 'src/modules/Lan.rb', line 358

def SetIPv6(status)
  if @ipv6 != status
    @ipv6 = status
    Popup.Warning(_("To apply this change, a reboot is needed."))
    Lan.SetModified
  end

  nil
end

#SetModifiedObject



130
131
132
133
# File 'src/modules/Lan.rb', line 130

def SetModified
  @modified = true
  nil
end

#Summary(mode) ⇒ Object

Create a textual summary and a list of unconfigured devices

Parameters:

  • mode (String)

    "summary": add resolver and routing summary, "proposal": for proposal also with resolver an routing summary

Returns:

  • summary of the current configuration



633
634
635
636
637
638
639
640
641
642
# File 'src/modules/Lan.rb', line 633

def Summary(mode)
  return no_config_message if yast_config.nil?

  case mode
  when "summary", "proposal"
    Y2Network::Presenters::Summary.text_for(yast_config, "proposal")
  else
    Y2Network::Presenters::Summary.text_for(yast_config, "interfaces")
  end
end

#system_configY2Network::Config

Returns the system configuration

Just a convenience method.

Returns:



751
752
753
# File 'src/modules/Lan.rb', line 751

def system_config
  find_config(:system)
end

#UpcaseCondSet(ret, modify, key) ⇒ Object

If there's key in modify, upcase key and assign the value to ret

Returns:

  • ret



540
541
542
543
544
545
# File 'src/modules/Lan.rb', line 540

def UpcaseCondSet(ret, modify, key)
  ret = deep_copy(ret)
  modify = deep_copy(modify)
  Ops.set(ret, Builtins.toupper(key), Ops.get(modify, key)) if Builtins.haskey(modify, key)
  deep_copy(ret)
end

#valid_dhcp_cfg?Boolean

Checks if system DHCLIENT_SET_HOSTNAME is valid

Returns:

  • (Boolean)


334
335
336
# File 'src/modules/Lan.rb', line 334

def valid_dhcp_cfg?
  invalid_dhcp_cfgs.empty?
end

#Write(gui: true, apply_config: !write_only)) ⇒ Object

Update the SCR according to network settings

Returns:

  • true on success



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'src/modules/Lan.rb', line 391

def Write(gui: true, apply_config: !write_only)
  log.info("Writing configuration")

  # Query modified flag in all components
  if !Modified()
    log.info("No changes to network setup -> nothing to write")
    return true
  end

  # Write dialog caption
  caption = _("Saving Network Configuration")

  sl = 0 # 1000; /* TESTING
  Builtins.sleep(sl)

  step_labels = [
    # Progress stage 2
    _("Write drivers information"),
    # Progress stage 3 - multiple devices may be present,really plural
    _("Write device configuration"),
    # Progress stage 4
    _("Write network configuration"),
    # Progress stage 5
    _("Write routing configuration"),
    # Progress stage 6
    _("Write hostname and DNS configuration"),
    # Progress stage 7
    _("Set up network services")
  ]

  # Progress stage 8
  step_labels << _("Writing firewall configuration") if firewalld.installed?

  # Progress stage 9
  step_labels = Builtins.add(step_labels, _("Activate network services")) if apply_config
  # Progress stage 10
  step_labels = Builtins.add(step_labels, _("Update configuration"))

  Progress.New(
    caption,
    " ",
    Builtins.size(step_labels),
    step_labels,
    [],
    ""
  )

  return false if Abort()

  # Progress step 2
  ProgressNextStage(_("Writing /etc/modprobe.conf..."))
  Builtins.sleep(sl)

  return false if Abort()

  # Progress step 3 - multiple devices may be present, really plural
  ProgressNextStage(_("Writing device configuration..."))
  Builtins.sleep(sl)

  return false if Abort()

  # Progress step 4
  ProgressNextStage(_("Writing network configuration..."))
  NetworkConfig.Write
  Builtins.sleep(sl)

  return false if Abort()

  # Progress step 5
  ProgressNextStage(_("Writing routing configuration..."))
  orig = Progress.set(false)

  write_config

  Progress.set(orig)
  Builtins.sleep(sl)

  return false if Abort()

  # Progress step 6
  ProgressNextStage(_("Writing hostname and DNS configuration..."))
  # write resolv.conf after change from dhcp to static (#327074)
  # reload/restart network before this to put correct resolv.conf from dhcp-backup
  orig = Progress.set(false)
  Host.Write(gui: gui)
  Progress.set(orig)

  Builtins.sleep(sl)

  return false if Abort()

  # Progress step 7
  ProgressNextStage(_("Setting up network services..."))
  writeIPv6
  Builtins.sleep(sl)

  if firewalld.installed?
    return false if Abort()

    # Progress step 7
    ProgressNextStage(_("Writing firewall configuration..."))
    firewalld.write
    Builtins.sleep(sl)
  end

  if apply_config
    return false if Abort()

    # Progress step 9
    ProgressNextStage(_("Activating network services..."))

    select_network_service ? activate_network_service : NetworkService.disable

    Builtins.sleep(sl)
  end

  return false if Abort()

  # Progress step 10
  ProgressNextStage(_("Updating configuration..."))
  update_mta_config if !apply_config
  Builtins.sleep(sl)

  ensure_network_running if yast_config.backend?(:network_manager)

  # Final progress step
  ProgressNextStage(_("Finished"))
  Builtins.sleep(sl)

  Progress.Finish

  return false if Abort()

  true
end

#write_config(only: nil, report: true) ⇒ Object

Writes current yast config and replaces the system config with it

Parameters:

  • only (Array<Symbol>, nil) (defaults to: nil)

    explicit sections to be written, by default if no parameter is given then all changes will be written

See Also:



788
789
790
791
792
793
794
# File 'src/modules/Lan.rb', line 788

def write_config(only: nil, report: true)
  result = yast_config.write(original: system_config, only: only)
  return false if result&.issues? && report && !Y2Issues.report(result.issues)

  # Force a refresh of the system_config bsc#1162987
  add_config(:system, yast_config.copy)
end

#writeIPv6Object



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'src/modules/Lan.rb', line 368

def writeIPv6
  log.info("writeIPv6: IPv6 is #{@ipv6 ? "enabled" : "disabled"}")
  sysctl_config_file = CFA::SysctlConfig.new
  sysctl_config_file.load
  sysctl_config_file.disable_ipv6 = !@ipv6
  sysctl_config_file.save unless sysctl_config_file.conflict?
  SCR.Execute(
    path(".target.bash"),
    Builtins.sformat(
      "/usr/sbin/sysctl -w net.ipv6.conf.all.disable_ipv6=%1",
      @ipv6 ? "0" : "1"
    )
  )
  SCR.Write(
    path(".sysconfig.windowmanager.KDE_USE_IPV6"),
    @ipv6 ? "yes" : "no"
  )

  nil
end

#WriteOnlyObject

Only write configuration without starting any init scripts and SuSEconfig

Returns:

  • true on success



529
530
531
532
# File 'src/modules/Lan.rb', line 529

def WriteOnly
  @write_only = !autoinst.start_immediately
  Write()
end

#yast_configY2Network::Config

Returns YaST configuration

Just a convenience method.

Returns:



760
761
762
# File 'src/modules/Lan.rb', line 760

def yast_config
  find_config(:yast)
end