Class: Yast::LanClass

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

Constant Summary collapse

NM_DHCP_TIMEOUT =
45

Instance Method Summary collapse

Instance Method Details

#add_config(id, config) ⇒ Object

Adds the configuration


872
873
874
# File 'src/modules/Lan.rb', line 872

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

#AutoPackagesArray

mode


833
834
835
# File 'src/modules/Lan.rb', line 833

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

#clear_configsObject

Clears the network configurations list


877
878
879
# File 'src/modules/Lan.rb', line 877

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)

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


853
854
855
856
857
858
# File 'src/modules/Lan.rb', line 853

def dhcp_ntp_servers
  return [] if !NetworkService.isNetworkRunning || Yast::NetworkService.is_network_manager

  ReadWithCacheNoGUI()
  Yast::LanItems.dhcp_ntp_servers.values.flatten.uniq
end

#ExportObject

Export data. They need to be passed through Yast::LanAutoClient#ToAY to become what networking.rnc describes. Most prominently, instead of a flat list called "interfaces" we export a 2-level map of typed "devices"


713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
# File 'src/modules/Lan.rb', line 713

def Export
  profile = Y2Network::AutoinstProfile::NetworkingSection.new_from_network(yast_config)
  ay = {
    "dns"                  => profile.dns ? profile.dns.to_hashes : {},
    "net-udev"             => profile.udev_rules ? profile.udev_rules.udev_rules.map(&:to_hashes) : [],
    "s390-devices"         => profile.s390_devices ? profile.s390_devices.to_hashes["devices"] : [],
    "config"               => NetworkConfig.Export,
    "interfaces"           => profile.interfaces ? profile.interfaces.interfaces.map(&:to_hashes) : [],
    "ipv6"                 => @ipv6,
    "routing"              => profile.routing ? profile.routing.to_hashes : {},
    "managed"              => NetworkService.is_network_manager,
    "start_immediately"    => Ops.get_boolean(
      LanItems.autoinstall_settings,
      "start_immediately",
      false
    ), # start_immediately,
    "keep_install_network" => Ops.get_boolean(
      LanItems.autoinstall_settings,
      "keep_install_network",
      true
    )
  }
  Builtins.y2milestone("Exported map: %1", ay)
  deep_copy(ay)
end

#find_config(id) ⇒ Y2Network::Config?

Returns the network configuration with the given ID


864
865
866
# File 'src/modules/Lan.rb', line 864

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

#FromAY(input) ⇒ Object

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


597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
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 597

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

  input["interfaces"] ||= []
  # TODO: remove when s390 no longer need it
  interfaces = Builtins.listmap(input["interfaces"]) do |interface|
    # input: list of items $[ "device": "d", "foo": "f", "bar": "b"]
    # output: map of items  "d": $["FOO": "f", "BAR": "b"]
    new_interface = {}
    # uppercase map keys
    newk = nil
    interface = Builtins.mapmap(interface) do |k, v|
      newk = if k == "aliases"
        "_aliases"
      else
        Builtins.toupper(k)
      end
      { newk => v }
    end
    Builtins.foreach(interface) do |k, v|
      Ops.set(new_interface, k, v) if v != "" && k != "DEVICE"
    end
    new_device = Ops.get_string(interface, "DEVICE", "")
    { new_device => new_interface }
  end

  # split to a two level map like NetworkInterfaces
  devices = {}

  Builtins.foreach(interfaces) do |devname, if_data|
    # devname can be in old-style fashion (eth-bus-<pci_id>). So, convert it
    devname = LanItems.getDeviceName(devname)
    type = NetworkInterfaces.GetTypeFromIfcfgOrName(devname, if_data)
    d = Ops.get(devices, type, {})
    Ops.set(d, devname, if_data)
    Ops.set(devices, type, d)
  end

  hwcfg = {}
  if Ops.greater_than(Builtins.size(Ops.get_list(input, "modules", [])), 0)
    hwcfg = Builtins.listmap(Ops.get_list(input, "modules", [])) do |mod|
      options = Ops.get_string(mod, "options", "")
      module_name = Ops.get_string(mod, "module", "")
      start_mode = Ops.get_string(mod, "startmode", "auto")
      device_name = Ops.get_string(mod, "device", "")
      module_data = {
        "MODULE"         => module_name,
        "MODULE_OPTIONS" => options,
        "STARTMODE"      => start_mode
      }
      { device_name => module_data }
    end
  end

  Ops.set(input, "devices", devices)
  Ops.set(input, "hwcfg", hwcfg)

  # 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?
    Ops.set(input, ["config", "config"], "CHECK_DUPLICATE_IP" => true)
  end

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

#HaveXenBridgeObject

Xen bridging confuses us (#178848)


839
840
841
842
843
844
# File 'src/modules/Lan.rb', line 839

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

#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"


688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
# File 'src/modules/Lan.rb', line 688

def Import(settings)
  settings = {} if settings.nil?

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

  LanItems.Import(settings)
  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

#isAnyInterfaceDownObject

function for use from autoinstallation (Fate #301032)


133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
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
# File 'src/modules/Lan.rb', line 133

def isAnyInterfaceDown
  down = false
  link_status = {}
  net_devices = Builtins.splitstring(
    Ops.get_string(
      Convert.convert(
        SCR.Execute(
          path(".target.bash_output"),
          "/usr/bin/ls /sys/class/net/ | /usr/bin/grep -v lo | /usr/bin/tr '\n' ','"
        ),
        from: "any",
        to:   "map <string, any>"
      ),
      "stdout",
      ""
    ),
    ","
  )
  net_devices = Builtins.filter(net_devices) do |item|
    Ops.greater_than(Builtins.size(item), 0)
  end
  Builtins.foreach(net_devices) do |net_dev|
    row = Builtins.splitstring(
      Ops.get_string(
        SCR.Execute(
          path(".target.bash_output"),
          Builtins.sformat(
            "/usr/sbin/ip address show dev %1 | /usr/bin/grep 'inet\\|link' | /usr/bin/sed 's/^ \\+//g'| /usr/bin/cut -d' ' -f-2",
            net_dev.shellescape
          )
        ),
        "stdout",
        ""
      ),
      "\n"
    )
    tmp_mac = ""
    addr = false
    Builtins.foreach(row) do |column|
      tmp_col = Builtins.splitstring(column, " ")
      next if Ops.less_than(Builtins.size(tmp_col), 2)
      if Builtins.issubstring(Ops.get(tmp_col, 0, ""), "link/ether")
        tmp_mac = Ops.get(tmp_col, 1, "")
      end
      if Builtins.issubstring(Ops.get(tmp_col, 0, ""), "inet") &&
          !Builtins.issubstring(Ops.get(tmp_col, 0, ""), "inet6")
        addr = true
      end
    end
    if Ops.greater_than(Builtins.size(tmp_mac), 0)
      Ops.set(link_status, tmp_mac, addr)
    end
    Builtins.y2debug("link_status %1", link_status)
  end

  Builtins.y2milestone("link_status %1", link_status)
  configurations = NetworkInterfaces.FilterDevices("")
  Builtins.foreach(
    Builtins.splitstring(
      Ops.get(NetworkInterfaces.CardRegex, "netcard", ""),
      "|"
    )
  ) do |devtype|
    Builtins.foreach(
      Convert.convert(
        Map.Keys(Ops.get_map(configurations, devtype, {})),
        from: "list",
        to:   "list <string>"
      )
    ) do |devname|
      address_file = "/sys/class/net/#{devname}/address"
      mac = ::File.read(address_file).chomp if ::File.file?(address_file)
      Builtins.y2milestone("confname %1", mac)
      if !Builtins.haskey(link_status, mac)
        Builtins.y2error(
          "Mac address %1 not found in map %2!",
          mac,
          link_status
        )
      elsif Ops.get_boolean(link_status, mac, false) == false
        Builtins.y2warning("Interface with mac %1 is down!", mac)
        down = true
      else
        Builtins.y2debug("Interface with mac %1 is up", mac)
      end
    end
  end
  down
end

#mainObject


51
52
53
54
55
56
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
108
109
# File 'src/modules/Lan.rb', line 51

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 "NetworkInterfaces"
  Yast.import "NetworkService"
  Yast.import "Package"
  Yast.import "ProductFeatures"
  Yast.import "Progress"
  Yast.import "String"
  Yast.import "FileUtils"
  Yast.import "PackageSystem"
  Yast.import "LanItems"
  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

  # list of interface names which were recently assigned as a slave to a bond device
  @bond_autoconf_slaves = []

  # list of interface names which were recently enslaved in a bridge or bond device
  @autoconf_slaves = []

  # 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


117
118
119
120
121
122
123
124
125
# File 'src/modules/Lan.rb', line 117

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


814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'src/modules/Lan.rb', line 814

def Packages
  pkgs = []

  if NetworkService.is_network_manager
    pkgs << "NetworkManager" if !PackageSystem.Installed("NetworkManager")
  elsif !PackageSystem.Installed("wpa_supplicant")
    # we have to add wpa_supplicant when wlan is in game, wicked relies on it
    pkgs << "wpa_supplicant" if !LanItems.find_type_ifaces("wlan").empty?
  end

  pkgs.uniq!

  log.info("Additional packages requested by yast2-network: #{pkgs.inspect}") if !pkgs.empty?

  pkgs
end

#ProposeVirtualizedObject


784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'src/modules/Lan.rb', line 784

def ProposeVirtualized
  # then each configuration (except bridges) move to the bridge
  # and add old device name into bridge_ports
  yast_config.interfaces.each do |interface|
    bridge_builder = Y2Network::InterfaceConfigBuilder.for("br")
    bridge_builder.name = yast_config.interfaces.free_name("br")

    next unless connected_and_bridgeable?(bridge_builder, interface)

    next if yast_config.connections.by_name(interface.name)

    bridge_builder.stp = false
    bridge_builder.ports = [interface.name]
    bridge_builder.startmode = "auto"
    bridge_builder.save

    builder = Y2Network::InterfaceConfigBuilder.for(interface.type)
    builder.name = interface.name
    builder.configure_as_slave
    builder.save
    LanItems.move_routes(builder.name, bridge_builder.name)
    refresh_interfaces
  end

  nil
end

#Read(cache) ⇒ Object

Read all network settings from the SCR


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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'src/modules/Lan.rb', line 259

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 && PackageSystem.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"
            )
          )
        if ModuleLoading.Load("ndiswrapper", "", "", "", false, true) == :fail
          Popup.Error(
            _(
              "ndiswrapper kernel module has not been loaded.\nCheck configuration manually.\n"
            )
          )
        end
      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()
  ProgressNextStage(_("Reading device configuration...")) if @gui
  read_config

  Builtins.sleep(sl)

  return false if Abort()
  ProgressNextStage(_("Reading network configuration...")) if @gui
  begin
    NetworkConfig.Read

    @ipv6 = readIPv6

    Builtins.sleep(sl)

    Host.Read
    Builtins.sleep(sl)

    return false if Abort()
    ProgressNextStage(_("Detecting current status...")) if @gui
    NetworkService.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 => error
    msg = format(_("Network configuration is corrupted.\n"\
            "If you continue resulting configuration can be malformed."\
            "\n\n%s"), wrap_text(error.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(LanItems.invalid_dhcp_cfgs) if @gui && !LanItems.valid_dhcp_cfg?

  Progress.Finish if @gui

  true
end

#read_step_labelsObject


234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'src/modules/Lan.rb', line 234

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

  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


226
227
228
229
230
231
232
# File 'src/modules/Lan.rb', line 226

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

#ReadWithCacheBoolean

(a specialization used when a parameterless function is needed)


383
384
385
# File 'src/modules/Lan.rb', line 383

def ReadWithCache
  Read(:cache)
end

#ReadWithCacheNoGUIObject


387
388
389
390
# File 'src/modules/Lan.rb', line 387

def ReadWithCacheNoGUI
  @gui = false
  ReadWithCache()
end

#SetIPv6(status) ⇒ Object


392
393
394
395
396
397
398
399
400
# File 'src/modules/Lan.rb', line 392

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

  nil
end

#SetModifiedObject


127
128
129
130
# File 'src/modules/Lan.rb', line 127

def SetModified
  @modified = true
  nil
end

#Summary(mode) ⇒ Object

Create a textual summary and a list of unconfigured devices


743
744
745
746
747
748
749
750
751
752
# File 'src/modules/Lan.rb', line 743

def Summary(mode)
  case mode
  when "summary"
    "#{interfaces_summary}#{dns_summary}#{routing_summary}"
  when "proposal"
    "#{LanItems.summary(:proposal)}#{dns_summary}#{routing_summary}"
  else
    interfaces_summary
  end
end

#system_configY2Network::Config

Returns the system configuration

Just a convenience method.


886
887
888
# File 'src/modules/Lan.rb', line 886

def system_config
  find_config(:system)
end

#UpcaseCondSet(ret, m, key) ⇒ Object

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


584
585
586
587
588
589
590
591
# File 'src/modules/Lan.rb', line 584

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

#UseNetworkManagerObject

Uses product info and is subject to installed packages.


756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
# File 'src/modules/Lan.rb', line 756

def UseNetworkManager
  nm_default = false
  nm_feature = ProductFeatures.GetStringFeature(
    "network",
    "network_manager"
  )

  case nm_feature
  when ""
    # compatibility: use the boolean feature
    # (defaults to false)
    nm_default = ProductFeatures.GetBooleanFeature(
      "network",
      "network_manager_is_default"
    )
  when "always"
    nm_default = true
  when "laptop"
    nm_default = Arch.is_laptop
    log.info("Is a laptop: #{nm_default}")
  end

  nm_installed = Package.Installed("NetworkManager")
  log.info("NetworkManager wanted: #{nm_default}, installed: #{nm_installed}")

  nm_default && nm_installed
end

#Write(gui: true) ⇒ Object

Update the SCR according to network settings


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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'src/modules/Lan.rb', line 427

def Write(gui: true)
  Builtins.y2milestone("Writing configuration")

  # Query modified flag in all components, not just LanItems - DNS,
  # Routing, NetworkConfig too in order not to discard changes made
  # outside LanItems (bnc#439235)
  if !Modified()
    Builtins.y2milestone("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
  if !@write_only
    step_labels = Builtins.add(step_labels, _("Activate network services"))
  end
  # 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)

  target = :sysconfig if Mode.auto
  yast_config.write(original: system_config, target: target)
  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 !@write_only
    return false if Abort()
    # Progress step 9
    ProgressNextStage(_("Activating network services..."))

    activate_network_service

    Builtins.sleep(sl)
  end

  return false if Abort()
  # Progress step 10
  ProgressNextStage(_("Updating configuration..."))
  update_mta_config if !@write_only
  Builtins.sleep(sl)

  if NetworkService.is_network_manager
    network = false
    timeout = NM_DHCP_TIMEOUT
    while Ops.greater_than(timeout, 0)
      if NetworkService.isNetworkRunning
        network = true
        break
      end
      Builtins.y2milestone("waiting for network ... %1", timeout)
      Builtins.sleep(1000)
      timeout = Ops.subtract(timeout, 1)
    end

    Popup.Error(_("No network running")) unless network
  end

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

  Progress.Finish

  return false if Abort()
  true
end

#writeIPv6Object


402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'src/modules/Lan.rb', line 402

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

  nil
end

#WriteOnlyObject

Only write configuration without starting any init scripts and SuSEconfig


573
574
575
576
577
578
579
580
# File 'src/modules/Lan.rb', line 573

def WriteOnly
  @write_only = !Ops.get_boolean(
    LanItems.autoinstall_settings,
    "start_immediately",
    false
  )
  Write()
end

#yast_configY2Network::Config

Returns YaST configuration

Just a convenience method.


895
896
897
# File 'src/modules/Lan.rb', line 895

def yast_config
  find_config(:yast)
end