Class: Yast::LanItemsClass
- Inherits:
-
Module
- Object
- Module
- Yast::LanItemsClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/LanItems.rb
Overview
FIXME: well this class really is not nice rubocop:disable ClassLength
Constant Summary
- TRISTATE_TO_S =
{ nil => nil, false => "no", true => "yes" }.freeze
Instance Attribute Summary (collapse)
- - (list <map>) :Hardware(:Hardware)
-
- (Hash<Integer, Hash<String, Object> >, map <integer, any>) :Items(:Items)
Each item, indexed by an Integer in a Hash, aggregates several aspects of a network interface.
- - (list <string>) :Requires(:Requires)
- - (map <string, string>) :SysconfigDefaults(:SysconfigDefaults)
- - (string) alias
- - (map) aliases
- - (map) autoinstall_settings
- - (string) bond_option
- - (list <string>) bond_slaves
- - (string) bootproto
- - (string) bridge_ports
- - (string) chan_mode
-
- (integer) current
the index into #Items.
- - (string) description
- - (string) device
- - (map <string, any>) driver_options
- - (string) ethtool_options
- - (boolean) force_restart
- - (list <map>) Hardware
- - (string) hotplug
- - (string) ifplugd_priority
- - (boolean) ipa_takeover
- - (string) ipaddr
-
- (Object) ipoib_mode
Returns the value of attribute ipoib_mode.
-
- (Object) ipoib_modes
readonly
Returns the value of attribute ipoib_modes.
-
- (Hash<Integer, Hash<String, Object> >, map <integer, any>) Items
Each item, indexed by an Integer in a Hash, aggregates several aspects of a network interface.
- - (string) iucv_user
- - (string) lcs_timeout
- - (boolean) modified
- - (string) mtu
- - (string) netmask
- - (string) nm_name
- - (boolean) nm_proposal_valid
- - (symbol) operation
- - (string) prefix
- - (boolean) proposal_valid
- - (string) qeth_chanids
- - (boolean) qeth_layer2
- - (string) qeth_macaddress
- - (string) qeth_options
- - (string) qeth_portname
- - (string) qeth_portnumber
- - (string) remoteip
- - (list <string>) Requires
- - (boolean) set_default_route
- - (string) startmode
- - (map <string, string>) SysconfigDefaults
- - (string) tunnel_set_group
- - (string) tunnel_set_owner
- - (string) type
- - (map <string, any>) udev_net_rules
- - (string) vlan_etherdevice
- - (string) vlan_id
- - (string) wl_accesspoint
- - (string) wl_ap_scanmode
- - (string) wl_auth_mode
- - (list <string>) wl_auth_modes
- - (string) wl_bitrate
- - (list <string>) wl_bitrates
- - (string) wl_channel
- - (list <string>) wl_channels
- - (integer) wl_default_key
- - (list <string>) wl_enc_modes
- - (string) wl_essid
- - (string) wl_frequency
- - (list <string>) wl_key
- - (string) wl_key_length
- - (string) wl_mode
- - (string) wl_nick
- - (string) wl_nwid
- - (boolean) wl_power
- - (map <string, any>) wl_wpa_eap
- - (string) wl_wpa_psk
Instance Method Summary (collapse)
- - (Object) AddNew
- - (Object) BuildBondIndex
-
- (Object) BuildLanOverview
FIXME: side effect: sets @type.
-
- (Object) Commit
Commit pending operation.
- - (Object) createS390Device
- - (Boolean) current_renamed?
- - (Object) current_renamed_to
-
- (Object) current_udev_name
Returns name which is going to be used in the udev rule.
-
- (Object) delete_dev(name)
Deletes item and its configuration.
-
- (Object) DeleteItem
Deletes the #current item and its configuration.
- - (Object) enableCurrentEditButton
- - (Object) find_configured(device)
- - (Object) FindAndSelect(device)
-
- (Object) FindDeviceIndex(device)
search all known devices to find it's index in Items array.
-
- (Hash) FindMatchingDevice(interface)
Find matching device Find a device, optionally with some predefined values.
-
- (Array) FreeAliases(_type, _num)
Return 10 free aliases.
-
- (Array) FreeDevices(type)
Return 10 free devices.
-
- (Object) GetBondableInterfaces(bondMaster)
Creates list of items (interfaces) which can be used as a bond slave.
-
- (Object) GetBondSlaves(bond_master)
Creates list of devices enslaved in the bond device.
-
- (Object) GetBridgeableInterfaces(bridgeMaster)
Creates list of items (interfaces) which can be used as a bridge slave.
-
- (Object) getCurrentItem
Returns configuration for currently modified item.
- - (Object) GetCurrentMap
-
- (Object) GetCurrentName
Returns device name for current lan item (see LanItems::current).
-
- (Object) GetCurrentType
Returns device type for current lan item (see LanItems::current).
-
- (Object) GetDefaultsForHW
must be in sync with #SetDefaultsForHW.
- - (Object) GetDescr
-
- (Object) GetDeviceMap(itemId)
Returns ifcfg configuration for particular item.
-
- (Object) GetDeviceName(item_id)
Returns device name for given lan item.
-
- (Object) GetDeviceNames(items)
transforms given list of item ids onto device names.
-
- (Object) GetDeviceType(itemId)
Returns device type for particular lan item.
- - (Object) GetFirmwareForCurrentItem
- - (Object) GetItemDescription
-
- (Object) GetItemModules(default_module)
return list of available modules for current device with default default_module (on first possition).
-
- (Object) GetItemUdev(key)
It returns a value for the particular key of udev rule belonging to the current item.
-
- (Object) GetItemUdevRule(itemId)
Returns udev rule known for particular item.
-
- (Object) GetLanItem(itemId)
Returns configuration of item (see LanItems::Items) with given id.
-
- (Boolean) GetModified
Function which returns if the settings were modified.
-
- (Hash) GetModuleForInterface(ay_device, ay_modules)
Get the module configuration for the modules configured in the interface section.
-
- (Object) GetNetcardInterfaces
Creates list of all known netcard items.
-
- (Object) GetNetcardNames
Creates list of names of all known netcards configured even unconfigured.
-
- (Object) getNetworkInterfaces
get list of all configurations for “netcard” macro in NetworkInterfaces module.
-
- (Array) GetSlaveCandidates(master, validator)
Iterates over all items and lists those for which given validator returns true.
- - (Object) getUdevFallback
- - (Boolean) hotplug_usable?
-
- (Boolean) Import(settings)
Imports data from AY profile.
- - (Object) InitS390VarsByDefaults
- - (Object) ip_overview(ip)
-
- (Object) IsBondable(bondMaster, itemId)
Searches map of known devices and decides if referenced lan item can be enslaved in a bond device.
-
- (Object) IsBridgeable(_bridgeMaster, itemId)
Decides if given lan item can be enslaved in a bridge.
-
- (Object) IsCurrentConfigured
Returns true if current (see LanItems::current) has configuration.
-
- (Object) isCurrentDHCP
Check if currently edited device gets its IP address from DHCP (v4, v6 or both).
-
- (Object) isCurrentHotplug
Is current device hotplug or not? I.e.
-
- (Object) IsItemConfigured(itemId)
Returns true if the item (see LanItems::Items) has netconfig configuration.
- - (Object) main
- - (Object) needFirmwareCurrentItem
-
- (Object) new_device_startmode
returns default startmode for a new device.
-
- (Object) new_item_default_options
returns a map with device options for newly created item.
-
- (Object) Overview
Create an overview table with all configured devices.
- - (Object) ProposeItem
-
- (Object) Read
initializates @Items.
-
- (Object) ReadHw
preinitializates @Items according info on physically detected network cards.
- - (Object) ReadUdevDriverRules
-
- (Object?) RemoveItemUdev(key)
It deletes the given key from the udev rule of the current item.
-
- (Object) rename(name)
Sets new device name for current item.
-
- (Boolean) renamed?(item_id)
Tells if current item was renamed.
-
- (Object) renamed_to(item_id)
Returns new name for current item.
- - (Boolean) replace_ifplugd?
-
- (Object) ReplaceItemUdev(replace_key, new_key, new_val)
It replaces a tuple identified by replace_key in current item's udev rule.
-
- (Object) reset_cache
Clears internal cache of the module to default values.
- - (Object) Rollback
-
- (Object) Select(dev)
Select the given device FIXME: currently dev is always “”.
-
- (Object) SelectHW(which)
Select the hardware component.
-
- (Object) SelectHWMap(hardware)
Select the hardware component.
-
- (Object) SetCurrentName(name)
Updates current device name.
-
- (Object) SetDefaultsForHW
must be in sync with #GetDefaultsForHW.
-
- (Object) SetDeviceMap(item_id, devmap)
Sets item's sysconfig device map to given one.
-
- (void) SetDeviceVars(devmap, defaults)
Distributes an ifcfg hash to individual attributes.
- - (Object) setDriver(driver)
- - (Object) SetItem
-
- (Object) SetItemName(itemId, name)
Updates device name.
-
- (Object) SetItemSysconfigOpt(item_id, opt, value)
Sets one option in items sysconfig device map.
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) SetS390Vars(devmap, defaults)
Initializes s390 specific device variables.
-
- (Object) setup_basic_device_options(devmap)
Sets device map items for device when it is not alias.
-
- (Hash) setup_bonding(devmap, slaves, options)
Sets bonding specific sysconfig options in given device map.
-
- (Object) setup_dhclient_options(devmap)
Sets device map items related to dhclient.
-
- (Object) startmode_overview(item_id)
Creates item's startmode human description.
-
- (void) update_item_udev_rule!(based_on = :mac)
Updates the udev rule of the current Lan Item based on the key given which currently could be mac or bus_id.
- - (Object) write
- - (Object) WriteUdevDriverRules
-
- (Object) WriteUdevItemsRules
Writes udev rules for all items.
- - (Object) WriteUdevRules
Instance Attribute Details
- (list <map>) :Hardware(:Hardware)
2641 |
# File '../../src/modules/LanItems.rb', line 2641 publish_variable :Hardware, "list <map>" |
- (Hash<Integer, Hash<String, Object> >, map <integer, any>) :Items(:Items)
Each item, indexed by an Integer in a Hash, aggregates several aspects of a network interface. These aspects are in the inner Hash which mostly has other hashes as values:
-
ifcfg: String, just a foreign key for NetworkInterfaces#Select
-
hwinfo: Hash, detected hardware information
-
udev: Hash, udev naming rules
2639 |
# File '../../src/modules/LanItems.rb', line 2639 publish_variable :Items, "map <integer, any>" |
- (list <string>) :Requires(:Requires)
2656 |
# File '../../src/modules/LanItems.rb', line 2656 publish_variable :Requires, "list <string>" |
- (map <string, string>) :SysconfigDefaults(:SysconfigDefaults)
2709 |
# File '../../src/modules/LanItems.rb', line 2709 publish_variable :SysconfigDefaults, "map <string, string>" |
- (string) alias
2651 |
# File '../../src/modules/LanItems.rb', line 2651 publish_variable :alias, "string" |
- (map) aliases
2702 |
# File '../../src/modules/LanItems.rb', line 2702 publish_variable :aliases, "map" |
- (map) autoinstall_settings
2644 |
# File '../../src/modules/LanItems.rb', line 2644 publish_variable :autoinstall_settings, "map" |
- (string) bond_option
2677 |
# File '../../src/modules/LanItems.rb', line 2677 publish_variable :bond_option, "string" |
- (list <string>) bond_slaves
2676 |
# File '../../src/modules/LanItems.rb', line 2676 publish_variable :bond_slaves, "list <string>" |
- (string) bootproto
2657 |
# File '../../src/modules/LanItems.rb', line 2657 publish_variable :bootproto, "string" |
- (string) bridge_ports
2680 |
# File '../../src/modules/LanItems.rb', line 2680 publish_variable :bridge_ports, "string" |
- (string) chan_mode
2694 |
# File '../../src/modules/LanItems.rb', line 2694 publish_variable :chan_mode, "string" |
- (integer) current
the index into #Items
2653 |
# File '../../src/modules/LanItems.rb', line 2653 publish_variable :current, "integer" |
- (string) description
2648 |
# File '../../src/modules/LanItems.rb', line 2648 publish_variable :description, "string" |
- (string) device
2650 |
# File '../../src/modules/LanItems.rb', line 2650 publish_variable :device, "string" |
- (map <string, any>) driver_options
2643 |
# File '../../src/modules/LanItems.rb', line 2643 publish_variable :driver_options, "map <string, any>" |
- (string) ethtool_options
2666 |
# File '../../src/modules/LanItems.rb', line 2666 publish_variable :ethtool_options, "string" |
- (boolean) force_restart
2647 |
# File '../../src/modules/LanItems.rb', line 2647 publish_variable :force_restart, "boolean" |
- (list <map>) Hardware
2641 |
# File '../../src/modules/LanItems.rb', line 2641 publish_variable :Hardware, "list <map>" |
- (string) hotplug
2654 |
# File '../../src/modules/LanItems.rb', line 2654 publish_variable :hotplug, "string" |
- (string) ifplugd_priority
2664 |
# File '../../src/modules/LanItems.rb', line 2664 publish_variable :ifplugd_priority, "string" |
- (boolean) ipa_takeover
2696 |
# File '../../src/modules/LanItems.rb', line 2696 publish_variable :ipa_takeover, "boolean" |
- (string) ipaddr
2658 |
# File '../../src/modules/LanItems.rb', line 2658 publish_variable :ipaddr, "string" |
- (Object) ipoib_mode
Returns the value of attribute ipoib_mode
45 46 47 |
# File '../../src/modules/LanItems.rb', line 45 def ipoib_mode @ipoib_mode end |
- (Object) ipoib_modes (readonly)
Returns the value of attribute ipoib_modes
44 45 46 |
# File '../../src/modules/LanItems.rb', line 44 def ipoib_modes @ipoib_modes end |
- (Hash<Integer, Hash<String, Object> >, map <integer, any>) Items
Each item, indexed by an Integer in a Hash, aggregates several aspects of a network interface. These aspects are in the inner Hash which mostly has other hashes as values:
-
ifcfg: String, just a foreign key for NetworkInterfaces#Select
-
hwinfo: Hash, detected hardware information
-
udev: Hash, udev naming rules
2639 |
# File '../../src/modules/LanItems.rb', line 2639 publish_variable :Items, "map <integer, any>" |
- (string) iucv_user
2697 |
# File '../../src/modules/LanItems.rb', line 2697 publish_variable :iucv_user, "string" |
- (string) lcs_timeout
2701 |
# File '../../src/modules/LanItems.rb', line 2701 publish_variable :lcs_timeout, "string" |
- (boolean) modified
2645 |
# File '../../src/modules/LanItems.rb', line 2645 publish_variable :modified, "boolean" |
- (string) mtu
2665 |
# File '../../src/modules/LanItems.rb', line 2665 publish_variable :mtu, "string" |
- (string) netmask
2660 |
# File '../../src/modules/LanItems.rb', line 2660 publish_variable :netmask, "string" |
- (string) nm_name
2707 |
# File '../../src/modules/LanItems.rb', line 2707 publish_variable :nm_name, "string" |
- (boolean) nm_proposal_valid
2706 |
# File '../../src/modules/LanItems.rb', line 2706 publish_variable :nm_proposal_valid, "boolean" |
- (symbol) operation
2646 |
# File '../../src/modules/LanItems.rb', line 2646 publish_variable :operation, "symbol" |
- (string) prefix
2662 |
# File '../../src/modules/LanItems.rb', line 2662 publish_variable :prefix, "string" |
- (boolean) proposal_valid
2705 |
# File '../../src/modules/LanItems.rb', line 2705 publish_variable :proposal_valid, "boolean" |
- (string) qeth_chanids
2700 |
# File '../../src/modules/LanItems.rb', line 2700 publish_variable :qeth_chanids, "string" |
- (boolean) qeth_layer2
2698 |
# File '../../src/modules/LanItems.rb', line 2698 publish_variable :qeth_layer2, "boolean" |
- (string) qeth_macaddress
2699 |
# File '../../src/modules/LanItems.rb', line 2699 publish_variable :qeth_macaddress, "string" |
- (string) qeth_options
2695 |
# File '../../src/modules/LanItems.rb', line 2695 publish_variable :qeth_options, "string" |
- (string) qeth_portname
2692 |
# File '../../src/modules/LanItems.rb', line 2692 publish_variable :qeth_portname, "string" |
- (string) qeth_portnumber
2693 |
# File '../../src/modules/LanItems.rb', line 2693 publish_variable :qeth_portnumber, "string" |
- (string) remoteip
2659 |
# File '../../src/modules/LanItems.rb', line 2659 publish_variable :remoteip, "string" |
- (list <string>) Requires
2656 |
# File '../../src/modules/LanItems.rb', line 2656 publish_variable :Requires, "list <string>" |
- (boolean) set_default_route
2661 |
# File '../../src/modules/LanItems.rb', line 2661 publish_variable :set_default_route, "boolean" |
- (string) startmode
2663 |
# File '../../src/modules/LanItems.rb', line 2663 publish_variable :startmode, "string" |
- (map <string, string>) SysconfigDefaults
2709 |
# File '../../src/modules/LanItems.rb', line 2709 publish_variable :SysconfigDefaults, "map <string, string>" |
- (string) tunnel_set_group
2704 |
# File '../../src/modules/LanItems.rb', line 2704 publish_variable :tunnel_set_group, "string" |
- (string) tunnel_set_owner
2703 |
# File '../../src/modules/LanItems.rb', line 2703 publish_variable :tunnel_set_owner, "string" |
- (string) type
2649 |
# File '../../src/modules/LanItems.rb', line 2649 publish_variable :type, "string" |
- (map <string, any>) udev_net_rules
2642 |
# File '../../src/modules/LanItems.rb', line 2642 publish_variable :udev_net_rules, "map <string, any>" |
- (string) vlan_etherdevice
2678 |
# File '../../src/modules/LanItems.rb', line 2678 publish_variable :vlan_etherdevice, "string" |
- (string) vlan_id
2679 |
# File '../../src/modules/LanItems.rb', line 2679 publish_variable :vlan_id, "string" |
- (string) wl_accesspoint
2685 |
# File '../../src/modules/LanItems.rb', line 2685 publish_variable :wl_accesspoint, "string" |
- (string) wl_ap_scanmode
2687 |
# File '../../src/modules/LanItems.rb', line 2687 publish_variable :wl_ap_scanmode, "string" |
- (string) wl_auth_mode
2670 |
# File '../../src/modules/LanItems.rb', line 2670 publish_variable :wl_auth_mode, "string" |
- (list <string>) wl_auth_modes
2688 |
# File '../../src/modules/LanItems.rb', line 2688 publish_variable :wl_auth_modes, "list <string>" |
- (string) wl_bitrate
2684 |
# File '../../src/modules/LanItems.rb', line 2684 publish_variable :wl_bitrate, "string" |
- (list <string>) wl_bitrates
2691 |
# File '../../src/modules/LanItems.rb', line 2691 publish_variable :wl_bitrates, "list <string>" |
- (string) wl_channel
2682 |
# File '../../src/modules/LanItems.rb', line 2682 publish_variable :wl_channel, "string" |
- (list <string>) wl_channels
2690 |
# File '../../src/modules/LanItems.rb', line 2690 publish_variable :wl_channels, "list <string>" |
- (integer) wl_default_key
2674 |
# File '../../src/modules/LanItems.rb', line 2674 publish_variable :wl_default_key, "integer" |
- (list <string>) wl_enc_modes
2689 |
# File '../../src/modules/LanItems.rb', line 2689 publish_variable :wl_enc_modes, "list <string>" |
- (string) wl_essid
2668 |
# File '../../src/modules/LanItems.rb', line 2668 publish_variable :wl_essid, "string" |
- (string) wl_frequency
2683 |
# File '../../src/modules/LanItems.rb', line 2683 publish_variable :wl_frequency, "string" |
- (list <string>) wl_key
2673 |
# File '../../src/modules/LanItems.rb', line 2673 publish_variable :wl_key, "list <string>" |
- (string) wl_key_length
2672 |
# File '../../src/modules/LanItems.rb', line 2672 publish_variable :wl_key_length, "string" |
- (string) wl_mode
2667 |
# File '../../src/modules/LanItems.rb', line 2667 publish_variable :wl_mode, "string" |
- (string) wl_nick
2675 |
# File '../../src/modules/LanItems.rb', line 2675 publish_variable :wl_nick, "string" |
- (string) wl_nwid
2669 |
# File '../../src/modules/LanItems.rb', line 2669 publish_variable :wl_nwid, "string" |
- (boolean) wl_power
2686 |
# File '../../src/modules/LanItems.rb', line 2686 publish_variable :wl_power, "boolean" |
- (map <string, any>) wl_wpa_eap
2681 |
# File '../../src/modules/LanItems.rb', line 2681 publish_variable :wl_wpa_eap, "map <string, any>" |
- (string) wl_wpa_psk
2671 |
# File '../../src/modules/LanItems.rb', line 2671 publish_variable :wl_wpa_psk, "string" |
Instance Method Details
- (Object) AddNew
818 819 820 821 822 823 824 |
# File '../../src/modules/LanItems.rb', line 818 def AddNew @current = @Items.to_h.size @Items[@current] = { "commited" => false } @operation = :add nil end |
- (Object) BuildBondIndex
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 |
# File '../../src/modules/LanItems.rb', line 1318 def BuildBondIndex index = {} bond_devs = Convert.convert( Ops.get(NetworkInterfaces.FilterDevices("netcard"), "bond", {}), from: "map", to: "map <string, map>" ) Builtins.foreach(bond_devs) do |bond_master, _value| Builtins.foreach(GetBondSlaves(bond_master)) do |slave| index = Builtins.add(index, slave, bond_master) end end Builtins.y2debug("bond slaves index: %1", index) deep_copy(index) end |
- (Object) BuildLanOverview
FIXME: side effect: sets @type. No reason for that. It should only build item overview. Check and remove.
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 |
# File '../../src/modules/LanItems.rb', line 1406 def BuildLanOverview overview = [] links = [] LanItems.Items.each_key do |key| rich = "" ip = _("Not configured") item_hwinfo = LanItems.Items[key]["hwinfo"] || {} descr = item_hwinfo["name"] || "" note = "" bullets = [] ifcfg_name = LanItems.Items[key]["ifcfg"] || "" LanItems.type = NetworkInterfaces.GetType(ifcfg_name) if !ifcfg_name.empty? ifcfg_conf = GetDeviceMap(key) ifcfg_desc = ifcfg_conf["NAME"] descr = ifcfg_desc if !ifcfg_desc.nil? && !ifcfg_desc.empty? descr = CheckEmptyName(LanItems.type, descr) ip = DeviceProtocol(ifcfg_conf) status = DeviceStatus( LanItems.type, ifcfg_name, ifcfg_conf ) bullets << _("Device Name: %s") % ifcfg_name bullets += startmode_overview(key) bullets += ip_overview(ip) if ifcfg_conf["STARTMODE"] != "managed" if LanItems.type == "wlan" && ifcfg_conf["WIRELESS_AUTH_MODE"] == "open" && IsEmpty(ifcfg_conf["WIRELESS_KEY_0"]) # avoid colons ifcfg_name = ifcfg_name.tr(":", "/") href = "lan--wifi-encryption-" + ifcfg_name # interface summary: WiFi without encryption warning = HTML.Colorize(_("Warning: no encryption is used."), "red") # Hyperlink: Change the configuration of an interface status << " " << warning << " " << Hyperlink(href, _("Change.")) links << href end if LanItems.type == "bond" bond_slaves_desc = format( "%s: %s", _("Bonding slaves"), GetBondSlaves(ifcfg_name).join(" ") ) bullets << bond_slaves_desc end bond_index = BuildBondIndex() bond_master = Ops.get( bond_index, ifcfg_name, "" ) if !bond_master.empty? note = format(_("enslaved in %s"), bond_master) bond_master_desc = format("%s: %s", _("Bonding master"), bond_master) bullets << bond_master_desc end if renamed?(key) note = format("%s -> %s", GetDeviceName(key), renamed_to(key)) end overview << Summary.Device(descr, status) else descr = CheckEmptyName(LanItems.type, descr) overview << Summary.Device(descr, Summary.NotConfigured) end conn = "" conn = HTML.Bold(format("(%s)", _("Not connected"))) if !item_hwinfo["link"] conn = HTML.Bold(format("(%s)", _("No hwinfo"))) if item_hwinfo.empty? mac_dev = HTML.Bold("MAC : ") + item_hwinfo["mac"].to_s + "<br>" bus_id = HTML.Bold("BusID : ") + item_hwinfo["busid"].to_s + "<br>" rich << " " << conn << "<br>" << mac_dev if IsNotEmpty(item_hwinfo["mac"]) rich << bus_id if IsNotEmpty(item_hwinfo["busid"]) # display it only if we need it, don't duplicate "ifcfg_name" above if IsNotEmpty(item_hwinfo["dev_name"]) && ifcfg_name.empty? dev_name = _("Device Name: %s") % item_hwinfo["dev_name"] rich << HTML.Bold(dev_name) << "<br>" end rich = HTML.Bold(descr) + rich if IsEmpty(item_hwinfo["dev_name"]) && !item_hwinfo.empty? && !Arch.s390 rich << "<p>" rich << _("Unable to configure the network card because the kernel device (eth0, wlan0) is not present. This is mostly caused by missing firmware (for wlan devices). See dmesg output for details.") rich << "</p>" elsif !ifcfg_name.empty? rich << HTML.List(bullets) else rich << "<p>" rich << _("The device is not configured. Press <b>Edit</b>\nto configure.\n") rich << "</p>" curr = @current @current = key if needFirmwareCurrentItem fw = GetFirmwareForCurrentItem() rich << format("%s : %s", _("Needed firmware"), !fw.empty? ? fw : _("unknown")) end @current = curr end LanItems.Items[key]["table_descr"] = { "rich_descr" => rich, "table_descr" => [descr, ip, ifcfg_name, note] } end [Summary.DevicesList(overview), links] end |
- (Object) Commit
Commit pending operation
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 |
# File '../../src/modules/LanItems.rb', line 1989 def Commit if @operation != :add && @operation != :edit log.error("Unknown operation: #{@operation}") raise ArgumentError, "Unknown operation: #{@operation}" end newdev = {} # #104494 - always write IPADDR+NETMASK, even empty newdev["IPADDR"] = @ipaddr if !@prefix.empty? newdev["PREFIXLEN"] = @prefix else newdev["NETMASK"] = @netmask end # #50955 omit computable fields newdev["BROADCAST"] = "" newdev["NETWORK"] = "" newdev["REMOTE_IPADDR"] = @remoteip # set LLADDR to sysconfig only for device on layer2 and only these which needs it # do not write incorrect LLADDR. if @qeth_layer2 && s390_correct_lladdr(@qeth_macaddress) busid = Ops.get_string(@Items, [@current, "hwinfo", "busid"], "") # sysfs id has changed from css0... sysfs_id = "/devices/qeth/#{busid}" log.info("busid #{busid}") if s390_device_needs_persistent_mac(sysfs_id, @Hardware) newdev["LLADDR"] = @qeth_macaddress end end newdev["NAME"] = @description newdev = (newdev) newdev = (newdev) case @type when "bond" # we need current slaves - when some of them is not used anymore we need to # configure it for deletion from ifcfg (SCR expects special value nil) current_slaves = (GetCurrentMap() || {}).select { |k, _| k.start_with?("BONDING_SLAVE") } newdev = setup_bonding(newdev.merge(current_slaves), @bond_slaves, @bond_option) when "vlan" newdev["ETHERDEVICE"] = @vlan_etherdevice newdev["VLAN_ID"] = @vlan_id when "br" newdev["BRIDGE_PORTS"] = @bridge_ports newdev["BRIDGE"] = "yes" newdev["BRIDGE_STP"] = "off" newdev["BRIDGE_FORWARDDELAY"] = "0" when "wlan" newdev["WIRELESS_MODE"] = @wl_mode newdev["WIRELESS_ESSID"] = @wl_essid newdev["WIRELESS_NWID"] = @wl_nwid newdev["WIRELESS_AUTH_MODE"] = @wl_auth_mode newdev["WIRELESS_WPA_PSK"] = @wl_wpa_psk newdev["WIRELESS_KEY_LENGTH"] = @wl_key_length # obsoleted by WIRELESS_KEY_0 newdev["WIRELESS_KEY"] = "" # TODO: delete the varlable newdev["WIRELESS_KEY_0"] = Ops.get(@wl_key, 0, "") newdev["WIRELESS_KEY_1"] = Ops.get(@wl_key, 1, "") newdev["WIRELESS_KEY_2"] = Ops.get(@wl_key, 2, "") newdev["WIRELESS_KEY_3"] = Ops.get(@wl_key, 3, "") Ops.set( newdev, "WIRELESS_DEFAULT_KEY", Builtins.tostring(@wl_default_key) ) Ops.set(newdev, "WIRELESS_NICK", @wl_nick) Ops.set(newdev, "WIRELESS_AP_SCANMODE", @wl_ap_scanmode) if @wl_wpa_eap != {} Ops.set( newdev, "WIRELESS_EAP_MODE", Ops.get_string(@wl_wpa_eap, "WPA_EAP_MODE", "") ) Ops.set( newdev, "WIRELESS_WPA_IDENTITY", Ops.get_string(@wl_wpa_eap, "WPA_EAP_IDENTITY", "") ) Ops.set( newdev, "WIRELESS_WPA_PASSWORD", Ops.get_string(@wl_wpa_eap, "WPA_EAP_PASSWORD", "") ) Ops.set( newdev, "WIRELESS_WPA_ANONID", Ops.get_string(@wl_wpa_eap, "WPA_EAP_ANONID", "") ) Ops.set( newdev, "WIRELESS_CLIENT_CERT", Ops.get_string(@wl_wpa_eap, "WPA_EAP_CLIENT_CERT", "") ) Ops.set( newdev, "WIRELESS_CLIENT_KEY", Ops.get_string(@wl_wpa_eap, "WPA_EAP_CLIENT_KEY", "") ) Ops.set( newdev, "WIRELESS_CLIENT_KEY_PASSWORD", Ops.get_string(@wl_wpa_eap, "WPA_EAP_CLIENT_KEY_PASSWORD", "") ) Ops.set( newdev, "WIRELESS_CA_CERT", Ops.get_string(@wl_wpa_eap, "WPA_EAP_CA_CERT", "") ) Ops.set( newdev, "WIRELESS_EAP_AUTH", Ops.get_string(@wl_wpa_eap, "WPA_EAP_AUTH", "") ) Ops.set( newdev, "WIRELESS_PEAP_VERSION", Ops.get_string(@wl_wpa_eap, "WPA_EAP_PEAP_VERSION", "") ) end newdev["WIRELESS_CHANNEL"] = @wl_channel newdev["WIRELESS_FREQUENCY"] = @wl_frequency newdev["WIRELESS_BITRATE"] = @wl_bitrate newdev["WIRELESS_AP"] = @wl_accesspoint newdev["WIRELESS_POWER"] = @wl_power ? "yes" : "no" when "ib" newdev["IPOIB_MODE"] = @ipoib_mode end if DriverType(@type) == "ctc" if Ops.get(NetworkConfig.Config, "WAIT_FOR_INTERFACES").nil? || Ops.less_than( Ops.get_integer(NetworkConfig.Config, "WAIT_FOR_INTERFACES", 0), 40 ) Ops.set(NetworkConfig.Config, "WAIT_FOR_INTERFACES", 40) end end if ["tun", "tap"].include?(@type) newdev = { "BOOTPROTO" => "static", "STARTMODE" => "auto", "TUNNEL" => @type, "TUNNEL_SET_OWNER" => @tunnel_set_owner, "TUNNEL_SET_GROUP" => @tunnel_set_group } end # L3: bnc#585458 # FIXME: INTERFACETYPE confuses sysconfig, bnc#458412 # Only test when newdev has enough info for GetTypeFromIfcfg to work. implied_type = NetworkInterfaces.GetTypeFromIfcfg(newdev) if !implied_type.nil? && implied_type != @type newdev["INTERFACETYPE"] = @type end NetworkInterfaces.Name = Ops.get_string(@Items, [@current, "ifcfg"], "") NetworkInterfaces.Current = deep_copy(newdev) # bnc#752464 - can leak wireless passwords # useful only for debugging. Writes huge struct mostly filled by defaults. Builtins.y2debug("%1", NetworkInterfaces.ConcealSecrets1(newdev)) Ops.set(@Items, [@current, "ifcfg"], "") if !NetworkInterfaces.Commit # configure bridge ports if @bridge_ports @bridge_ports.split.each { |bp| configure_as_bridge_port(bp) } end @modified = true @operation = nil true end |
- (Object) createS390Device
2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 |
# File '../../src/modules/LanItems.rb', line 2480 def createS390Device Builtins.y2milestone("creating device s390 network device") result = true # command to create device command1 = "" # command to find created device command2 = "" case @type when "hsi", "qeth" @portnumber_param = if Ops.greater_than(Builtins.size(@qeth_portnumber), 0) Builtins.sformat("-n %1", @qeth_portnumber) else "" end @portname_param = if Ops.greater_than(Builtins.size(@qeth_portname), 0) Builtins.sformat("-p %1", @qeth_portname) else "" end @options_param = if Ops.greater_than(Builtins.size(@qeth_options), 0) Builtins.sformat("-o %1", @qeth_options) else "" end command1 = Builtins.sformat( "qeth_configure %1 %2 %3 %4 %5 1", @options_param, @qeth_layer2 ? "-l" : "", @portname_param, @portnumber_param, @qeth_chanids ) command2 = Builtins.sformat( "ls /sys/devices/qeth/%1/net/|head -n1|tr -d '\n'", Ops.get(Builtins.splitstring(@qeth_chanids, " "), 0, "") ) when "ctc" # chan_ids (read, write), protocol command1 = Builtins.sformat( "ctc_configure %1 1 %2", @qeth_chanids, @chan_mode ) command2 = Builtins.sformat( "ls /sys/devices/ctcm/%1/net/|head -n1|tr -d '\n'", Ops.get(Builtins.splitstring(@qeth_chanids, " "), 0, "") ) when "lcs" # chan_ids (read, write), protocol command1 = Builtins.sformat( "ctc_configure %1 1 %2", @qeth_chanids, @chan_mode ) command2 = Builtins.sformat( "ls /sys/devices/lcs/%1/net/|head -n1|tr -d '\n'", Ops.get(Builtins.splitstring(@qeth_chanids, " "), 0, "") ) when "iucv" # router command1 = Builtins.sformat("iucv_configure %1 1", @iucv_user) command2 = Builtins.sformat( "ls /sys/devices/%1/*/net/|head -n1|tr -d '\n'", @type ) else Builtins.y2error("Unsupported type : %1", @type) end Builtins.y2milestone("execute %1", command1) output1 = Convert.convert( SCR.Execute(path(".target.bash_output"), command1), from: "any", to: "map <string, any>" ) if Ops.get_integer(output1, "exit", -1) == 0 && Builtins.size(Ops.get_string(output1, "stderr", "")) == 0 Builtins.y2milestone("Success : %1", output1) else Builtins.y2error("Problem occured : %1", output1) result = false end Builtins.y2milestone("output1 %1", output1) if result Builtins.y2milestone("command2 %1", command2) output2 = Convert.convert( SCR.Execute(path(".target.bash_output"), command2), from: "any", to: "map <string, any>" ) Builtins.y2milestone("output2 %1", output2) if Ops.get_integer(output2, "exit", -1) == 0 && Builtins.size(Ops.get_string(output2, "stderr", "")) == 0 Ops.set( @Items, [@current, "ifcfg"], Ops.get_string(output2, "stdout", "") ) Ops.set( @Items, [@current, "hwinfo", "dev_name"], Ops.get_string(output2, "stdout", "") ) Builtins.y2milestone( "Device %1 created", Ops.get_string(output2, "stdout", "") ) else Builtins.y2error("Some problem occured : %1", output2) result = false end end result end |
- (Boolean) current_renamed?
668 669 670 |
# File '../../src/modules/LanItems.rb', line 668 def current_renamed? renamed?(@current) end |
- (Object) current_renamed_to
656 657 658 |
# File '../../src/modules/LanItems.rb', line 656 def current_renamed_to renamed_to(@current) end |
- (Object) current_udev_name
Returns name which is going to be used in the udev rule
351 352 353 354 355 356 357 |
# File '../../src/modules/LanItems.rb', line 351 def current_udev_name if LanItems.current_renamed? LanItems.current_renamed_to else LanItems.GetItemUdev("NAME") end end |
- (Object) delete_dev(name)
Deletes item and its configuration
Item for deletion is searched using device name
2356 2357 2358 2359 |
# File '../../src/modules/LanItems.rb', line 2356 def delete_dev(name) FindAndSelect(name) DeleteItem() end |
- (Object) DeleteItem
Deletes the #current item and its configuration
2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 |
# File '../../src/modules/LanItems.rb', line 2362 def DeleteItem return if @current < 0 return if @Items.nil? || @Items.empty? log.info("DeleteItem: #{@Items[@current]}") devmap = GetCurrentMap() drop_hosts(devmap["IPADDR"]) if devmap SetCurrentName("") current_item = @Items[@current] if current_item["hwinfo"].nil? || current_item["hwinfo"].empty? # size is always > 0 here and items are numbered 0, 1, ..., size -1 delete_index = @Items.size - 1 @Items[@current] = @Items[delete_index] if delete_index != @current @Items.delete(delete_index) # item was deleted, so original @current is invalid @current = -1 end SetModified() nil end |
- (Object) enableCurrentEditButton
2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 |
# File '../../src/modules/LanItems.rb', line 2466 def enableCurrentEditButton return true if needFirmwareCurrentItem return true if Arch.s390 if IsEmpty(Ops.get_string(getCurrentItem, ["hwinfo", "dev_name"], "")) && Ops.greater_than( Builtins.size(Ops.get_map(getCurrentItem, "hwinfo", {})), 0 ) return false else return true end end |
- (Object) find_configured(device)
1018 1019 1020 |
# File '../../src/modules/LanItems.rb', line 1018 def find_configured(device) @Items.select { |_k, v| v["ifcfg"] == device }.keys.first end |
- (Object) FindAndSelect(device)
1022 1023 1024 1025 1026 1027 |
# File '../../src/modules/LanItems.rb', line 1022 def FindAndSelect(device) item_id = find_configured(device) @current = item_id if item_id !item_id.nil? end |
- (Object) FindDeviceIndex(device)
search all known devices to find it's index in Items array
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
# File '../../src/modules/LanItems.rb', line 1033 def FindDeviceIndex(device) ret = -1 Builtins.foreach( Convert.convert( @Items, from: "map <integer, any>", to: "map <integer, map <string, any>>" ) ) do |i, a| if Ops.get_string(a, ["hwinfo", "dev_name"], "") == device ret = i raise Break end end ret end |
- (Hash) FindMatchingDevice(interface)
Find matching device Find a device, optionally with some predefined values
2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 |
# File '../../src/modules/LanItems.rb', line 2225 def FindMatchingDevice(interface) interface = deep_copy(interface) tosel = nil # Minimal changes to code to fix both #119592 and #146965 # Alternatively we could try to ensure that we never match a # device that got already matched matched_by_module = false devs = NetworkInterfaces.List("netcard") Builtins.y2milestone("Configured devices: %1", devs) # this condition is always true for SLES9, HEAD uses $[] for proposal if interface != {} # Notes for comments about matching: # - interface["device"] is the key which we look for in the actual hw # - H iterates over Hardware # - patterns are shell-like device_id = Builtins.splitstring( Ops.get_string(interface, "device", ""), "-" ) # code for eth-id-00:80:c8:f6:48:4c configurations # *-id-$ID => find H["mac"] == $ID if Ops.greater_than(Builtins.size(device_id), 1) && Ops.get_string(device_id, 1, "") == "id" hwaddr = Ops.get_string(device_id, 2, "") tosel = Builtins.find(@Hardware) do |h| Ops.get_string(h, "mac", "") == hwaddr end if !hwaddr.nil? && hwaddr != "" Builtins.y2milestone("Rule: matching mac in device name") # code for eth-bus-pci-0000:00:0d.0 configurations # code for eth-bus-vio-30000001 configurations # *-bus-$BUS-$ID => find H["bus"] == $BUS & H["busid"] == $ID elsif Ops.greater_than(Builtins.size(device_id), 2) && Ops.get_string(device_id, 1, "") == "bus" bus = Ops.get_string(device_id, 2, "") busid = Ops.get_string(device_id, 3, "") if !bus.nil? && bus != "" && !busid.nil? && busid != "" tosel = Builtins.find(@Hardware) do |h| Ops.get_string(h, "busid", "") == busid && Ops.get_string(h, "bus", "") == bus end end Builtins.y2milestone("Rule: matching bus id in device name") end # code for module configuration # join with the modules list of the ay profile according to "device" # if exists => find H["module"] == AH["module"] aymodule = GetModuleForInterface( Ops.get_string(interface, "device", ""), Ops.get_list(@autoinstall_settings, "modules", []) ) Builtins.y2milestone("module data: %1", aymodule) if tosel.nil? && aymodule != {} if !aymodule.nil? && Ops.get_string(aymodule, "module", "") != "" tosel = Builtins.find(@Hardware) do |h| Ops.get_string(h, "module", "") == Ops.get_string(aymodule, "module", "") end end matched_by_module = true if !tosel.nil? Builtins.y2milestone("Rule: matching module configuration") end end # First device was already configured, we are now looking for # a second (third,...) one if Ops.greater_than(Builtins.size(devs), 0) # #119592, #146965: this used to be unconditional, overwriting the # results of the above matching. if matched_by_module || tosel.nil? # go thru all devices, check whether there's one that does # not have a configuration yet # and has the same type as the current profile item Builtins.foreach(@Hardware) do |h| Builtins.y2milestone("Checking for device=%1", h) SelectHWMap(h) # string _device_name = NetworkInterfaces::device_name(NetworkInterfaces::RealType(type, hotplug), device); if !NetworkInterfaces.Check(@device) && @type == NetworkInterfaces.GetType( Ops.get_string(interface, "device", "") ) Builtins.y2milestone("Selected: %1", h) tosel = deep_copy(h) raise Break end end end Builtins.y2error("Nothing found") if tosel.nil? else # this is the first interface, match the hardware with install.inf # No install.inf -> select the first connected # find H["active"] == true if tosel.nil? tosel = Builtins.find(@Hardware) do |h| Ops.get_boolean(h, ["link", "state"], false) end Builtins.y2milestone("Rule: first connected") end # No install.inf driver -> select the first active # find H["active"] == true if tosel.nil? tosel = Builtins.find(@Hardware) do |h| Ops.get_boolean(h, "active", false) end Builtins.y2milestone("Rule: first active") end # No active driver -> select the first with a driver # find H["module"] != "" if tosel.nil? Builtins.y2milestone("No active driver found, trying further.") tosel = Builtins.find(@Hardware) do |h| Ops.get_string(h, "module", "") != "" && Builtins.y2milestone("Using driver: %1", h).nil? end Builtins.y2milestone("Rule: first with driver") end end deep_copy(tosel) end |
- (Array) FreeAliases(_type, _num)
Return 10 free aliases
1688 1689 1690 |
# File '../../src/modules/LanItems.rb', line 1688 def FreeAliases(_type, _num) NetworkInterfaces.GetFreeDevices("_aliases", 10) end |
- (Array) FreeDevices(type)
Return 10 free devices
1680 1681 1682 |
# File '../../src/modules/LanItems.rb', line 1680 def FreeDevices(type) NetworkInterfaces.GetFreeDevices(type, 10) end |
- (Object) GetBondableInterfaces(bondMaster)
Creates list of items (interfaces) which can be used as a bond slave.
976 977 978 979 980 981 |
# File '../../src/modules/LanItems.rb', line 976 def GetBondableInterfaces(bondMaster) GetSlaveCandidates( bondMaster, fun_ref(method(:IsBondable), "boolean (string, integer)") ) end |
- (Object) GetBondSlaves(bond_master)
Creates list of devices enslaved in the bond device.
1308 1309 1310 1311 1312 1313 1314 1315 1316 |
# File '../../src/modules/LanItems.rb', line 1308 def GetBondSlaves(bond_master) net_cards = NetworkInterfaces.FilterDevices("netcard") || { "bond" => {} } bonds = net_cards["bond"] || {} bond_map = bonds[bond_master] || {} slaves = bond_map.select { |k, _| k.start_with?("BONDING_SLAVE") }.values deep_copy(slaves) end |
- (Object) GetBridgeableInterfaces(bridgeMaster)
Creates list of items (interfaces) which can be used as a bridge slave.
987 988 989 990 991 992 |
# File '../../src/modules/LanItems.rb', line 987 def GetBridgeableInterfaces(bridgeMaster) GetSlaveCandidates( bridgeMaster, fun_ref(method(:IsBridgeable), "boolean (string, integer)") ) end |
- (Object) getCurrentItem
Returns configuration for currently modified item.
313 314 315 |
# File '../../src/modules/LanItems.rb', line 313 def getCurrentItem GetLanItem(@current) end |
- (Object) GetCurrentMap
401 402 403 |
# File '../../src/modules/LanItems.rb', line 401 def GetCurrentMap GetDeviceMap(@current) end |
- (Object) GetCurrentName
Returns device name for current lan item (see LanItems::current)
369 370 371 |
# File '../../src/modules/LanItems.rb', line 369 def GetCurrentName GetDeviceName(@current) end |
- (Object) GetCurrentType
Returns device type for current lan item (see LanItems::current)
381 382 383 |
# File '../../src/modules/LanItems.rb', line 381 def GetCurrentType GetDeviceType(@current) end |
- (Object) GetDefaultsForHW
must be in sync with #SetDefaultsForHW
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 |
# File '../../src/modules/LanItems.rb', line 1693 def GetDefaultsForHW ret = {} # LCS eth interfaces on s390 need the MTU of 1492. #81815. # TODO: lcs, or eth? # will eth not get mapped to lcs? # Apparently both LCS eth and LCS tr are represented as "lcs" # but it does not hurt to change the default also for tr # #93798: limit to s390 to minimize regressions. Probably it could # be also done by only testing for lcs and not eth but that # would need more testing. if Arch.s390 && Builtins.contains(["lcs", "eth"], @type) Builtins.y2milestone("Adding LCS: setting MTU") ret = Builtins.add(ret, "MTU", "1492") end deep_copy(ret) end |
- (Object) GetDescr
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 |
# File '../../src/modules/LanItems.rb', line 1206 def GetDescr descr = [] Builtins.foreach( Convert.convert( @Items, from: "map <integer, any>", to: "map <integer, map <string, any>>" ) ) do |key, value| if Builtins.haskey(value, "table_descr") && Ops.greater_than( Builtins.size(Ops.get_map(@Items, [key, "table_descr"], {})), 1 ) descr = Builtins.add( descr, "id" => key, "rich_descr" => Ops.get_string( @Items, [key, "table_descr", "rich_descr"], "" ), "table_descr" => Ops.get_list( @Items, [key, "table_descr", "table_descr"], [] ) ) end end deep_copy(descr) end |
- (Object) GetDeviceMap(itemId)
Returns ifcfg configuration for particular item
388 389 390 391 392 393 394 395 396 397 398 399 |
# File '../../src/modules/LanItems.rb', line 388 def GetDeviceMap(itemId) return nil if !IsItemConfigured(itemId) devname = GetDeviceName(itemId) devtype = NetworkInterfaces.GetType(devname) Convert.convert( Ops.get(NetworkInterfaces.FilterDevices("netcard"), [devtype, devname]), from: "any", to: "map <string, any>" ) end |
- (Object) GetDeviceName(item_id)
Returns device name for given lan item.
First it looks into the item's netconfig and if it doesn't exist it uses device name from hwinfo if available.
340 341 342 343 344 345 346 347 348 |
# File '../../src/modules/LanItems.rb', line 340 def GetDeviceName(item_id) lan_item = GetLanItem(item_id) return lan_item["ifcfg"] if lan_item["ifcfg"] return lan_item["hwinfo"]["dev_name"] || "" if lan_item["hwinfo"] log.error("Item #{item_id} has no dev_name nor configuration associated") "" # this should never happen end |
- (Object) GetDeviceNames(items)
transforms given list of item ids onto device names
item id is index into internal @Items structure
362 363 364 365 366 |
# File '../../src/modules/LanItems.rb', line 362 def GetDeviceNames(items) return [] unless items items.map { |itemId| GetDeviceName(itemId) }.reject(&:empty?) end |
- (Object) GetDeviceType(itemId)
Returns device type for particular lan item
376 377 378 |
# File '../../src/modules/LanItems.rb', line 376 def GetDeviceType(itemId) NetworkInterfaces.GetType(GetDeviceName(itemId)) end |
- (Object) GetFirmwareForCurrentItem
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 |
# File '../../src/modules/LanItems.rb', line 1268 def GetFirmwareForCurrentItem kernel_module = "" if IsNotEmpty(Ops.get_string(@Items, [@current, "hwinfo", "driver"], "")) if Builtins.haskey( @request_firmware, Ops.get_string(@Items, [@current, "hwinfo", "driver"], "") ) kernel_module = Ops.get_string( @Items, [@current, "hwinfo", "driver"], "" ) end else Builtins.foreach( Ops.get_list(@Items, [@current, "hwinfo", "drivers"], []) ) do |driver| if Builtins.haskey( @request_firmware, Ops.get_string(driver, ["modules", 0, 0], "") ) kernel_module = Ops.get_string(driver, ["modules", 0, 0], "") raise Break end end end firmware = Ops.get(@request_firmware, kernel_module, "") Builtins.y2milestone( "driver %1 needs firmware %2", kernel_module, firmware ) firmware end |
- (Object) GetItemDescription
1549 1550 1551 |
# File '../../src/modules/LanItems.rb', line 1549 def GetItemDescription Ops.get_string(@Items, [@current, "table_descr", "rich_descr"], "") end |
- (Object) GetItemModules(default_module)
return list of available modules for current device with default default_module (on first possition)
829 830 831 832 833 834 835 836 837 838 839 |
# File '../../src/modules/LanItems.rb', line 829 def GetItemModules(default_module) mods = [] mods = Builtins.add(mods, default_module) if IsNotEmpty(default_module) Builtins.foreach( Ops.get_list(@Items, [@current, "hwinfo", "drivers"], []) ) do |row| tmp_mod = Ops.get_string(row, ["modules", 0, 0], "") mods = Builtins.add(mods, tmp_mod) if !Builtins.contains(mods, tmp_mod) end deep_copy(mods) end |
- (Object) GetItemUdev(key)
It returns a value for the particular key of udev rule belonging to the current item.
498 499 500 |
# File '../../src/modules/LanItems.rb', line 498 def GetItemUdev(key) udev_key_value(getUdevFallback, key) end |
- (Object) GetItemUdevRule(itemId)
Returns udev rule known for particular item
434 435 436 |
# File '../../src/modules/LanItems.rb', line 434 def GetItemUdevRule(itemId) Ops.get_list(GetLanItem(itemId), ["udev", "net"], []) end |
- (Object) GetLanItem(itemId)
Returns configuration of item (see LanItems::Items) with given id.
308 309 310 |
# File '../../src/modules/LanItems.rb', line 308 def GetLanItem(itemId) Ops.get_map(@Items, itemId, {}) end |
- (Boolean) GetModified
Function which returns if the settings were modified
807 808 809 |
# File '../../src/modules/LanItems.rb', line 807 def GetModified @modified end |
- (Hash) GetModuleForInterface(ay_device, ay_modules)
Get the module configuration for the modules configured in the interface section
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 |
# File '../../src/modules/LanItems.rb', line 2207 def GetModuleForInterface(ay_device, ay_modules) ay_modules = deep_copy(ay_modules) ayret = {} ay_filtered = Builtins.filter(ay_modules) do |ay_m| Ops.get_string(ay_m, "device", "") == ay_device end if Ops.greater_than(Builtins.size(ay_filtered), 0) ayret = Ops.get(ay_filtered, 0, {}) end deep_copy(ayret) end |
- (Object) GetNetcardInterfaces
Creates list of all known netcard items
It means list of item ids of all netcards which are detected and/or configured in the system
998 999 1000 |
# File '../../src/modules/LanItems.rb', line 998 def GetNetcardInterfaces @Items.keys end |
- (Object) GetNetcardNames
Creates list of names of all known netcards configured even unconfigured
1003 1004 1005 |
# File '../../src/modules/LanItems.rb', line 1003 def GetNetcardNames GetDeviceNames(GetNetcardInterfaces()) end |
- (Object) getNetworkInterfaces
get list of all configurations for “netcard” macro in NetworkInterfaces module
1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# File '../../src/modules/LanItems.rb', line 1008 def getNetworkInterfaces configurations = NetworkInterfaces.FilterDevices("netcard") devtypes = NetworkInterfaces.CardRegex["netcard"].to_s.split("|") devtypes.inject([]) do |acc, type| conf = configurations[type].to_h acc.concat(conf.keys) end end |
- (Array) GetSlaveCandidates(master, validator)
Iterates over all items and lists those for which given validator returns true.
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
# File '../../src/modules/LanItems.rb', line 939 def GetSlaveCandidates(master, validator) validator = deep_copy(validator) if validator.nil? Builtins.y2error("GetSlaveCandidates: needs a validator.") return [] end if IsEmpty(master) Builtins.y2error("GetSlaveCandidates: master device name is required.") return [] end result = [] Builtins.foreach(@Items) do |itemId, _attribs| if @current != itemId && validator.call(master, itemId) result = Builtins.add(result, itemId) else Builtins.y2debug( "GetSlaveCandidates: validation failed for item (%1), current (%2)", itemId, @current ) end end Builtins.y2milestone( "GetSlaveCandidates: candidates for enslaving: %1", result ) deep_copy(result) end |
- (Object) getUdevFallback
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File '../../src/modules/LanItems.rb', line 480 def getUdevFallback udev_rules = Ops.get_list(getCurrentItem, ["udev", "net"], []) if IsEmpty(udev_rules) udev_rules = GetDefaultUdevRule( GetCurrentName(), Ops.get_string(getCurrentItem, ["hwinfo", "mac"], "") ) Builtins.y2milestone( "No Udev rules found, creating default: %1", udev_rules ) end deep_copy(udev_rules) end |
- (Boolean) hotplug_usable?
1843 1844 1845 |
# File '../../src/modules/LanItems.rb', line 1843 def hotplug_usable? true unless Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "").empty? end |
- (Boolean) Import(settings)
Imports data from AY profile
As network related configuration is spread over the whole AY profile's networking section the function requires hash map with whole AY profile hash representation as returned by LanAutoClient#FromAY profile.
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 |
# File '../../src/modules/LanItems.rb', line 1187 def Import(settings) reset_cache NetworkInterfaces.Import("netcard", settings["devices"] || {}) NetworkInterfaces.List("netcard").each do |device| AddNew() LanItems.Items[current] = { "ifcfg" => device } end autoinstall_settings["start_immediately"] = settings.fetch("start_immediately", false) autoinstall_settings["strict_IP_check_timeout"] = settings.fetch("strict_IP_check_timeout", -1) autoinstall_settings["keep_install_network"] = settings.fetch("keep_install_network", false) # settings == {} has special meaning 'Reset' used by AY SetModified() if !settings.empty? true end |
- (Object) InitS390VarsByDefaults
1837 1838 1839 1840 1841 |
# File '../../src/modules/LanItems.rb', line 1837 def InitS390VarsByDefaults SetS390Vars({}, @s390_defaults) nil end |
- (Object) ip_overview(ip)
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
# File '../../src/modules/LanItems.rb', line 1374 def ip_overview(ip) bullets = [] case ip when "NONE", "" # do nothing when /DHCP/ bullets << format("%s %s", _("IP address assigned using"), ip) else prefixlen = NetworkInterfaces.Current["PREFIXLEN"] if prefixlen bullets << format(_("IP address: %s/%s"), ip, prefixlen) else subnetmask = NetworkInterfaces.Current["NETMASK"] bullets << format(_("IP address: %s, subnet mask %s"), ip, subnetmask) end end # build aliases overview item_aliases = NetworkInterfaces.Current["_aliases"] || {} if !item_aliases.empty? && !NetworkService.is_network_manager item_aliases.each do |_key2, desc| parameters = format("%s/%s", desc["IPADDR"], desc["PREFIXLEN"]) bullets << format("%s (%s)", desc["LABEL"], parameters) end end bullets end |
- (Object) IsBondable(bondMaster, itemId)
Searches map of known devices and decides if referenced lan item can be enslaved in a bond device
TODO: Check for valid configurations. E.g. bond device over vlan is nonsense and is not supported by netconfig. Also devices enslaved in a bridge should be excluded too.
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
# File '../../src/modules/LanItems.rb', line 849 def IsBondable(bondMaster, itemId) ret = true devname = GetDeviceName(itemId) bonded = BuildBondIndex() # check if the device is L2 capable if Arch.s390 s390_config = s390_ReadQethConfig(devname) # only devices with L2 support can be enslaved in bond. See bnc#719881 ret &&= Ops.get_string(s390_config, "QETH_LAYER2", "no") == "yes" end ifcfg = GetDeviceMap(itemId) itemBondMaster = Ops.get(bonded, devname, "") if IsNotEmpty(itemBondMaster) && bondMaster != itemBondMaster Builtins.y2debug( "IsBondable: excluding lan item (%1: %2) for %3 - is already bonded", itemId, devname, GetDeviceName(@current) ) return false end return ret if ifcfg.nil? # filter the eth devices (BOOTPROTO=none) # don't care about STARTMODE (see bnc#652987c6) ret &&= Ops.get_string(ifcfg, "BOOTPROTO", "") == "none" ret end |
- (Object) IsBridgeable(_bridgeMaster, itemId)
Decides if given lan item can be enslaved in a bridge.
TODO: bridgeMaster is not used yet bcs detection of bridge master for checked device is missing.
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
# File '../../src/modules/LanItems.rb', line 891 def IsBridgeable(_bridgeMaster, itemId) ifcfg = GetDeviceMap(itemId) # no netconfig configuration has been found so nothing # blocks using the device as bridge slave return true if ifcfg.nil? devname = GetDeviceName(itemId) bonded = BuildBondIndex() if bonded[devname] log.debug("Excluding lan item (#{itemId}: #{devname}) - is bonded") return false end devtype = GetDeviceType(itemId) # exclude forbidden configurations case devtype when "br" log.debug("Excluding lan item (#{itemId}: #{devname}) - is bridge") return false when "tun" log.debug("Excluding lan item (#{itemId}: #{devname}) - is tun") return false end case ifcfg["STARTMODE"] when "nfsroot" log.debug("Excluding lan item (#{itemId}: #{devname}) - is nfsroot") return false when "ifplugd" log.debug("Excluding lan item (#{itemId}: #{devname}) - ifplugd") return false else return true end end |
- (Object) IsCurrentConfigured
Returns true if current (see LanItems::current) has configuration
330 331 332 |
# File '../../src/modules/LanItems.rb', line 330 def IsCurrentConfigured IsItemConfigured(@current) end |
- (Object) isCurrentDHCP
Check if currently edited device gets its IP address from DHCP (v4, v6 or both)
1545 1546 1547 |
# File '../../src/modules/LanItems.rb', line 1545 def isCurrentDHCP Builtins.regexpmatch(@bootproto, "dhcp[46]?") end |
- (Object) isCurrentHotplug
Is current device hotplug or not? I.e. is connected via usb/pcmci?
1533 1534 1535 1536 1537 1538 1539 1540 |
# File '../../src/modules/LanItems.rb', line 1533 def isCurrentHotplug hotplugtype = Ops.get_string(getCurrentItem, ["hwinfo", "hotplug"], "") if hotplugtype == "usb" || hotplugtype == "pcmci" return true else return false end end |
- (Object) IsItemConfigured(itemId)
Returns true if the item (see LanItems::Items) has netconfig configuration.
321 322 323 324 325 326 |
# File '../../src/modules/LanItems.rb', line 321 def IsItemConfigured(itemId) ret = !GetLanItem(itemId)["ifcfg"].to_s.empty? log.info("IsItemConfigured: item=#{itemId} configured=#{ret}") ret end |
- (Object) main
49 50 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 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 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 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 |
# File '../../src/modules/LanItems.rb', line 49 def main Yast.import "UI" textdomain "network" Yast.import "NetworkInterfaces" Yast.import "ProductFeatures" Yast.import "NetworkConfig" Yast.import "NetworkStorage" Yast.import "Host" Yast.import "Storage" Yast.import "Stage" Yast.include self, "network/complex.rb" Yast.include self, "network/routines.rb" Yast.include self, "network/lan/s390.rb" Yast.include self, "network/lan/udev.rb" Yast.include self, "network/lan/bridge.rb" reset_cache # Hardware information # @see #ReadHardware @Hardware = [] @udev_net_rules = {} @driver_options = {} # used at autoinstallation time @autoinstall_settings = {} # Data was modified? # current selected HW @hw = {} # Which operation is pending? @operation = nil # in special cases when rcnetwork reload is not enought @force_restart = false @description = "" @type = "" # ifcfg name for the @current device @device = "" # FIXME: always empty string - remove all occuriences @alias = "" @current = -1 @hotplug = "" @Requires = [] # address options # boot protocol: BOOTPROTO @bootproto = "static" @ipaddr = "" @remoteip = "" @netmask = "" @prefix = "" @startmode = "auto" @ifplugd_priority = "0" @mtu = "" @ethtool_options = "" # wireless options @wl_mode = "" @wl_essid = "" @wl_nwid = "" @wl_auth_mode = "" # when adding another key, don't forget the chmod 600 in NetworkInterfaces @wl_wpa_psk = "" @wl_key_length = "" @wl_key = [] @wl_default_key = 0 @wl_nick = "" # bond options @bond_slaves = [] @bond_option = "" # VLAN option @vlan_etherdevice = "" @vlan_id = "" # interfaces attached to bridge (list delimited by ' ') @bridge_ports = "" # wl_wpa_eap aggregates the settings in a map for easier CWM access. # # **Structure:** # # wpa_eap # WPA_EAP_MODE: string ("TTLS" "PEAP" or "TLS") # WPA_EAP_IDENTITY: string # WPA_EAP_PASSWORD: string (for TTLS and PEAP) # WPA_EAP_ANONID: string (for TTLS and PEAP) # WPA_EAP_CLIENT_CERT: string (for TLS, file name) # WPA_EAP_CLIENT_KEY: string (for TLS, file name) # WPA_EAP_CLIENT_KEY_PASSWORD: string (for TLS) # WPA_EAP_CA_CERT: string (file name) # WPA_EAP_AUTH: string ("", "MD5", "GTC", "CHAP"*, "PAP"*, "MSCHAP"*, "MSCHAPV2") (*: TTLS only) # WPA_EAP_PEAP_VERSION: string ("", "0", "1") @wl_wpa_eap = {} @wl_channel = "" @wl_frequency = "" @wl_bitrate = "" @wl_accesspoint = "" @wl_power = true @wl_ap_scanmode = "" # Card Features from hwinfo # if not provided, we use the default full list @wl_auth_modes = nil @wl_enc_modes = nil @wl_channels = nil @wl_bitrates = nil @nilliststring = nil # to save some casting # s390 options @qeth_portname = "" @qeth_portnumber = "" # * ctc as PROTOCOL (or ctc mode, number in { 0, 1, .., 4 }, default: 0) @chan_mode = "0" @qeth_options = "" @ipa_takeover = false # * iucv as ROUTER (or iucv user, a zVM guest, string of 1 to 8 chars ) @iucv_user = "" # #84148 # 26bdd00.pdf # Ch 7: qeth device driver for OSA-Express (QDIO) and HiperSockets # MAC address handling for IPv4 with the layer2 option @qeth_layer2 = false @qeth_macaddress = "00:00:00:00:00:00" @qeth_chanids = "" # Timeout for LCS LANCMD @lcs_timeout = "5" # aliases @aliases = {} # for TUN / TAP devices @tunnel_set_owner = "" @tunnel_set_group = "" # infiniband options @ipoib_mode = "" @ipoib_modes = { # translators: a possible value for: IPoIB device mode "connected" => _("connected"), "datagram" => _("datagram") } # propose options @proposal_valid = false @nm_proposal_valid = false # NetworkModules:: name @nm_name = "" # this is the map of kernel modules vs. requested firmware # non-empty keys are firmware packages shipped by SUSE @request_firmware = { "atmel_pci" => "atmel-firmware", "atmel_cs" => "atmel-firmware", "at76_usb" => "atmel-firmware", "ipw2100" => "ipw-firmware", "ipw2200" => "ipw-firmware", "ipw3945" => "ipw-firmware", "iwl1000" => "kernel-firmware", "iwl3945" => "kernel-firmware", "iwl4965" => "kernel-firmware", "iwl5000" => "kernel-firmware", "iwl5150" => "kernel-firmware", "iwl6000" => "kernel-firmware", "b43" => "b43-fwcutter", "b43-pci-bridge" => "b43-fwcutter", "bcm43xx" => "", "prism54" => "", "spectrum_cs" => "", "zd1201" => "", "zd1211rw" => "", "acx" => "", "rt73usb" => "", "prism54usb" => "" } Yast.include self, "network/hardware.rb" # the defaults here are what sysconfig defaults to # (as opposed to what a new interface gets, in {#Select)} @SysconfigDefaults = { "BOOTPROTO" => "static", "IPADDR" => "", "PREFIXLEN" => "", "REMOTE_IPADDR" => "", "NETMASK" => "", "MTU" => "", "ETHTOOL_OPTIONS" => "", "NAME" => "", "STARTMODE" => "manual", "IFPLUGD_PRIORITY" => "0", "WIRELESS_MODE" => "Managed", "WIRELESS_ESSID" => "", "WIRELESS_NWID" => "", "WIRELESS_AUTH_MODE" => "open", "WIRELESS_WPA_PSK" => "", "WIRELESS_KEY_LENGTH" => "128", "WIRELESS_KEY" => "", "WIRELESS_KEY_0" => "", "WIRELESS_KEY_1" => "", "WIRELESS_KEY_2" => "", "WIRELESS_KEY_3" => "", "WIRELESS_DEFAULT_KEY" => "0", "WIRELESS_NICK" => "", "WIRELESS_CHANNEL" => "", "WIRELESS_FREQUENCY" => "", "WIRELESS_BITRATE" => "auto", "WIRELESS_AP" => "", "WIRELESS_POWER" => "", "WIRELESS_EAP_MODE" => "", "WIRELESS_WPA_IDENTITY" => "", "WIRELESS_WPA_PASSWORD" => "", "WIRELESS_WPA_ANONID" => "", "WIRELESS_CLIENT_CERT" => "", "WIRELESS_CLIENT_KEY" => "", "WIRELESS_CLIENT_KEY_PASSWORD" => "", "WIRELESS_CA_CERT" => "", "WIRELESS_EAP_AUTH" => "", "WIRELESS_PEAP_VERSION" => "", "WIRELESS_AP_SCANMODE" => "1", # default options for bonding (bnc#404449) "BONDING_MODULE_OPTS" => "mode=active-backup miimon=100", # defaults for tun/tap devices "TUNNEL_SET_OWNER" => "", "TUNNEL_SET_GROUP" => "", # Infiniband # default mode for IPoIB devices suggested in fate#315501 "IPOIB_MODE" => "connected" } # Default values used when creating an emulated NIC for physical s390 hardware. @s390_defaults = { "CHAN_MODE" => "0", "QETH_PORTNAME" => "", "QETH_PORTNUMBER" => "", "QETH_OPTIONS" => "", "QETH_LAYER2" => "no", "QETH_CHANIDS" => "", "IPA_TAKEOVER" => "no", "IUCV_USER" => "", "LLADDR" => "00:00:00:00:00:00" } # ifplugd sometimes does not work for wifi # so wired needs higher priority to override it @ifplugd_priorities = { "eth" => "20", "wlan" => "10" } end |
- (Object) needFirmwareCurrentItem
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 |
# File '../../src/modules/LanItems.rb', line 1239 def needFirmwareCurrentItem need = false if IsNotEmpty(Ops.get_string(@Items, [@current, "hwinfo", "driver"], "")) if Builtins.haskey( @request_firmware, Ops.get_string(@Items, [@current, "hwinfo", "driver"], "") ) need = true end else Builtins.foreach( Ops.get_list(@Items, [@current, "hwinfo", "drivers"], []) ) do |driver| if Builtins.haskey( @request_firmware, Ops.get_string(driver, ["modules", 0, 0], "") ) Builtins.y2milestone( "driver %1 needs firmware", Ops.get_string(driver, ["modules", 0, 0], "") ) need = true end end end Builtins.y2milestone("item %1 needs firmware:%2", @current, need) need end |
- (Object) new_device_startmode
returns default startmode for a new device
startmode is returned according product, Arch and current device type
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 |
# File '../../src/modules/LanItems.rb', line 1858 def new_device_startmode product_startmode = ProductFeatures.GetStringFeature( "network", "startmode" ) Builtins.y2milestone("Startmode by product: #{product_startmode}") case product_startmode when "ifplugd" if replace_ifplugd? startmode = hotplug_usable? ? "hotplug" : "auto" else startmode = product_startmode end when "auto" startmode = "auto" else startmode = hotplug_usable? ? "hotplug" : "auto" end Builtins.y2milestone("New device startmode: #{startmode}") startmode end |
- (Object) new_item_default_options
returns a map with device options for newly created item
1885 1886 1887 1888 1889 1890 1891 1892 1893 |
# File '../../src/modules/LanItems.rb', line 1885 def { # bnc#46369 "NETMASK" => NetHwDetection.result["NETMASK"] || "255.255.255.0", "STARTMODE" => new_device_startmode, # bnc#883836 bnc#868187 "DHCLIENT_SET_DEFAULT_ROUTE" => "no" } end |
- (Object) Overview
Create an overview table with all configured devices
1527 1528 1529 1530 |
# File '../../src/modules/LanItems.rb', line 1527 def Overview BuildLanOverview() GetDescr() end |
- (Object) ProposeItem
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 |
# File '../../src/modules/LanItems.rb', line 2422 def ProposeItem Builtins.y2milestone("Propose configuration for %1", getCurrentItem) @operation = nil return false if Select("") != true SetDefaultsForHW() @ipaddr = "" @netmask = "" @bootproto = "dhcp" # #176804 if Storage.IsDeviceOnNetwork(NetworkStorage.getDevice("/")) != :no @startmode = "nfsroot" Builtins.y2milestone("startmode nfsroot") end NetworkInterfaces.Add @operation = :edit Ops.set( @Items, [@current, "ifcfg"], Ops.get_string(getCurrentItem, ["hwinfo", "dev_name"], "") ) @description = HardwareName( [Ops.get_map(getCurrentItem, "hwinfo", {})], Ops.get_string(getCurrentItem, ["hwinfo", "dev_name"], "") ) Commit() Builtins.y2milestone("After configuration propose %1", getCurrentItem) true end |
- (Object) Read
initializates @Items
It does: (1) read hardware present on the system (2) read known configurations (e.g. ifcfg-eth0) (3) joins together. Join is done via device name (e.g. eth0) as key. It is full outer join in -> you can have hwinfo part with no coresponding netconfig part (or vice versa) in @Items when the method is done.
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
# File '../../src/modules/LanItems.rb', line 1112 def Read ReadHw() NetworkInterfaces.Read NetworkInterfaces.CleanHotplugSymlink interfaces = getNetworkInterfaces # match configurations to Items list with hwinfo Builtins.foreach(interfaces) do |confname| pos = nil val = {} Builtins.foreach( Convert.convert( @Items, from: "map <integer, any>", to: "map <integer, map <string, any>>" ) ) do |key, value| if Ops.get_string(value, ["hwinfo", "dev_name"], "") == confname pos = key val = deep_copy(value) end end if pos.nil? pos = Builtins.size(@Items) Ops.set(@Items, pos, {}) end Ops.set(@Items, [pos, "ifcfg"], confname) end # add to Items also virtual devices (configurations) without hwinfo Builtins.foreach(interfaces) do |confname| already = false Builtins.foreach( Convert.convert( Map.Keys(@Items), from: "list", to: "list <integer>" ) ) do |key| if confname == Ops.get_string(@Items, [key, "ifcfg"], "") already = true raise Break end end if !already AddNew() Ops.set(@Items, @current, "ifcfg" => confname) end end Builtins.y2milestone("Read Configuration LanItems::Items %1", @Items) nil end |
- (Object) ReadHw
preinitializates @Items according info on physically detected network cards
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File '../../src/modules/LanItems.rb', line 1053 def ReadHw @Items = {} @Hardware = ReadHardware("netcard") # Hardware = [$["active":true, "bus":"pci", "busid":"0000:02:00.0", "dev_name":"wlan0", "drivers":[$["active":true, "modprobe":true, "modules":[["ath5k" , ""]]]], "link":true, "mac":"00:22:43:37:55:c3", "modalias":"pci:v0000168Cd0000001Csv00001A3Bsd00001026bc02s c00i00", "module":"ath5k", "name":"AR242x 802.11abg Wireless PCI Express Adapter", "num":0, "options":"", "re quires":[], "sysfs_id":"/devices/pci0000:00/0000:00:1c.1/0000:02:00.0", "type":"wlan", "udi":"/org/freedeskto p/Hal/devices/pci_168c_1c", "wl_auth_modes":["open", "sharedkey", "wpa-psk", "wpa-eap"], "wl_bitrates":nil, " wl_channels":["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"], "wl_enc_modes":["WEP40", "WEP104", "T KIP", "CCMP"]], $["active":true, "bus":"pci", "busid":"0000:01:00.0", "dev_name":"eth0", "drivers":[$["active ":true, "modprobe":true, "modules":[["atl1e", ""]]]], "link":false, "mac":"00:23:54:3f:7c:c3", "modalias":"pc i:v00001969d00001026sv00001043sd00008324bc02sc00i00", "module":"atl1e", "name":"L1 Gigabit Ethernet Adapter", "num":1, "options":"", "requires":[], "sysfs_id":"/devices/pci0000:00/0000:00:1c.3/0000:01:00.0", "type":"et h", "udi":"/org/freedesktop/Hal/devices/pci_1969_1026", "wl_auth_modes":nil, "wl_bitrates":nil, "wl_channels" :nil, "wl_enc_modes":nil]]; ReadUdevDriverRules() udev_drivers_rules = Convert.convert( SCR.Read(path(".udev_persistent.drivers")), from: "any", to: "map <string, any>" ) Builtins.foreach(@Hardware) do |hwitem| udev_net = if Ops.get_string(hwitem, "dev_name", "") != "" Ops.get_list( @udev_net_rules, Ops.get_string(hwitem, "dev_name", ""), [] ) else [] end mod = Builtins.deletechars( Ops.get( Builtins.splitstring( Ops.get( Ops.get_list( udev_drivers_rules, Ops.get_string(hwitem, "modalias", ""), [] ), 1, "" ), "=" ), 1, "" ), "\"" ) Ops.set( @Items, Builtins.size(@Items), "hwinfo" => hwitem, "udev" => { "net" => udev_net, "driver" => mod } ) end nil end |
- (Object) ReadUdevDriverRules
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 |
# File '../../src/modules/LanItems.rb', line 438 def ReadUdevDriverRules Builtins.y2milestone("Reading udev rules ...") @udev_net_rules = Convert.convert( SCR.Read(path(".udev_persistent.net")), from: "any", to: "map <string, any>" ) Builtins.y2milestone("Reading driver options ...") Builtins.foreach(SCR.Dir(path(".modules.options"))) do |driver| pth = Builtins.sformat(".modules.options.%1", driver) Builtins.foreach( Convert.convert( SCR.Read(Builtins.topath(pth)), from: "any", to: "map <string, string>" ) ) do |key, value| Ops.set( @driver_options, driver, Builtins.sformat( "%1%2%3=%4", Ops.get_string(@driver_options, driver, ""), if Ops.greater_than( Builtins.size(Ops.get_string(@driver_options, driver, "")), 0 ) " " else "" end, key, value ) ) end end true end |
- (Object?) RemoveItemUdev(key)
It deletes the given key from the udev rule of the current item.
there is not udev rules for the current item
507 508 509 510 511 512 513 514 515 |
# File '../../src/modules/LanItems.rb', line 507 def RemoveItemUdev(key) current_rule = LanItems.GetItemUdevRule(LanItems.current) return nil if current_rule.empty? log.info("Removing #{key} from #{current_rule}") Items()[@current]["udev"]["net"] = LanItems.RemoveKeyFromUdevRule(current_rule, key) end |
- (Object) rename(name)
Sets new device name for current item
641 642 643 644 645 646 647 |
# File '../../src/modules/LanItems.rb', line 641 def rename(name) if (GetCurrentName() != name) @Items[@current]["renamed_to"] = name else @Items[@current].delete("renamed_to") end end |
- (Boolean) renamed?(item_id)
Tells if current item was renamed
663 664 665 666 |
# File '../../src/modules/LanItems.rb', line 663 def renamed?(item_id) return false if !LanItems.Items[item_id].key?("renamed_to") renamed_to(item_id) != GetDeviceName(item_id) end |
- (Object) renamed_to(item_id)
Returns new name for current item
652 653 654 |
# File '../../src/modules/LanItems.rb', line 652 def renamed_to(item_id) @Items[item_id]["renamed_to"] end |
- (Boolean) replace_ifplugd?
1847 1848 1849 1850 1851 1852 1853 |
# File '../../src/modules/LanItems.rb', line 1847 def replace_ifplugd? return true if !Arch.is_laptop return true if NetworkService.is_network_manager return true if ["bond", "vlan", "br"].include? type false end |
- (Object) ReplaceItemUdev(replace_key, new_key, new_val)
It replaces a tuple identified by replace_key in current item's udev rule
Note that the tuple is identified by key only. However modification flag is set only if value was changed (in case when replace_key == new_key)
It also contain a logic on tuple operators. When the new_key is “NAME” then assignment operator (=) is used. Otherwise equality operator (==) is used. Thats bcs this function is currently used for touching “NAME”, “KERNELS” and “ATTRaddress” keys only
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 |
# File '../../src/modules/LanItems.rb', line 573 def ReplaceItemUdev(replace_key, new_key, new_val) # = for assignment # == for equality checks operator = new_key == "NAME" ? "=" : "==" current_rule = getUdevFallback rule = RemoveKeyFromUdevRule(getUdevFallback, replace_key) # NAME="devname" has to be last in the rule. # otherwise SCR agent .udev_persistent.net returns crap # isn't that fun name_tuple = rule.pop new_rule = AddToUdevRule(rule, "#{new_key}#{operator}\"#{new_val}\"") new_rule.push(name_tuple) log.info("ReplaceItemUdev: new udev rule = #{new_rule}") if current_rule.sort != new_rule.sort SetModified() Items()[@current]["udev"] = { "net" => {} } if !Items()[@current]["udev"] Items()[@current]["udev"]["net"] = new_rule end deep_copy(new_rule) end |
- (Object) reset_cache
Clears internal cache of the module to default values
TODO: LanItems consists of several sets of internal variables. 1) cache of items describing network interface 2) variables used as a kind of iterator in the cache 3) variables which keeps (some of) attributes of the current item (= item which is being pointed by the iterator)
1173 1174 1175 1176 1177 |
# File '../../src/modules/LanItems.rb', line 1173 def reset_cache LanItems.Items = {} @modified = false end |
- (Object) Rollback
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 |
# File '../../src/modules/LanItems.rb', line 2176 def Rollback if Ops.get_boolean(getCurrentItem, "commited", true) == false Builtins.y2milestone("rollback item %1", @current) if !Ops.greater_than( Builtins.size(Ops.get_map(getCurrentItem, "hwinfo", {})), 0 ) @Items = Builtins.remove(@Items, @current) else if Builtins.haskey(Ops.get_map(@Items, @current, {}), "ifcfg") if !Builtins.contains( getNetworkInterfaces, Ops.get_string(getCurrentItem, "ifcfg", "") ) Ops.set( @Items, @current, Builtins.remove(Ops.get_map(@Items, @current, {}), "ifcfg") ) end end end end true end |
- (Object) Select(dev)
Select the given device FIXME: currently dev is always “”
1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 |
# File '../../src/modules/LanItems.rb', line 1899 def Select(dev) Builtins.y2debug("dev=%1", dev) devmap = # FIXME: encapsulate into LanItems.GetItemType ? @type = Ops.get_string(@Items, [@current, "hwinfo", "type"], "eth") @device = @type + NetworkInterfaces.GetFreeDevice(@type) # TODO: instead of udev use hwinfo dev_name NetworkInterfaces.Name = GetItemUdev("NAME") if Ops.less_than(Builtins.size(@Items), @current) Ops.set(@Items, @current, "ifcfg" => NetworkInterfaces.Name) else Ops.set(@Items, [@current, "ifcfg"], NetworkInterfaces.Name) end # FIXME: alias: how to prefill new alias? @alias = "" # general stuff @description = BuildDescription(@type, @device, devmap, @Hardware) SetDeviceVars(devmap, @SysconfigDefaults) InitS390VarsByDefaults() @hotplug = "" Builtins.y2debug("type=%1", @type) if Builtins.issubstring(@type, "-") @type = Builtins.regexpsub(@type, "([^-]+)-.*$", "\\1") end Builtins.y2debug("type=%1", @type) true end |
- (Object) SelectHW(which)
Select the hardware component
1668 1669 1670 1671 1672 |
# File '../../src/modules/LanItems.rb', line 1668 def SelectHW(which) SelectHWMap(FindHardware(@Hardware, which)) nil end |
- (Object) SelectHWMap(hardware)
Select the hardware component
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
# File '../../src/modules/LanItems.rb', line 1555 def SelectHWMap(hardware) hardware = deep_copy(hardware) sel = SelectHardwareMap(hardware) # common stuff @description = Ops.get_string(sel, "name", "") @type = Ops.get_string(sel, "type", "eth") @hotplug = Ops.get_string(sel, "hotplug", "") @Requires = Ops.get_list(sel, "requires", []) # #44977: Requires now contain the appropriate kernel packages # but they are handled differently due to multiple kernel flavors # (see Package::InstallKernel) # Leave only those not starting with "kernel". @Requires = Builtins.filter(@Requires) do |r| Builtins.search(r, "kernel") != 0 end Builtins.y2milestone("requires=%1", @Requires) # FIXME: devname @hotplug = "" # Wireless Card Features @wl_auth_modes = Builtins.prepend( Convert.convert( Ops.get(hardware, "wl_auth_modes", @nilliststring), from: "any", to: "list <string>" ), "no-encryption" ) @wl_enc_modes = Convert.convert( Ops.get(hardware, "wl_enc_modes", @nilliststring), from: "any", to: "list <string>" ) @wl_channels = Convert.convert( Ops.get(hardware, "wl_channels", @nilliststring), from: "any", to: "list <string>" ) @wl_bitrates = Convert.convert( Ops.get(hardware, "wl_bitrates", @nilliststring), from: "any", to: "list <string>" ) Builtins.y2milestone("hw=%1", hardware) @hw = deep_copy(hardware) if Arch.s390 && @operation == :add Builtins.y2internal("Propose chan_ids values for %1", @hw) devid = 0 devstr = "" s390chanid = "[0-9]+\\.[0-9]+\\." if Builtins.regexpmatch(Ops.get_string(@hw, "busid", ""), s390chanid) devid = Builtins.tointeger( Ops.add( "0x", Builtins.regexpsub( Ops.get_string(@hw, "busid", ""), Ops.add(s390chanid, "(.*)"), "\\1" ) ) ) devstr = Builtins.regexpsub( Ops.get_string(@hw, "busid", ""), Ops.add(Ops.add("(", s390chanid), ").*"), "\\1" ) end Builtins.y2milestone("devid=%1(%2)", devid, devstr) devid = 0 if devid.nil? devid0 = String.PadZeros( Builtins.regexpsub(Builtins.tohexstring(devid), "0x(.*)", "\\1"), 4 ) devid1 = String.PadZeros( Builtins.regexpsub( Builtins.tohexstring(Ops.add(devid, 1)), "0x(.*)", "\\1" ), 4 ) devid2 = String.PadZeros( Builtins.regexpsub( Builtins.tohexstring(Ops.add(devid, 2)), "0x(.*)", "\\1" ), 4 ) if DriverType(@type) == "ctc" || DriverType(@type) == "lcs" @qeth_chanids = Builtins.sformat("%1%2 %1%3", devstr, devid0, devid1) else @qeth_chanids = Builtins.sformat( "%1%2 %1%3 %1%4", devstr, devid0, devid1, devid2 ) end end nil end |
- (Object) SetCurrentName(name)
Updates current device name.
It updates device's udev rules and config name. Updating config name means that old configuration is deleted from the system.
Returns new name
636 637 638 |
# File '../../src/modules/LanItems.rb', line 636 def SetCurrentName(name) SetItemName(@current, name) end |
- (Object) SetDefaultsForHW
must be in sync with #GetDefaultsForHW
1711 1712 1713 1714 1715 1716 |
# File '../../src/modules/LanItems.rb', line 1711 def SetDefaultsForHW Builtins.y2milestone("SetDefaultsForHW type %1", @type) @mtu = "1492" if Arch.s390 && Builtins.contains(["lcs", "eth"], @type) nil end |
- (Object) SetDeviceMap(item_id, devmap)
Sets item's sysconfig device map to given one
It updates NetworkInterfaces according given map. Map is expected to be a hash where both key even value are strings
411 412 413 414 415 416 |
# File '../../src/modules/LanItems.rb', line 411 def SetDeviceMap(item_id, devmap) devname = GetDeviceName(item_id) return false if devname.nil? || devname.empty? NetworkInterfaces.Change2(devname, devmap, false) end |
- (void) SetDeviceVars(devmap, defaults)
This method returns an undefined value.
Distributes an ifcfg hash to individual attributes.
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 |
# File '../../src/modules/LanItems.rb', line 1722 def SetDeviceVars(devmap, defaults) d = defaults.merge(devmap) # address options @bootproto = d["BOOTPROTO"] @ipaddr = d["IPADDR"] @prefix = d["PREFIXLEN"] @remoteip = d["REMOTE_IPADDR"] @netmask = d["NETMASK"] @set_default_route = case d["DHCLIENT_SET_DEFAULT_ROUTE"] when "yes" then true when "no" then false # all other values! count as unspecified which is default value end @mtu = d["MTU"] @ethtool_options = d["ETHTOOL_OPTIONS"] @startmode = d["STARTMODE"] @ifplugd_priority = d["IFPLUGD_PRIORITY"] @description = d["NAME"] @bond_option = d["BONDING_MODULE_OPTS"] @vlan_etherdevice = d["ETHERDEVICE"] # FIXME, remember that it can be implied from the name. probably @vlan_id = d["VLAN_ID"] @bridge_ports = d["BRIDGE_PORTS"] @bond_slaves = [] Builtins.foreach(devmap) do |key, value| if Builtins.regexpmatch(Convert.to_string(key), "BONDING_SLAVE[0-9]+") if !Convert.to_string(value).nil? @bond_slaves = Builtins.add(@bond_slaves, Convert.to_string(value)) end end end # tun/tap settings @tunnel_set_owner = d["TUNNEL_SET_OWNER"] @tunnel_set_group = d["TUNNEL_SET_GROUP"] # wireless options @wl_mode = d["WIRELESS_MODE"] @wl_essid = d["WIRELESS_ESSID"] @wl_nwid = d["WIRELESS_NWID"] @wl_auth_mode = d["WIRELESS_AUTH_MODE"] @wl_wpa_psk = d["WIRELESS_WPA_PSK"] @wl_key_length = d["WIRELESS_KEY_LENGTH"] @wl_key = [ d["WIRELESS_KEY_0"], d["WIRELESS_KEY_1"], d["WIRELESS_KEY_2"], d["WIRELESS_KEY_3"] ] @wl_key[0] = d["WIRELESS_KEY"] if (@wl_key[0] || "").empty? @wl_default_key = d["WIRELESS_DEFAULT_KEY"].to_i @wl_nick = d["WIRELESS_NICK"] @wl_wpa_eap = { "WPA_EAP_MODE" => d["WIRELESS_EAP_MODE"], "WPA_EAP_IDENTITY" => d["WIRELESS_WPA_IDENTITY"], "WPA_EAP_PASSWORD" => d["WIRELESS_WPA_PASSWORD"], "WPA_EAP_ANONID" => d["WIRELESS_WPA_ANONID"], "WPA_EAP_CLIENT_CERT" => d["WIRELESS_CLIENT_CERT"], "WPA_EAP_CLIENT_KEY" => d["WIRELESS_CLIENT_KEY"], "WPA_EAP_CLIENT_KEY_PASSWORD" => d["WIRELESS_CLIENT_KEY_PASSWORD"], "WPA_EAP_CA_CERT" => d["WIRELESS_CA_CERT"], "WPA_EAP_AUTH" => d["WIRELESS_EAP_AUTH"], "WPA_EAP_PEAP_VERSION" => d["WIRELESS_PEAP_VERSION"] } @wl_channel = d["WIRELESS_CHANNEL"] @wl_frequency = d["WIRELESS_FREQUENCY"] @wl_bitrate = d["WIRELESS_BITRATE"] @wl_accesspoint = d["WIRELESS_AP"] @wl_power = d["WIRELESS_POWER"] == "yes" @wl_ap_scanmode = d["WIRELESS_AP_SCANMODE"] @ipoib_mode = d["IPOIB_MODE"] @aliases = Ops.get_map(devmap, "_aliases", {}) nil end |
- (Object) setDriver(driver)
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 |
# File '../../src/modules/LanItems.rb', line 2451 def setDriver(driver) Builtins.y2milestone( "driver %1, %2", driver, Ops.get_string(getCurrentItem, ["hwinfo", "module"], "") ) if Ops.get_string(getCurrentItem, ["hwinfo", "module"], "") == driver && IsEmpty(Ops.get_string(getCurrentItem, ["udev", "driver"], "")) return end Ops.set(@Items, [@current, "udev", "driver"], driver) nil end |
- (Object) SetItem
2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 |
# File '../../src/modules/LanItems.rb', line 2390 def SetItem @operation = :edit @device = Ops.get_string(getCurrentItem, "ifcfg", "") NetworkInterfaces.Edit(@device) @type = Ops.get_string(getCurrentItem, ["hwinfo", "type"], "") @type = NetworkInterfaces.GetType(@device) if IsEmpty(@type) @alias = NetworkInterfaces.alias_num(@device) # general stuff devmap = deep_copy(NetworkInterfaces.Current) s390_devmap = s390_ReadQethConfig( Ops.get_string(getCurrentItem, ["hwinfo", "dev_name"], "") ) @description = BuildDescription(@type, @device, devmap, @Hardware) SetDeviceVars(devmap, @SysconfigDefaults) SetS390Vars(s390_devmap, @s390_defaults) @hotplug = "" Builtins.y2debug("type=%1", @type) if Builtins.issubstring(@type, "-") @type = Builtins.regexpsub(@type, "([^-]+)-.*$", "\\1") end Builtins.y2debug("type=%1", @type) nil end |
- (Object) SetItemName(itemId, name)
Updates device name.
It updates device's udev rules and config name. Updating config name means that old configuration is deleted from the system.
Returns new name
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
# File '../../src/modules/LanItems.rb', line 608 def SetItemName(itemId, name) lan_items = LanItems.Items if name && !name.empty? if lan_items[itemId]["udev"] updated_rule = update_udev_rule_key(GetItemUdevRule(itemId), "NAME", name) lan_items[itemId]["udev"]["net"] = updated_rule end else # rewrite rule for empty name is meaningless lan_items[itemId].delete("udev") end if lan_items[itemId].key?("ifcfg") NetworkInterfaces.Delete2(lan_items[itemId]["ifcfg"]) lan_items[itemId]["ifcfg"] = name.to_s end name end |
- (Object) SetItemSysconfigOpt(item_id, opt, value)
Sets one option in items sysconfig device map
Currently no checks on sysconfig option validity are performed
423 424 425 426 427 428 429 |
# File '../../src/modules/LanItems.rb', line 423 def SetItemSysconfigOpt(item_id, opt, value) devmap = GetDeviceMap(item_id) return false if devmap.nil? devmap[opt] = value SetDeviceMap(item_id, devmap) end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”
812 813 814 815 816 |
# File '../../src/modules/LanItems.rb', line 812 def SetModified @modified = true nil end |
- (Object) SetS390Vars(devmap, defaults)
Initializes s390 specific device variables.
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 |
# File '../../src/modules/LanItems.rb', line 1808 def SetS390Vars(devmap, defaults) return if !Arch.s390 d = defaults.merge(devmap) @qeth_portname = d["QETH_PORTNAME"] @qeth_portnumber = d["QETH_PORTNUMBER"] @qeth_layer2 = d["QETH_LAYER2"] == "yes" @qeth_chanids = d["QETH_CHANIDS"] # s/390 options # We always have to set the MAC Address for qeth Layer2 support. # It is used mainly as a hint for user that MAC is expected in case # of Layer2 devices. Other devices do not need it. Simply # because such devices do not emulate Layer2 @qeth_macaddress = d["LLADDR"] if @qeth_layer2 # qeth attribute. FIXME: currently not read from system. @ipa_takeover = Ops.get_string(defaults, "IPA_TAKEOVER", "") == "yes" # not device attribute @qeth_options = Ops.get_string(defaults, "QETH_OPTIONS", "") # handle non qeth devices @iucv_user = Ops.get_string(defaults, "IUCV_USER", "") @chan_mode = Ops.get_string(defaults, "CHAN_MODE", "") nil end |
- (Object) setup_basic_device_options(devmap)
Sets device map items for device when it is not alias
1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 |
# File '../../src/modules/LanItems.rb', line 1946 def (devmap) return devmap if !@alias.empty? devmap["MTU"] = @mtu devmap["ETHTOOL_OPTIONS"] = @ethtool_options devmap["STARTMODE"] = @startmode devmap["IFPLUGD_PRIORITY"] = @ifplugd_priority.to_i if @startmode == "ifplugd" devmap["BOOTPROTO"] = @bootproto devmap["_aliases"] = @aliases log.info("aliases #{@aliases}") devmap end |
- (Hash) setup_bonding(devmap, slaves, options)
Sets bonding specific sysconfig options in given device map
If any bonding specific option is present already it gets overwritten by new ones in case of collision. If any BONDING_SLAVEx from devmap is not set, then its value is set to 'nil'
1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 |
# File '../../src/modules/LanItems.rb', line 1971 def setup_bonding(devmap, slaves, ) raise ArgumentError, "Device map has to be provided." if devmap.nil? devmap = deep_copy(devmap) slaves ||= [] slave_opts = devmap.select { |k, _| k.start_with?("BONDING_SLAVE") }.keys slave_opts.each { |s| devmap[s] = nil } slaves.each_with_index { |s, i| devmap["BONDING_SLAVE#{i}"] = s } devmap["BONDING_MODULE_OPTS"] = || "" devmap["BONDING_MASTER"] = "yes" devmap end |
- (Object) setup_dhclient_options(devmap)
Sets device map items related to dhclient
1938 1939 1940 1941 1942 1943 |
# File '../../src/modules/LanItems.rb', line 1938 def (devmap) if isCurrentDHCP devmap["DHCLIENT_SET_DEFAULT_ROUTE"] = TRISTATE_TO_S.fetch(@set_default_route) end devmap end |
- (Object) startmode_overview(item_id)
Creates item's startmode human description
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
# File '../../src/modules/LanItems.rb', line 1340 def startmode_overview(item_id) startmode_descrs = { # summary description of STARTMODE=auto "auto" => _( "Started automatically at boot" ), # summary description of STARTMODE=auto "onboot" => _( "Started automatically at boot" ), # summary description of STARTMODE=hotplug "hotplug" => _( "Started automatically at boot" ), # summary description of STARTMODE=ifplugd "ifplugd" => _( "Started automatically on cable connection" ), # summary description of STARTMODE=managed "managed" => _( "Managed by NetworkManager" ), # summary description of STARTMODE=off "off" => _( "Will not be started at all" ) } ifcfg = GetDeviceMap(item_id) || {} startmode_descr = startmode_descrs[ifcfg["STARTMODE"].to_s] || _("Started manually") [startmode_descr] end |
- (void) update_item_udev_rule!(based_on = :mac)
This method returns an undefined value.
Updates the udev rule of the current Lan Item based on the key given which currently could be mac or bus_id.
In case of bus_id the dev_port will be always added to avoid cases where the interfaces shared the same bus_id (i.e. Multiport cards using the same function to all the ports) (bsc#1007172)
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 |
# File '../../src/modules/LanItems.rb', line 526 def update_item_udev_rule!(based_on = :mac) case based_on when :mac LanItems.RemoveItemUdev("ATTR{dev_port}") # FIXME: While the user is able to modify the udev rule using the # mac address instead of bus_id when bonding, could be that the # mac in use was not the permanent one. We could read it with # ethtool -P dev_name} LanItems.ReplaceItemUdev( "KERNELS", "ATTR{address}", LanItems.getCurrentItem.fetch("hwinfo", {}).fetch("mac", "") ) when :bus_id # Update or insert the dev_port if the sysfs dev_port attribute is present LanItems.ReplaceItemUdev( "ATTR{dev_port}", "ATTR{dev_port}", LanItems.dev_port(LanItems.GetCurrentName) ) if LanItems.dev_port?(LanItems.GetCurrentName) # If the current rule is mac based, overwrite to bus id. Don't touch otherwise. LanItems.ReplaceItemUdev( "ATTR{address}", "KERNELS", LanItems.getCurrentItem.fetch("hwinfo", {}).fetch("busid", "") ) else raise ArgumentError, "The key given for udev rule #{based_on} is not supported" end end |
- (Object) write
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
# File '../../src/modules/LanItems.rb', line 781 def write renamed_items = @Items.keys.select { |item_id| renamed?(item_id) } renamed_items.each do |item_id| devmap = GetDeviceMap(item_id) # change configuration name if device is configured NetworkInterfaces.Change2(renamed_to(item_id), devmap, false) if devmap SetItemName(item_id, renamed_to(item_id)) end # FIXME: in case of AY, writing udev rules was partly moved into first stage # (bnc#955217). However, it is so only in case of ssh / vnc installation. # Otherwise, udev rules are written in second stage in *LanUdevAuto* module # and it breaks consistency of data stored in Items. So, moving writing # udev rules into first stage should be completed ASAP even fo non-ssh / vnc # AY installations and LanUdevAuto module should be dropped. # When refactored at least these use cases need to be retested: # - bnc#955217 # - bnc#956605 LanItems.WriteUdevRules if !Stage.cont && LanUdevAuto.AllowUdevModify # FIXME: hack: no "netcard" filter as biosdevname names it diferently (bnc#712232) NetworkInterfaces.Write("") end |
- (Object) WriteUdevDriverRules
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
# File '../../src/modules/LanItems.rb', line 714 def WriteUdevDriverRules udev_drivers_rules = {} Builtins.foreach( Convert.convert( Map.Keys(@Items), from: "list", to: "list <integer>" ) ) do |key| driver = Ops.get_string(@Items, [key, "udev", "driver"], "") if IsNotEmpty(driver) modalias = Ops.get_string(@Items, [key, "hwinfo", "modalias"], "") driver_rule = [] driver_rule = AddToUdevRule( driver_rule, Builtins.sformat("ENV{MODALIAS}==\"%1\"", modalias) ) driver_rule = AddToUdevRule( driver_rule, Builtins.sformat("ENV{MODALIAS}=\"%1\"", driver) ) Ops.set(udev_drivers_rules, driver, driver_rule) end end Builtins.y2milestone("write drivers udev rules: %1", udev_drivers_rules) SCR.Write(path(".udev_persistent.drivers"), udev_drivers_rules) # write rules from driver Builtins.foreach( Convert.convert( @driver_options, from: "map <string, any>", to: "map <string, string>" ) ) do |key, value| val = {} Builtins.foreach(Builtins.splitstring(value, " ")) do |k| l = Builtins.splitstring(k, "=") Ops.set(val, Ops.get(l, 0, ""), Ops.get(l, 1, "")) end val = nil if IsEmpty(value) SCR.Write(Builtins.add(path(".modules.options"), key), val) end SCR.Write(path(".modules"), nil) nil end |
- (Object) WriteUdevItemsRules
Writes udev rules for all items.
Currently only interesting change is renaming interface.
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
# File '../../src/modules/LanItems.rb', line 675 def WriteUdevItemsRules # loop over all items and checks if device name has changed net_rules = [] Builtins.foreach( Convert.convert( Map.Keys(@Items), from: "list", to: "list <integer>" ) ) do |key| item_udev_net = GetItemUdevRule(key) next if IsEmpty(item_udev_net) dev_name = Ops.get_string(@Items, [key, "hwinfo", "dev_name"], "") @current = key if dev_name != GetItemUdev("NAME") # when changing device name you have a choice # - change kernel "match rule", or # - remove it completely # removing is less error prone when tracking name changes, so it was chosen. item_udev_net = RemoveKeyFromUdevRule(item_udev_net, "KERNEL") # setting links down during AY is forbidden bcs it can freeze ssh installation SetLinkDown(dev_name) if !Mode.autoinst @force_restart = true end net_rules = Builtins.add( net_rules, Builtins.mergestring(item_udev_net, ", ") ) end Builtins.y2milestone("write net udev rules: %1", net_rules) write_update_udevd(net_rules) true end |
- (Object) WriteUdevRules
768 769 770 771 772 773 774 775 776 777 778 779 |
# File '../../src/modules/LanItems.rb', line 768 def WriteUdevRules WriteUdevItemsRules() WriteUdevDriverRules() # wait so that ifcfgs written in NetworkInterfaces are newer # (1-second-wise) than netcontrol status files, # and rcnetwork reload actually works (bnc#749365) SCR.Execute(path(".target.bash"), "udevadm settle") sleep(1) nil end |