Class: Yast::LanItemsClass
- Inherits:
-
Module
- Object
- Module
- Yast::LanItemsClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/LanItems.rb
Overview
Does way too many things.
-
Aggregates data about network interfaces, both configured and unconfigured, in #Items, which see.
-
Provides direct access to individual items of ifcfg files. For example BOOTPROTO and STARTMODE are accessible in #bootproto and #startmode (set via #SetDeviceVars via #Select or #SetItem). The reverse direction (putting the individual values back to an item) is #Commit.
-
...
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 any 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)
-
- (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?
- - (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) 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)
- - (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.
-
- (Object) setup_dhclient_options(devmap)
Sets device map items related to dhclient.
- - (Object) startmode_overview
-
- (Object) UnsetModified
Function sets internal variable, which indicates, that any settings were modified, to “false”.
- - (Object) write
- - (Object) WriteUdevDriverRules
-
- (Object) WriteUdevItemsRules
Writes udev rules for all items.
- - (Object) WriteUdevRules
Instance Attribute Details
- (list <map>) :Hardware(:Hardware)
2553 |
# File '../../src/modules/LanItems.rb', line 2553 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
2551 |
# File '../../src/modules/LanItems.rb', line 2551 publish_variable :Items , "map <integer, any>" |
- (list <string>) :Requires(:Requires)
2568 |
# File '../../src/modules/LanItems.rb', line 2568 publish_variable :Requires , "list <string>" |
- (map <string, string>) :SysconfigDefaults(:SysconfigDefaults)
2621 |
# File '../../src/modules/LanItems.rb', line 2621 publish_variable :SysconfigDefaults , "map <string, string>" |
- (string) alias
2563 |
# File '../../src/modules/LanItems.rb', line 2563 publish_variable :alias , "string" |
- (map) aliases
2614 |
# File '../../src/modules/LanItems.rb', line 2614 publish_variable :aliases , "map" |
- (map) autoinstall_settings
2556 |
# File '../../src/modules/LanItems.rb', line 2556 publish_variable :autoinstall_settings , "map" |
- (string) bond_option
2589 |
# File '../../src/modules/LanItems.rb', line 2589 publish_variable :bond_option , "string" |
- (list <string>) bond_slaves
2588 |
# File '../../src/modules/LanItems.rb', line 2588 publish_variable :bond_slaves , "list <string>" |
- (string) bootproto
2569 |
# File '../../src/modules/LanItems.rb', line 2569 publish_variable :bootproto , "string" |
- (string) bridge_ports
2592 |
# File '../../src/modules/LanItems.rb', line 2592 publish_variable :bridge_ports , "string" |
- (string) chan_mode
2606 |
# File '../../src/modules/LanItems.rb', line 2606 publish_variable :chan_mode , "string" |
- (integer) current
the index into #Items
2565 |
# File '../../src/modules/LanItems.rb', line 2565 publish_variable :current , "integer" |
- (string) description
2560 |
# File '../../src/modules/LanItems.rb', line 2560 publish_variable :description , "string" |
- (string) device
2562 |
# File '../../src/modules/LanItems.rb', line 2562 publish_variable :device , "string" |
- (map <string, any>) driver_options
2555 |
# File '../../src/modules/LanItems.rb', line 2555 publish_variable :driver_options , "map <string, any>" |
- (string) ethtool_options
2578 |
# File '../../src/modules/LanItems.rb', line 2578 publish_variable :ethtool_options , "string" |
- (boolean) force_restart
2559 |
# File '../../src/modules/LanItems.rb', line 2559 publish_variable :force_restart , "boolean" |
- (list <map>) Hardware
2553 |
# File '../../src/modules/LanItems.rb', line 2553 publish_variable :Hardware , "list <map>" |
- (string) hotplug
2566 |
# File '../../src/modules/LanItems.rb', line 2566 publish_variable :hotplug , "string" |
- (string) ifplugd_priority
2576 |
# File '../../src/modules/LanItems.rb', line 2576 publish_variable :ifplugd_priority , "string" |
- (boolean) ipa_takeover
2608 |
# File '../../src/modules/LanItems.rb', line 2608 publish_variable :ipa_takeover , "boolean" |
- (string) ipaddr
2570 |
# File '../../src/modules/LanItems.rb', line 2570 publish_variable :ipaddr , "string" |
- (Object) ipoib_mode
Returns the value of attribute ipoib_mode
43 44 45 |
# File '../../src/modules/LanItems.rb', line 43 def ipoib_mode @ipoib_mode end |
- (Object) ipoib_modes (readonly)
Returns the value of attribute ipoib_modes
42 43 44 |
# File '../../src/modules/LanItems.rb', line 42 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
2551 |
# File '../../src/modules/LanItems.rb', line 2551 publish_variable :Items , "map <integer, any>" |
- (string) iucv_user
2609 |
# File '../../src/modules/LanItems.rb', line 2609 publish_variable :iucv_user , "string" |
- (string) lcs_timeout
2613 |
# File '../../src/modules/LanItems.rb', line 2613 publish_variable :lcs_timeout , "string" |
- (boolean) modified
2557 |
# File '../../src/modules/LanItems.rb', line 2557 publish_variable :modified , "boolean" |
- (string) mtu
2577 |
# File '../../src/modules/LanItems.rb', line 2577 publish_variable :mtu , "string" |
- (string) netmask
2572 |
# File '../../src/modules/LanItems.rb', line 2572 publish_variable :netmask , "string" |
- (string) nm_name
2619 |
# File '../../src/modules/LanItems.rb', line 2619 publish_variable :nm_name , "string" |
- (boolean) nm_proposal_valid
2618 |
# File '../../src/modules/LanItems.rb', line 2618 publish_variable :nm_proposal_valid , "boolean" |
- (symbol) operation
2558 |
# File '../../src/modules/LanItems.rb', line 2558 publish_variable :operation , "symbol" |
- (string) prefix
2574 |
# File '../../src/modules/LanItems.rb', line 2574 publish_variable :prefix , "string" |
- (boolean) proposal_valid
2617 |
# File '../../src/modules/LanItems.rb', line 2617 publish_variable :proposal_valid , "boolean" |
- (string) qeth_chanids
2612 |
# File '../../src/modules/LanItems.rb', line 2612 publish_variable :qeth_chanids , "string" |
- (boolean) qeth_layer2
2610 |
# File '../../src/modules/LanItems.rb', line 2610 publish_variable :qeth_layer2 , "boolean" |
- (string) qeth_macaddress
2611 |
# File '../../src/modules/LanItems.rb', line 2611 publish_variable :qeth_macaddress , "string" |
- (string) qeth_options
2607 |
# File '../../src/modules/LanItems.rb', line 2607 publish_variable :qeth_options , "string" |
- (string) qeth_portname
2604 |
# File '../../src/modules/LanItems.rb', line 2604 publish_variable :qeth_portname , "string" |
- (string) qeth_portnumber
2605 |
# File '../../src/modules/LanItems.rb', line 2605 publish_variable :qeth_portnumber , "string" |
- (string) remoteip
2571 |
# File '../../src/modules/LanItems.rb', line 2571 publish_variable :remoteip , "string" |
- (list <string>) Requires
2568 |
# File '../../src/modules/LanItems.rb', line 2568 publish_variable :Requires , "list <string>" |
- (boolean) set_default_route
2573 |
# File '../../src/modules/LanItems.rb', line 2573 publish_variable :set_default_route , "boolean" |
- (string) startmode
2575 |
# File '../../src/modules/LanItems.rb', line 2575 publish_variable :startmode , "string" |
- (map <string, string>) SysconfigDefaults
2621 |
# File '../../src/modules/LanItems.rb', line 2621 publish_variable :SysconfigDefaults , "map <string, string>" |
- (string) tunnel_set_group
2616 |
# File '../../src/modules/LanItems.rb', line 2616 publish_variable :tunnel_set_group , "string" |
- (string) tunnel_set_owner
2615 |
# File '../../src/modules/LanItems.rb', line 2615 publish_variable :tunnel_set_owner , "string" |
- (string) type
2561 |
# File '../../src/modules/LanItems.rb', line 2561 publish_variable :type , "string" |
- (map <string, any>) udev_net_rules
2554 |
# File '../../src/modules/LanItems.rb', line 2554 publish_variable :udev_net_rules , "map <string, any>" |
- (string) vlan_etherdevice
2590 |
# File '../../src/modules/LanItems.rb', line 2590 publish_variable :vlan_etherdevice , "string" |
- (string) vlan_id
2591 |
# File '../../src/modules/LanItems.rb', line 2591 publish_variable :vlan_id , "string" |
- (string) wl_accesspoint
2597 |
# File '../../src/modules/LanItems.rb', line 2597 publish_variable :wl_accesspoint , "string" |
- (string) wl_ap_scanmode
2599 |
# File '../../src/modules/LanItems.rb', line 2599 publish_variable :wl_ap_scanmode , "string" |
- (string) wl_auth_mode
2582 |
# File '../../src/modules/LanItems.rb', line 2582 publish_variable :wl_auth_mode , "string" |
- (list <string>) wl_auth_modes
2600 |
# File '../../src/modules/LanItems.rb', line 2600 publish_variable :wl_auth_modes , "list <string>" |
- (string) wl_bitrate
2596 |
# File '../../src/modules/LanItems.rb', line 2596 publish_variable :wl_bitrate , "string" |
- (list <string>) wl_bitrates
2603 |
# File '../../src/modules/LanItems.rb', line 2603 publish_variable :wl_bitrates , "list <string>" |
- (string) wl_channel
2594 |
# File '../../src/modules/LanItems.rb', line 2594 publish_variable :wl_channel , "string" |
- (list <string>) wl_channels
2602 |
# File '../../src/modules/LanItems.rb', line 2602 publish_variable :wl_channels , "list <string>" |
- (integer) wl_default_key
2586 |
# File '../../src/modules/LanItems.rb', line 2586 publish_variable :wl_default_key , "integer" |
- (list <string>) wl_enc_modes
2601 |
# File '../../src/modules/LanItems.rb', line 2601 publish_variable :wl_enc_modes , "list <string>" |
- (string) wl_essid
2580 |
# File '../../src/modules/LanItems.rb', line 2580 publish_variable :wl_essid , "string" |
- (string) wl_frequency
2595 |
# File '../../src/modules/LanItems.rb', line 2595 publish_variable :wl_frequency , "string" |
- (list <string>) wl_key
2585 |
# File '../../src/modules/LanItems.rb', line 2585 publish_variable :wl_key , "list <string>" |
- (string) wl_key_length
2584 |
# File '../../src/modules/LanItems.rb', line 2584 publish_variable :wl_key_length , "string" |
- (string) wl_mode
2579 |
# File '../../src/modules/LanItems.rb', line 2579 publish_variable :wl_mode , "string" |
- (string) wl_nick
2587 |
# File '../../src/modules/LanItems.rb', line 2587 publish_variable :wl_nick , "string" |
- (string) wl_nwid
2581 |
# File '../../src/modules/LanItems.rb', line 2581 publish_variable :wl_nwid , "string" |
- (boolean) wl_power
2598 |
# File '../../src/modules/LanItems.rb', line 2598 publish_variable :wl_power , "boolean" |
- (map <string, any>) wl_wpa_eap
2593 |
# File '../../src/modules/LanItems.rb', line 2593 publish_variable :wl_wpa_eap , "map <string, any>" |
- (string) wl_wpa_psk
2583 |
# File '../../src/modules/LanItems.rb', line 2583 publish_variable :wl_wpa_psk , "string" |
Instance Method Details
- (Object) AddNew
750 751 752 753 754 755 756 |
# File '../../src/modules/LanItems.rb', line 750 def AddNew @current = @Items.to_h.size @Items[@current] = { "commited" => false } @operation = :add nil end |
- (Object) BuildBondIndex
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
# File '../../src/modules/LanItems.rb', line 1224 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.
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 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 1373 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 1403 1404 1405 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 |
# File '../../src/modules/LanItems.rb', line 1309 def BuildLanOverview overview = [] links = [] Builtins.foreach( Convert.convert( Map.Keys(@Items), :from => "list", :to => "list <integer>" ) ) do |key| rich = "" ip = _("Not configured") item_hwinfo = @Items[key]["hwinfo"] || {} descr = item_hwinfo["name"] || "" note = "" bullets = [] ifcfg_name = @Items[key]["ifcfg"] || "" @type = NetworkInterfaces.GetType(ifcfg_name) if !ifcfg_name.empty? NetworkInterfaces.Select(ifcfg_name) ifcfg_desc = GetDeviceMap(key)["NAME"] descr = ifcfg_desc if !ifcfg_desc.nil? && !ifcfg_desc.empty? descr = CheckEmptyName(@type, descr) ip = DeviceProtocol(NetworkInterfaces.Current) status = DeviceStatus( @type, NetworkInterfaces.device_num(NetworkInterfaces.Name), NetworkInterfaces.Current ) bullets << _("Device Name: %s") % ifcfg_name bullets = bullets + startmode_overview bullets = bullets + ip_overview(ip) if NetworkInterfaces.Current["STARTMODE"] != "managed" if @type == "wlan" && NetworkInterfaces.Current["WIRELESS_AUTH_MODE"] == "open" && IsEmpty(NetworkInterfaces.Current["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 @type == "bond" bond_slaves_desc = ("%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 = _("enslaved in %s") % bond_master bond_master_desc = ("%s: %s") % [_("Bonding master"), bond_master] bullets << bond_master_desc end if renamed?(key) note = ("%s -> %s") % [GetDeviceName(key), renamed_to(key)] end overview << Summary.Device(descr, status) else descr = CheckEmptyName(@type, descr) overview << Summary.Device(descr, Summary.NotConfigured) end conn = "" conn = HTML.Bold("(%s)" % _("Not connected")) if !item_hwinfo["link"] if item_hwinfo.empty? conn = HTML.Bold("(%s)" % _("No hwinfo")) end mac_dev = HTML.Bold("MAC : ") + item_hwinfo["mac"].to_s + "<br>" bus_id = HTML.Bold("BusID : ") + item_hwinfo["busid"].to_s + "<br>" if IsNotEmpty(item_hwinfo["mac"]) rich << " " << conn << "<br>" << mac_dev end if IsNotEmpty(item_hwinfo["busid"]) rich << bus_id end # 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 << ("%s : %s") % [_("Needed firmware"), !fw.empty? ? fw : _("unknown")] end @current = curr end @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
1894 1895 1896 1897 1898 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 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 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 |
# File '../../src/modules/LanItems.rb', line 1894 def Commit if @operation != :add && @operation != :edit Builtins.y2error("Unknown operation: %1", @operation) raise ArgumentError, "Unknown operation: #{@operation}" end newdev = {} # #104494 - always write IPADDR+NETMASK, even empty Ops.set(newdev, "IPADDR", @ipaddr) if Ops.greater_than(Builtins.size(@prefix), 0) Ops.set(newdev, "PREFIXLEN", @prefix) else Ops.set(newdev, "NETMASK", @netmask) end # #50955 omit computable fields Ops.set(newdev, "BROADCAST", "") Ops.set(newdev, "NETWORK", "") Ops.set(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" i = 0 Builtins.foreach(@bond_slaves) do |slave| Ops.set(newdev, Builtins.sformat("BONDING_SLAVE%1", i), slave) i = Ops.add(i, 1) end #assign nil to rest BONDING_SLAVEn to remove them while Ops.less_than(i, @MAX_BOND_SLAVE) Ops.set(newdev, Builtins.sformat("BONDING_SLAVE%1", i), nil) i = Ops.add(i, 1) end Ops.set(newdev, "BONDING_MODULE_OPTS", @bond_option) #BONDING_MASTER always is yes Ops.set(newdev, "BONDING_MASTER", "yes") when "vlan" Ops.set(newdev, "ETHERDEVICE", @vlan_etherdevice) Ops.set(newdev, "VLAN_ID", @vlan_id) when "br" Ops.set(newdev, "BRIDGE_PORTS", @bridge_ports) Ops.set(newdev, "BRIDGE", "yes") Ops.set(newdev, "BRIDGE_STP", "off") Ops.set(newdev, "BRIDGE_FORWARDDELAY", "0") when "wlan" Ops.set(newdev, "WIRELESS_MODE", @wl_mode) Ops.set(newdev, "WIRELESS_ESSID", @wl_essid) Ops.set(newdev, "WIRELESS_NWID", @wl_nwid) Ops.set(newdev, "WIRELESS_AUTH_MODE", @wl_auth_mode) Ops.set(newdev, "WIRELESS_WPA_PSK", @wl_wpa_psk) Ops.set(newdev, "WIRELESS_KEY_LENGTH", @wl_key_length) # obsoleted by WIRELESS_KEY_0 Ops.set(newdev, "WIRELESS_KEY", "") # TODO: delete the varlable Ops.set(newdev, "WIRELESS_KEY_0", Ops.get(@wl_key, 0, "")) Ops.set(newdev, "WIRELESS_KEY_1", Ops.get(@wl_key, 1, "")) Ops.set(newdev, "WIRELESS_KEY_2", Ops.get(@wl_key, 2, "")) Ops.set(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 Ops.set(newdev, "WIRELESS_CHANNEL", @wl_channel) Ops.set(newdev, "WIRELESS_FREQUENCY", @wl_frequency) Ops.set(newdev, "WIRELESS_BITRATE", @wl_bitrate) Ops.set(newdev, "WIRELESS_AP", @wl_accesspoint) Ops.set(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 Builtins.contains(["tun", "tap"], @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 Ops.set(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
2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 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 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 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 |
# File '../../src/modules/LanItems.rb', line 2400 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 = Ops.greater_than( Builtins.size(@qeth_portnumber), 0 ) ? Builtins.sformat("-n %1", @qeth_portnumber) : "" @portname_param = Ops.greater_than(Builtins.size(@qeth_portname), 0) ? Builtins.sformat("-p %1", @qeth_portname) : "" @options_param = Ops.greater_than(Builtins.size(@qeth_options), 0) ? Builtins.sformat("-o %1", @qeth_options) : "" 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?
593 594 595 |
# File '../../src/modules/LanItems.rb', line 593 def current_renamed? renamed?(@current) end |
- (Object) current_renamed_to
583 584 585 |
# File '../../src/modules/LanItems.rb', line 583 def current_renamed_to renamed_to(@current) end |
- (Object) current_udev_name
Returns name which is going to be used in the udev rule
348 349 350 351 352 353 354 |
# File '../../src/modules/LanItems.rb', line 348 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
2275 2276 2277 2278 |
# File '../../src/modules/LanItems.rb', line 2275 def delete_dev(name) FindAndSelect(name) DeleteItem() end |
- (Object) DeleteItem
Deletes the #current item and its configuration
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 |
# File '../../src/modules/LanItems.rb', line 2281 def DeleteItem return if @current < 0 return if @Items.nil? || @Items.empty? log.info("DeleteItem: #{@Items[@current]}") if IsCurrentConfigured() SetCurrentName("") NetworkInterfaces.Commit end 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
2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 |
# File '../../src/modules/LanItems.rb', line 2386 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)
951 952 953 |
# File '../../src/modules/LanItems.rb', line 951 def find_configured(device) @Items.select { |k,v| v["ifcfg"] == device }.keys.first end |
- (Object) FindAndSelect(device)
955 956 957 958 959 960 |
# File '../../src/modules/LanItems.rb', line 955 def FindAndSelect(device) item_id = find_configured(device) @current = item_id if item_id return !item_id.nil? end |
- (Object) FindDeviceIndex(device)
search all known devices to find it's index in Items array
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
# File '../../src/modules/LanItems.rb', line 966 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
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 2175 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 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 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 |
# File '../../src/modules/LanItems.rb', line 2144 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
1609 1610 1611 1612 1613 1614 |
# File '../../src/modules/LanItems.rb', line 1609 def FreeAliases(type, num) # FIXME: NI y2debug("Devices=%1", Devices); _Devices_1 = {} # FIXME: NI Devices[type, sformat("%1",num)]:$[]; Builtins.y2debug("Devices=%1", _Devices_1) NetworkInterfaces.GetFreeDevices("_aliases", 10) end |
- (Array) FreeDevices(type)
Return 10 free devices
1601 1602 1603 |
# File '../../src/modules/LanItems.rb', line 1601 def FreeDevices(type) NetworkInterfaces.GetFreeDevices(type, 10) end |
- (Object) GetBondableInterfaces(bondMaster)
Creates list of items (interfaces) which can be used as a bond slave.
909 910 911 912 913 914 |
# File '../../src/modules/LanItems.rb', line 909 def GetBondableInterfaces(bondMaster) GetSlaveCandidates( bondMaster, fun_ref(method(:IsBondable), "boolean (string, integer)") ) end |
- (Object) GetBondSlaves(bond_master)
Creates list of devices enslaved in any bond device.
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
# File '../../src/modules/LanItems.rb', line 1200 def GetBondSlaves(bond_master) slaves = [] slave_index = 0 while Ops.less_than(slave_index, @MAX_BOND_SLAVE) slave = Ops.get_string( NetworkInterfaces.FilterDevices("netcard"), [ "bond", bond_master, Builtins.sformat("BONDING_SLAVE%1", slave_index) ], "" ) if Ops.greater_than(Builtins.size(slave), 0) slaves = Builtins.add(slaves, slave) end slave_index = Ops.add(slave_index, 1) end deep_copy(slaves) end |
- (Object) GetBridgeableInterfaces(bridgeMaster)
Creates list of items (interfaces) which can be used as a bridge slave.
920 921 922 923 924 925 |
# File '../../src/modules/LanItems.rb', line 920 def GetBridgeableInterfaces(bridgeMaster) GetSlaveCandidates( bridgeMaster, fun_ref(method(:IsBridgeable), "boolean (string, integer)") ) end |
- (Object) getCurrentItem
Returns configuration for currently modified item.
314 315 316 |
# File '../../src/modules/LanItems.rb', line 314 def getCurrentItem GetLanItem(@current) end |
- (Object) GetCurrentMap
394 395 396 |
# File '../../src/modules/LanItems.rb', line 394 def GetCurrentMap GetDeviceMap(@current) end |
- (Object) GetCurrentName
Returns device name for current lan item (see LanItems::current)
366 367 368 |
# File '../../src/modules/LanItems.rb', line 366 def GetCurrentName GetDeviceName(@current) end |
- (Object) GetCurrentType
Returns device type for current lan item (see LanItems::current)
376 377 378 |
# File '../../src/modules/LanItems.rb', line 376 def GetCurrentType GetDeviceType(@current) end |
- (Object) GetDefaultsForHW
must be in sync with #SetDefaultsForHW
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 |
# File '../../src/modules/LanItems.rb', line 1618 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
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File '../../src/modules/LanItems.rb', line 1099 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
381 382 383 384 385 386 387 388 389 390 391 392 |
# File '../../src/modules/LanItems.rb', line 381 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.
337 338 339 340 341 342 343 344 345 |
# File '../../src/modules/LanItems.rb', line 337 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") return "" # 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
359 360 361 362 363 |
# File '../../src/modules/LanItems.rb', line 359 def GetDeviceNames( items) return [] unless items items.map { |itemId| GetDeviceName( itemId) }.reject( &:empty?) end |
- (Object) GetDeviceType(itemId)
Returns device type for particular lan item
371 372 373 |
# File '../../src/modules/LanItems.rb', line 371 def GetDeviceType(itemId) NetworkInterfaces.GetType(GetDeviceName(itemId)) end |
- (Object) GetFirmwareForCurrentItem
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
# File '../../src/modules/LanItems.rb', line 1163 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
1466 1467 1468 |
# File '../../src/modules/LanItems.rb', line 1466 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)
762 763 764 765 766 767 768 769 770 771 772 |
# File '../../src/modules/LanItems.rb', line 762 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)
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File '../../src/modules/LanItems.rb', line 480 def GetItemUdev(key) value = "" Builtins.foreach(getUdevFallback) do |row| if Builtins.issubstring(row, key) items = Builtins.filter(Builtins.splitstring(row, "=")) do |s| Ops.greater_than(Builtins.size(s), 0) end if Builtins.size(items) == 2 && Ops.get_string(items, 0, "") == key value = Builtins.deletechars(Ops.get_string(items, 1, ""), "\"") else Builtins.y2warning( "udev items %1 doesn't match the key %2", items, key ) end end end value end |
- (Object) GetItemUdevRule(itemId)
Returns udev rule known for particular item
421 422 423 |
# File '../../src/modules/LanItems.rb', line 421 def GetItemUdevRule(itemId) Ops.get_list(GetLanItem(itemId), ["udev", "net"], []) end |
- (Object) GetLanItem(itemId)
Returns configuration of item (see LanItems::Items) with given id.
309 310 311 |
# File '../../src/modules/LanItems.rb', line 309 def GetLanItem(itemId) Ops.get_map(@Items, itemId, {}) end |
- (Boolean) GetModified
Function which returns if the settings were modified
732 733 734 |
# File '../../src/modules/LanItems.rb', line 732 def GetModified @modified end |
- (Hash) GetModuleForInterface(ay_device, ay_modules)
Get the module configuration for the modules configured in the interface section
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 |
# File '../../src/modules/LanItems.rb', line 2125 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
931 932 933 |
# File '../../src/modules/LanItems.rb', line 931 def GetNetcardInterfaces @Items.keys end |
- (Object) GetNetcardNames
Creates list of names of all known netcards configured even unconfigured
936 937 938 |
# File '../../src/modules/LanItems.rb', line 936 def GetNetcardNames GetDeviceNames( GetNetcardInterfaces()) end |
- (Object) getNetworkInterfaces
get list of all configurations for “netcard” macro in NetworkInterfaces module
941 942 943 944 945 946 947 948 949 |
# File '../../src/modules/LanItems.rb', line 941 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.
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# File '../../src/modules/LanItems.rb', line 872 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
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File '../../src/modules/LanItems.rb', line 463 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?
1774 1775 1776 |
# File '../../src/modules/LanItems.rb', line 1774 def hotplug_usable? true unless Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "").empty? end |
- (Object) InitS390VarsByDefaults
1768 1769 1770 1771 1772 |
# File '../../src/modules/LanItems.rb', line 1768 def InitS390VarsByDefaults SetS390Vars({}, @s390_defaults) nil end |
- (Object) ip_overview(ip)
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 1303 1304 |
# File '../../src/modules/LanItems.rb', line 1276 def ip_overview(ip) bullets = [] case ip when "NONE", "" # do nothing when /DHCP/ bullets << ("%s %s") % [_("IP address assigned using"), ip] else prefixlen = NetworkInterfaces.Current["PREFIXLEN"] if prefixlen bullets << _("IP address: %s/%s") % [ip, prefixlen] else subnetmask = NetworkInterfaces.Current["NETMASK"] bullets << _("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 = "%s/%s" % [desc["IPADDR"], desc["PREFIXLEN"]] bullets << ("%s (%s)") % [desc["LABEL"], parameters] end end return 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.
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
# File '../../src/modules/LanItems.rb', line 782 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 = 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 = 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.
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File '../../src/modules/LanItems.rb', line 824 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
329 330 331 |
# File '../../src/modules/LanItems.rb', line 329 def IsCurrentConfigured IsItemConfigured(@current) end |
- (Object) isCurrentDHCP
Check if currently edited device gets its IP address from DHCP (v4, v6 or both)
1462 1463 1464 |
# File '../../src/modules/LanItems.rb', line 1462 def isCurrentDHCP Builtins.regexpmatch(@bootproto, "dhcp[46]?") end |
- (Object) isCurrentHotplug
Is current device hotplug or not? I.e. is connected via usb/pcmci?
1450 1451 1452 1453 1454 1455 1456 1457 |
# File '../../src/modules/LanItems.rb', line 1450 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.
320 321 322 323 324 325 |
# File '../../src/modules/LanItems.rb', line 320 def IsItemConfigured(itemId) ret = !GetLanItem(itemId)["ifcfg"].to_s.empty? log.info("IsItemConfigured: item=#{itemId} configured=#{ret}") return ret end |
- (Object) main
47 48 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 304 305 306 |
# File '../../src/modules/LanItems.rb', line 47 def main Yast.import "UI" textdomain "network" Yast.import "NetworkInterfaces" Yast.import "ProductFeatures" Yast.import "NetworkConfig" Yast.import "NetworkStorage" Yast.import "Storage" 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" # Hardware information # @see #ReadHardware @Items = {} @Hardware = [] @udev_net_rules = {} @driver_options = {} # used at autoinstallation time @autoinstall_settings = {} # Data was modified? @modified = false # 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 = "" @MAX_BOND_SLAVE = 10 # 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", "rt73usb" => "ralink-firmware", "rt61pci" => "ralink-firmware", "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_CLIENT_CERT" => "", "WIRELESS_CA_CERT" => "", "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
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 |
# File '../../src/modules/LanItems.rb', line 1134 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
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
# File '../../src/modules/LanItems.rb', line 1789 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
1816 1817 1818 1819 1820 1821 1822 1823 1824 |
# File '../../src/modules/LanItems.rb', line 1816 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
1444 1445 1446 1447 |
# File '../../src/modules/LanItems.rb', line 1444 def Overview BuildLanOverview() GetDescr() end |
- (Object) ProposeItem
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 |
# File '../../src/modules/LanItems.rb', line 2342 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.
1045 1046 1047 1048 1049 1050 1051 1052 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 |
# File '../../src/modules/LanItems.rb', line 1045 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
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File '../../src/modules/LanItems.rb', line 986 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 = Ops.get_string(hwitem, "dev_name", "") != "" ? Ops.get_list( @udev_net_rules, Ops.get_string(hwitem, "dev_name", ""), [] ) : [] 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
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File '../../src/modules/LanItems.rb', line 425 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, ""), Ops.greater_than( Builtins.size(Ops.get_string(@driver_options, driver, "")), 0 ) ? " " : "", key, value ) ) end end true end |
- (Object) rename(name)
Sets new device name for current item
570 571 572 573 574 575 576 |
# File '../../src/modules/LanItems.rb', line 570 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
588 589 590 591 |
# File '../../src/modules/LanItems.rb', line 588 def renamed?(item_id) return false if !@Items[item_id].has_key?("renamed_to") renamed_to(item_id) != GetDeviceName(item_id) end |
- (Object) renamed_to(item_id)
Returns new name for current item
579 580 581 |
# File '../../src/modules/LanItems.rb', line 579 def renamed_to(item_id) @Items[item_id]["renamed_to"] end |
- (Boolean) replace_ifplugd?
1778 1779 1780 1781 1782 1783 1784 |
# File '../../src/modules/LanItems.rb', line 1778 def replace_ifplugd? return true if !Arch.is_laptop return true if NetworkService.is_network_manager return true if ["bond", "vlan", "br"].include? type return false end |
- (Object) ReplaceItemUdev(replace_key, new_key, new_val)
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File '../../src/modules/LanItems.rb', line 502 def ReplaceItemUdev(replace_key, new_key, new_val) new_rules = [] # udev syntax distinguishes among others: # = for assignment # == for equality checks operator = new_key == "NAME" ? "=" : "==" Builtins.foreach(getUdevFallback) do |row| if Builtins.issubstring(row, replace_key) row = Builtins.sformat("%1%2\"%3\"", new_key, operator, new_val) end new_rules = Builtins.add(new_rules, row) end Builtins.y2debug( "LanItems::ReplaceItemUdev: udev rules %1", Ops.get_list(@Items, [@current, "udev", "net"], []) ) Ops.set(@Items, [@current, "udev", "net"], new_rules) Builtins.y2debug( "LanItems::ReplaceItemUdev(%1, %2, %3) %4", replace_key, new_key, new_val, new_rules ) deep_copy(new_rules) end |
- (Object) Rollback
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 |
# File '../../src/modules/LanItems.rb', line 2093 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 “”
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 |
# File '../../src/modules/LanItems.rb', line 1830 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
1587 1588 1589 1590 1591 |
# File '../../src/modules/LanItems.rb', line 1587 def SelectHW(which) SelectHWMap(FindHardware(@Hardware, which)) nil end |
- (Object) SelectHWMap(hardware)
Select the hardware component
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 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 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 |
# File '../../src/modules/LanItems.rb', line 1472 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>" ) busid = Ops.get_string(hardware, "busid", "") 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
565 566 567 |
# File '../../src/modules/LanItems.rb', line 565 def SetCurrentName( name) SetItemName( @current, name) end |
- (Object) SetDefaultsForHW
must be in sync with #GetDefaultsForHW
1636 1637 1638 1639 1640 1641 1642 1643 |
# File '../../src/modules/LanItems.rb', line 1636 def SetDefaultsForHW Builtins.y2milestone("SetDefaultsForHW type %1", @type) if Arch.s390 && Builtins.contains(["lcs", "eth"], @type) @mtu = "1492" end 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
402 403 404 405 406 407 |
# File '../../src/modules/LanItems.rb', line 402 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.
1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 |
# File '../../src/modules/LanItems.rb', line 1649 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"; true when "no"; false # all other values! count as unspecified else nil 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"] ] if (@wl_key[0] || "").empty? @wl_key[0] = d["WIRELESS_KEY"] end @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)
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 |
# File '../../src/modules/LanItems.rb', line 2371 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
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 |
# File '../../src/modules/LanItems.rb', line 2310 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
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File '../../src/modules/LanItems.rb', line 541 def SetItemName( itemId, name) if name && !name.empty? updated_rule = update_udev_rule_key(GetItemUdevRule(itemId), "NAME", name) @Items[itemId]["udev"]["net"] = updated_rule else # rewrite rule for empty name is meaningless @Items[itemId].delete("udev") end if @Items[ itemId].has_key?( "ifcfg") NetworkInterfaces.Delete2( @Items[ itemId][ "ifcfg"]) @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
412 413 414 415 416 417 418 |
# File '../../src/modules/LanItems.rb', line 412 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”
737 738 739 740 741 |
# File '../../src/modules/LanItems.rb', line 737 def SetModified @modified = true nil end |
- (Object) SetS390Vars(devmap, defaults)
Initializes s390 specific device variables.
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 |
# File '../../src/modules/LanItems.rb', line 1738 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
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 |
# File '../../src/modules/LanItems.rb', line 1877 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 |
- (Object) setup_dhclient_options(devmap)
Sets device map items related to dhclient
1869 1870 1871 1872 1873 1874 |
# File '../../src/modules/LanItems.rb', line 1869 def (devmap) if isCurrentDHCP devmap["DHCLIENT_SET_DEFAULT_ROUTE"] = TRISTATE_TO_S.fetch(@set_default_route) end return devmap end |
- (Object) startmode_overview
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
# File '../../src/modules/LanItems.rb', line 1243 def startmode_overview 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" ) } startmode_descr = startmode_descrs[NetworkInterfaces.Current["STARTMODE"].to_s] || _("Started manually") return [startmode_descr] end |
- (Object) UnsetModified
Function sets internal variable, which indicates, that any settings were modified, to “false”
744 745 746 747 748 |
# File '../../src/modules/LanItems.rb', line 744 def UnsetModified @modified = false nil end |
- (Object) write
717 718 719 720 721 722 723 724 725 726 727 728 |
# File '../../src/modules/LanItems.rb', line 717 def write renamed_items = @Items.keys.select { |item_id| renamed?(item_id) } renamed_items.each do |item_id| NetworkInterfaces.Change2(renamed_to(item_id), GetDeviceMap(item_id), false) SetItemName(item_id, renamed_to(item_id)) end LanItems.WriteUdevRules if !Mode.autoinst && LanUdevAuto.AllowUdevModify # FIXME: hack: no "netcard" filter as biosdevname names it diferently (bnc#712232) NetworkInterfaces.Write("") end |
- (Object) WriteUdevDriverRules
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File '../../src/modules/LanItems.rb', line 650 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.
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File '../../src/modules/LanItems.rb', line 600 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") SetLinkDown(dev_name) @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) SCR.Write(path(".udev_persistent.rules"), net_rules) SCR.Write(path(".udev_persistent.nil"), []) SCR.Execute(path(".target.bash"), "udevadm control --reload") # When configuring a new s390 card, we neglect to fill # its Items[i, "udev", "net"], causing jumbled names (bnc#721520) # The udev trigger will will make udev write the persistent names # (which it already has done, but we have overwritten them now). SCR.Execute( path(".target.bash"), "udevadm trigger --subsystem-match=net --action=add" ) true end |
- (Object) WriteUdevRules
704 705 706 707 708 709 710 711 712 713 714 715 |
# File '../../src/modules/LanItems.rb', line 704 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 |