Module: Yast::NetworkRoutinesInclude
- Includes:
- I18n, Logger, Yast
- Defined in:
- src/include/network/routines.rb
Constant Summary
Constants included from Yast
DNS, Host, Lan, LanItems, NetHwDetection, Routing
Instance Method Summary collapse
-
#Abort ⇒ Object
Abort function.
-
#add_pkgs_to_proposal(packages) ⇒ Object
Adds the packages to the software proposal to make sure they are available in the installed system.
-
#ControllerType(hwdevice) ⇒ Object
Simple convertor from subclass to controller type.
-
#dev_port(dev_name) ⇒ String
Dev port of the given interface from /sys/class/net/$dev_name/dev_port.
-
#dev_port?(dev_name) ⇒ boolean
Checks if the given interface exports its dev port via sysfs.
-
#DeviceName(hwdevice) ⇒ Object
Extract the device 'name'.
-
#disable_unconfigureable_items(items, show_popup) ⇒ Object
Disables all widgets which cannot be configured with current network service.
- #DistinguishedName(name, hwdevice) ⇒ Object
-
#DriverType(type) ⇒ Object
For s390 hwinfo gives us a multitude of types but some are handled the same, mostly acording to the driver which is used.
-
#has_carrier?(dev_name) ⇒ boolean
Checks if given device has carrier.
- #initialize_network_routines(_include_target) ⇒ Object
-
#IsEmpty(value) ⇒ Object
Checks if given value is emtpy.
-
#IsNotEmpty(value) ⇒ Object
Checks if given value is non emtpy.
-
#PackagesInstall(packages) ⇒ Object
Check if required packages are installed and install them if they're not.
-
#phy_connected?(dev_name) ⇒ boolean
Checks if device is physically connected to a network.
-
#physical_port_id(dev_name) ⇒ String
With NPAR and SR-IOV capabilities, one device could divide a ethernet port in various.
-
#physical_port_id?(dev_name) ⇒ boolean
True if the physical port id is not empty.
-
#PollAbort ⇒ Object
Check for pending Abort press.
-
#ProgressNextStage(title) ⇒ Object
Progress::NextStage and Progress::Title combined into one function.
-
#ReadHardware(hwtype) ⇒ Object
Read HW information.
-
#ReallyAbort ⇒ Object
If modified, ask for confirmation.
-
#ReallyAbortCond(modified) ⇒ Object
If modified, ask for confirmation.
-
#Run(command) ⇒ Object
Run an external command on the target machine and check if it was successful.
-
#RunAndRead(command) ⇒ Object
Hash in form $[ “exit”: <command-exit-status>, “output”: [ <1st line>, <2nd line>, … ] ].
- #s390_device_needs_persistent_mac(sysfs_id, hardware) ⇒ Object
-
#SetIfaceDown(dev_name) ⇒ Object
Calls wicked ifdown with the given interface.
-
#SetLinkUp(dev_name) ⇒ Object
Wrapper to call 'ip link set up' with the given interface.
- #sysfs_card_type(sysfs_id, _hardware) ⇒ Object
- #unconfigureable_service? ⇒ Boolean
-
#ValidNicName(name) ⇒ Object
Validates given name for use as a nic name in sysconfig.
Methods included from Yast
#lan_summary, #load_hosts, #settings
Instance Method Details
#Abort ⇒ Object
Abort function
62 63 64 65 66 |
# File 'src/include/network/routines.rb', line 62 def Abort return false if Mode.commandline UI.PollInput == :abort end |
#add_pkgs_to_proposal(packages) ⇒ Object
Adds the packages to the software proposal to make sure they are available in the installed system
100 101 102 103 104 |
# File 'src/include/network/routines.rb', line 100 def add_pkgs_to_proposal(packages) log.info "Adding network packages to proposal: #{packages}" PackagesProposal.AddResolvables("network", :package, packages) unless packages.empty? :next end |
#ControllerType(hwdevice) ⇒ Object
Simple convertor from subclass to controller type.
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 380 381 382 383 384 385 386 387 388 389 390 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 |
# File 'src/include/network/routines.rb', line 263 def ControllerType(hwdevice) hwdevice = deep_copy(hwdevice) return "modem" if Ops.get_string(hwdevice, "subclass", "") == "Modem" return "isdn" if Ops.get_string(hwdevice, "subclass", "") == "ISDN" return "dsl" if Ops.get_string(hwdevice, "subclass", "") == "DSL" subclass_id = Ops.get_integer(hwdevice, "sub_class_id", -1) # Network controller if Ops.get_integer(hwdevice, "class_id", -1) == 2 case subclass_id when 0 return "eth" when 1 return "tr" when 2 return "fddi" when 3 return "atm" when 4 return "isdn" when 6 ## Should be PICMG? return "ib" when 7 return "ib" when 129 return "myri" when 130 return "wlan" when 131 return "xp" when 134 return "qeth" when 135 return "hsi" when 136 return "ctc" when 137 return "lcs" when 142 return "ficon" when 143 return "escon" when 144 return "iucv" when 145 return "usb" # #22739 when 128 # Mellanox ConnectX-3 series badly uses the 128 sub class # Check for the specific known boards with bad subclass. # # Concerned devices are: # 15b3:1003 MT27500 Family [ConnectX-3] # 15b3:1004 MT27500/MT27520 Family [ConnectX-3/ConnectX-3 Pro Virtual Function] # 15b3:1007 MT27520 Family [ConnectX-3 Pro] if hwdevice["vendor_id"] == 71_091 return "ib" if [69_635, 69_636, 69_639].include?(hwdevice["device_id"]) end # Nothing was found Builtins.y2error("Unknown network controller type: %1", hwdevice) Builtins.y2error( "It's probably missing in hwinfo (NOT src/hd/hd.h:sc_net_if)" ) return "" else # Nothing was found Builtins.y2error("Unknown network controller type: %1", hwdevice) return "" end end # exception for infiniband device if Ops.get_integer(hwdevice, "class_id", -1) == 12 return "ib" if subclass_id == 6 end # Communication controller if Ops.get_integer(hwdevice, "class_id", -1) == 7 case subclass_id when 3 return "modem" when 128 # Nothing was found Builtins.y2error("Unknown network controller type: %1", hwdevice) Builtins.y2error( "It's probably missing in hwinfo (src/hd/hd.h:sc_net_if)" ) return "" else # Nothing was found Builtins.y2error("Unknown network controller type: %1", hwdevice) return "" end # Network Interface # check the CVS history and then kill this code! # 0x107 is the output of hwinfo --network # which lists the INTERFACES # but we are inteested in hwinfo --netcard # Just make sure that hwinfo or ag_probe # indeed does not pass this to us elsif Ops.get_integer(hwdevice, "class_id", -1) == 263 Builtins.y2milestone("CLASS 0x107") # this should happen rarely case subclass_id when 0 return "lo" when 1 return "eth" when 2 return "tr" when 3 return "fddi" when 4 return "ctc" when 5 return "iucv" when 6 return "hsi" when 7 return "qeth" when 8 return "escon" when 9 return "myri" when 10 return "wlan" when 11 return "xp" when 12 return "usb" when 128 # Nothing was found Builtins.y2error("Unknown network interface type: %1", hwdevice) Builtins.y2error( "It's probably missing in hwinfo (src/hd/hd.h:sc_net_if)" ) return "" when 129 return "sit" else # Nothing was found Builtins.y2error("Unknown network interface type: %1", hwdevice) return "" end elsif Ops.get_integer(hwdevice, "class_id", -1) == 258 return "modem" elsif Ops.get_integer(hwdevice, "class_id", -1) == 259 return "isdn" elsif Ops.get_integer(hwdevice, "class_id", -1) == 276 return "dsl" end # Nothing was found Builtins.y2error("Unknown controller type: %1", hwdevice) "" end |
#dev_port(dev_name) ⇒ String
Dev port of the given interface from /sys/class/net/$dev_name/dev_port
729 730 731 732 733 734 |
# File 'src/include/network/routines.rb', line 729 def dev_port(dev_name) SCR.Read( path(".target.string"), "/sys/class/net/#{dev_name}/dev_port" ).to_s.strip end |
#dev_port?(dev_name) ⇒ boolean
Checks if the given interface exports its dev port via sysfs
740 741 742 |
# File 'src/include/network/routines.rb', line 740 def dev_port?(dev_name) !dev_port(dev_name).empty? end |
#DeviceName(hwdevice) ⇒ Object
Extract the device 'name'
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'src/include/network/routines.rb', line 235 def DeviceName(hwdevice) device = hwdevice["device"] || "" return device if !device.empty? model = hwdevice["model"] || "" return model if !model.empty? vendor = hwdevice["sub_vendor"] || "" dev = hwdevice["sub_device"] || "" if vendor.empty? || dev.empty? vendor = hwdevice["vendor"] || "" dev = hwdevice["device"] || "" end "#{vendor} #{dev}".strip end |
#disable_unconfigureable_items(items, show_popup) ⇒ Object
Disables all widgets which cannot be configured with current network service
see bnc#433084 if listed any items, disable them, if show_popup, show warning popup
returns true if items were disabled
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'src/include/network/routines.rb', line 779 def disable_unconfigureable_items(items, show_popup) return false if !unconfigureable_service? items.each { |i| UI.ChangeWidget(Id(i), :Enabled, false) } if show_popup Popup.Warning( _( "Network is currently handled by NetworkManager\n" \ "or completely disabled. YaST is unable to configure some options." ) ) UI.FakeUserInput("ID" => "global") end true end |
#DistinguishedName(name, hwdevice) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 |
# File 'src/include/network/routines.rb', line 220 def DistinguishedName(name, hwdevice) hwdevice = deep_copy(hwdevice) if Ops.get_string(hwdevice, "sysfs_bus_id", "") != "" return Builtins.sformat( "%1 (%2)", name, Ops.get_string(hwdevice, "sysfs_bus_id", "") ) end name end |
#DriverType(type) ⇒ Object
For s390 hwinfo gives us a multitude of types but some are handled the same, mostly acording to the driver which is used. So let's group them under the name Driver Type.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'src/include/network/routines.rb', line 177 def DriverType(type) drvtype = type # handle HSI like qeth, S#40692#c15 if type == "hsi" drvtype = "qeth" # Should eth occur on s390? elsif type == "tr" || type == "eth" drvtype = "lcs" # N#82891 elsif type == "escon" || type == "ficon" drvtype = "ctc" end drvtype end |
#has_carrier?(dev_name) ⇒ boolean
Checks if given device has carrier
699 700 701 702 703 704 |
# File 'src/include/network/routines.rb', line 699 def has_carrier?(dev_name) SCR.Read( path(".target.string"), "/sys/class/net/#{dev_name}/carrier" ).to_i != 0 end |
#initialize_network_routines(_include_target) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'src/include/network/routines.rb', line 38 def initialize_network_routines(_include_target) Yast.import "UI" textdomain "network" Yast.import "Popup" Yast.import "Progress" Yast.import "String" Yast.import "NetworkService" Yast.import "NetworkInterfaces" Yast.import "Arch" Yast.import "Confirm" Yast.import "Map" Yast.import "Netmask" Yast.import "Mode" Yast.import "IP" Yast.import "TypeRepository" Yast.import "Stage" Yast.import "PackagesProposal" Yast.import "Report" end |
#IsEmpty(value) ⇒ Object
Checks if given value is emtpy.
161 162 163 164 |
# File 'src/include/network/routines.rb', line 161 def IsEmpty(value) value = deep_copy(value) TypeRepository.IsEmpty(value) end |
#IsNotEmpty(value) ⇒ Object
Checks if given value is non emtpy.
167 168 169 170 |
# File 'src/include/network/routines.rb', line 167 def IsNotEmpty(value) value = deep_copy(value) !IsEmpty(value) end |
#PackagesInstall(packages) ⇒ Object
Check if required packages are installed and install them if they're not
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'src/include/network/routines.rb', line 109 def PackagesInstall(packages) packages = deep_copy(packages) return :next if packages == [] log.info "Checking packages: #{packages}" # bnc#888130 In inst-sys, there is no RPM database to check # If the required package is part of the inst-sys, it will work, # if not, package can't be installed anyway # # Ideas: # - check /.packages.* for presence of the required package # - use `extend` to load the required packages on-the-fly return :next if Stage.initial Yast.import "Package" return :next if Package.InstalledAll(packages) # Popup text text = _("These packages need to be installed:") + "<p>" Builtins.foreach(packages) do |l| text = Ops.add(text, Builtins.sformat("%1<br>", l)) end Builtins.y2debug("Installing packages: %1", text) ret = false loop do ret = Package.InstallAll(packages) break if ret == true if ret == false && Package.InstalledAll(packages) ret = true break end # Popup text if !Popup.YesNo( _( "The required packages are not installed.\n" \ "The configuration will be aborted.\n" \ "\n" \ "Try again?\n" ) + "\n" ) break end end ret == true ? :next : :abort end |
#phy_connected?(dev_name) ⇒ boolean
Checks if device is physically connected to a network
It does neccessary steps which might be needed for proper initialization of devices driver.
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'src/include/network/routines.rb', line 750 def phy_connected?(dev_name) return true if has_carrier?(dev_name) # SetLinkUp ensures that driver is loaded SetLinkUp(dev_name) # Wait for driver initialization if needed. bnc#876848 # 5 secs is minimum proposed by sysconfig guys for intel drivers. # # For a discussion regarding this see # https://github.com/yast/yast-network/pull/202 sleep(5) has_carrier?(dev_name) end |
#physical_port_id(dev_name) ⇒ String
With NPAR and SR-IOV capabilities, one device could divide a ethernet port in various. If the driver module support it, we can check the phys port id via sysfs reading the /sys/class/net/$dev_name/phys_port_id
712 713 714 715 716 717 |
# File 'src/include/network/routines.rb', line 712 def physical_port_id(dev_name) SCR.Read( path(".target.string"), "/sys/class/net/#{dev_name}/phys_port_id" ).to_s.strip end |
#physical_port_id?(dev_name) ⇒ boolean
Returns true if the physical port id is not empty.
721 722 723 |
# File 'src/include/network/routines.rb', line 721 def physical_port_id?(dev_name) !physical_port_id(dev_name).empty? end |
#PollAbort ⇒ Object
Check for pending Abort press
70 71 72 |
# File 'src/include/network/routines.rb', line 70 def PollAbort UI.PollInput == :abort end |
#ProgressNextStage(title) ⇒ Object
Progress::NextStage and Progress::Title combined into one function
89 90 91 92 93 94 |
# File 'src/include/network/routines.rb', line 89 def ProgressNextStage(title) Progress.NextStage Progress.Title(title) nil end |
#ReadHardware(hwtype) ⇒ Object
Read HW information
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 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 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 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 |
# File 'src/include/network/routines.rb', line 421 def ReadHardware(hwtype) hardware = [] Builtins.y2debug("hwtype=%1", hwtype) # Confirmation: label text (detecting hardware: xxx) return [] if !confirmed_detection(hwtype) # read the corresponding hardware allcards = [] if hwtypes[hwtype] allcards = Convert.to_list(SCR.Read(hwtypes[hwtype])) elsif hwtype == "all" || hwtype.nil? || hwtype.empty? Builtins.maplist( Convert.convert( Map.Values(hwtypes), from: "list", to: "list <path>" ) ) do |v| allcards = Builtins.merge(allcards, Convert.to_list(SCR.Read(v))) end else Builtins.y2error("unknown hwtype: %1", hwtype) return [] end if allcards.nil? Builtins.y2error("hardware detection failure") return [] end # #97540 bms = Convert.to_string(SCR.Read(path(".etc.install_inf.BrokenModules"))) bms = "" if bms.nil? broken_modules = Builtins.splitstring(bms, " ") # fill in the hardware data num = 0 Builtins.maplist( Convert.convert(allcards, from: "list", to: "list <map>") ) do |card| # common stuff resource = Ops.get_map(card, "resource", {}) controller = ControllerType(card) one = {} one["name"] = DeviceName(card) # Temporary solution for s390: #40587 one["name"] = DistinguishedName(one["name"], card) if Arch.s390 one["type"] = controller one["udi"] = card["udi"] || "" one["sysfs_id"] = card["sysfs_id"] || "" one["dev_name"] = card["dev_name"] || "" one["requires"] = card["requires"] || [] one["modalias"] = card["modalias"] || "" one["unique"] = card["unique_key"] || "" # driver option needs for (bnc#412248) one["driver"] = card["driver"] || "" # Each card remembers its position in the list of _all_ cards. # It is used when selecting the card from the list of _unconfigured_ # ones (which may be smaller). #102945. one["num"] = num case controller # modem when "modem" one["device_name"] = card["dev_name"] || "" one["drivers"] = card["drivers"] || [] speed = Ops.get_integer(resource, ["baud", 0, "speed"], 57_600) # :-) have to check .probe and libhd if this confusion is # really necessary. maybe a pppd bug too? #148893 speed = 57_600 if speed == 12_000_000 one["speed"] = speed one["init1"] = Ops.get_string(resource, ["init_strings", 0, "init1"], "") one["init2"] = Ops.get_string(resource, ["init_strings", 0, "init2"], "") one["pppd_options"] = Ops.get_string(resource, ["pppd_option", 0, "option"], "") # isdn card when "isdn" drivers = card["isdn"] || [] one["drivers"] = drivers one["sel_drv"] = 0 one["bus"] = card["bus"] || "" one["io"] = Ops.get_integer(resource, ["io", 0, "start"], 0) one["irq"] = Ops.get_integer(resource, ["irq", 0, "irq"], 0) # dsl card when "dsl" driver_info = Ops.get_map(card, ["dsl", 0], {}) translate_mode = { "capiadsl" => "capi-adsl", "pppoe" => "pppoe" } m = driver_info["mode"] || "" one["pppmode"] = translate_mode[m] || m # treat the rest as a network card else # drivers: # Although normally there is only one module # (one=$[active:, module:, options:,...]), the generic # situation is: one or more driver variants (exclusive), # each having one or more modules (one[drivers]) # only drivers that are not marked as broken (#97540) drivers = Builtins.filter(Ops.get_list(card, "drivers", [])) do |d| # ignoring more modules per driver... module0 = Ops.get_list(d, ["modules", 0], []) # [module, options] brk = broken_modules.include?(module0[0]) if brk Builtins.y2milestone("In BrokenModules, skipping: %1", module0) end !brk end if drivers == [] Builtins.y2milestone("No good drivers found") else one["drivers"] = drivers driver = drivers[0] || {} one["active"] = driver["active"] || false module0 = Ops.get_list(driver, ["modules", 0], []) one["module"] = module0[0] || "" one["options"] = module0[1] || "" end # FIXME: this should be also done for modems and others # FIXME: #13571 hp = card["hotplug"] || "" if hp == "pcmcia" || hp == "cardbus" one["hotplug"] = "pcmcia" elsif hp == "usb" one["hotplug"] = "usb" end # store the BUS type bus = card["bus_hwcfg"] || card["bus"] || "" if bus == "PCI" bus = "pci" elsif bus == "USB" bus = "usb" elsif bus == "Virtual IO" bus = "vio" end one["bus"] = bus one["busid"] = card["sysfs_bus_id"] || "" if one["busid"].start_with?("virtio") one["parent_busid"] = one["sysfs_id"].split("/")[-2] end one["mac"] = Ops.get_string(resource, ["hwaddr", 0, "addr"], "") one["permanent_mac"] = Ops.get_string(resource, ["phwaddr", 0, "addr"], "") # is the cable plugged in? nil = don't know one["link"] = Ops.get(resource, ["link", 0, "state"]) # Wireless Card Features one["wl_channels"] = Ops.get(resource, ["wlan", 0, "channels"]) one["wl_bitrates"] = Ops.get(resource, ["wlan", 0, "bitrates"]) one["wl_auth_modes"] = Ops.get(resource, ["wlan", 0, "auth_modes"]) one["wl_enc_modes"] = Ops.get(resource, ["wlan", 0, "enc_modes"]) end if controller != "" && !filter_out(card, one["module"]) Builtins.y2debug("found device: %1", one) Ops.set(hardware, Builtins.size(hardware), one) num += 1 else Builtins.y2milestone("Filtering out: %1", card) end end # if there is wlan, put it to the front of the list # that's because we want it proposed and currently only one card # can be proposed found = false i = 0 Builtins.foreach(hardware) do |h| if h["type"] == "wlan" found = true raise Break end i += 1 end if found temp = hardware[0] || {} hardware[0] = hardware[i] hardware[i] = temp # adjust mapping: #98852, #102945 Ops.set(hardware, [0, "num"], 0) Ops.set(hardware, [i, "num"], i) end Builtins.y2debug("Hardware=%1", hardware) deep_copy(hardware) end |
#ReallyAbort ⇒ Object
If modified, ask for confirmation
76 77 78 |
# File 'src/include/network/routines.rb', line 76 def ReallyAbort Popup.ReallyAbort(true) end |
#ReallyAbortCond(modified) ⇒ Object
If modified, ask for confirmation
83 84 85 |
# File 'src/include/network/routines.rb', line 83 def ReallyAbortCond(modified) !modified || Popup.ReallyAbort(true) end |
#Run(command) ⇒ Object
Run an external command on the target machine and check if it was successful. Remember to always use a full path for the command and to quote the arguments. Using shellescape() is recommended.
668 669 670 671 672 673 674 675 676 677 |
# File 'src/include/network/routines.rb', line 668 def Run(command) if !command.lstrip.start_with?("/") log.warn("Command does not have an absolute path: #{command}") end ret = SCR.Execute(path(".target.bash"), command).zero? Builtins.y2error("Run <%1>: Command execution failed.", command) if !ret ret end |
#RunAndRead(command) ⇒ Object
Returns Hash in form $[ “exit”: <command-exit-status>, “output”: [ <1st line>, <2nd line>, … ] ].
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 |
# File 'src/include/network/routines.rb', line 631 def RunAndRead(command) if !command.lstrip.start_with?("/") log.warn("Command does not have an absolute path: #{command}") end ret = { "exit" => false, "output" => [] } result = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) output = Ops.get_string(result, "stdout", "") if Builtins.regexpmatch(output, ".*\n$") output = Builtins.substring( output, 0, Ops.subtract(Builtins.size(output), 1) ) end Ops.set(ret, "output", Builtins.splitstring(output, "\n")) Ops.set(ret, "exit", Ops.get_integer(result, "exit", 1) == 0) if Ops.get_boolean(ret, "exit", false) == false || IsEmpty(Ops.get_string(result, "stderr", "")) == false Builtins.y2error( "RunAndRead <%1>: Command execution failed.\n%2", command, Ops.get_string(result, "stderr", "") ) end deep_copy(ret) end |
#s390_device_needs_persistent_mac(sysfs_id, hardware) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'src/include/network/routines.rb', line 199 def s390_device_needs_persistent_mac(sysfs_id, hardware) hardware = deep_copy(hardware) card_type = sysfs_card_type(sysfs_id, hardware) types_needing_persistent = [ "OSD_100", "OSD_1000", "OSD_10GIG", "OSD_FE_LANE", "OSD_GbE_LANE", "OSD_Express" ] needs_persistent = Builtins.contains(types_needing_persistent, card_type) Builtins.y2milestone( "Sysfs Device: %1, card type: %2, needs persistent MAC: %3", sysfs_id, card_type, needs_persistent ) needs_persistent end |
#SetIfaceDown(dev_name) ⇒ Object
Calls wicked ifdown with the given interface
691 692 693 694 |
# File 'src/include/network/routines.rb', line 691 def SetIfaceDown(dev_name) log.info("Setting interface #{dev_name} down") Run("/sbin/ifdown #{dev_name.shellescape}") end |
#SetLinkUp(dev_name) ⇒ Object
Wrapper to call 'ip link set up' with the given interface
683 684 685 686 |
# File 'src/include/network/routines.rb', line 683 def SetLinkUp(dev_name) log.info("Setting link up for interface #{dev_name}") Run("/sbin/ip link set #{dev_name.shellescape} up") end |
#sysfs_card_type(sysfs_id, _hardware) ⇒ Object
192 193 194 195 196 197 |
# File 'src/include/network/routines.rb', line 192 def sysfs_card_type(sysfs_id, _hardware) return "none" if sysfs_id == "" filename = Ops.add(Ops.add("/sys", sysfs_id), "/card_type") card_type = Convert.to_string(SCR.Read(path(".target.string"), filename)) String.FirstChunk(card_type, "\n") end |
#unconfigureable_service? ⇒ Boolean
766 767 768 769 770 771 |
# File 'src/include/network/routines.rb', line 766 def unconfigureable_service? return true if Mode.normal && NetworkService.is_network_manager return true if NetworkService.is_disabled false end |
#ValidNicName(name) ⇒ Object
Validates given name for use as a nic name in sysconfig. See bnc#784952
254 255 256 257 |
# File 'src/include/network/routines.rb', line 254 def ValidNicName(name) # 16 is the kernel limit on interface name size (IFNAMSIZ) !(name =~ /^[[:alnum:]._:-]{1,15}\z/).nil? end |