Class: Yast::LanItemsClass
- Inherits:
-
Module
- Object
- Module
- Yast::LanItemsClass
- Defined in:
- ../../src/modules/LanItems.rb
Instance Method Summary (collapse)
- - (Object) AddNew
- - (Object) BuildBondIndex
- - (Object) BuildLanOverview
-
- (Object) Commit
Commit pending operation.
- - (Object) createS390Device
- - (Object) DeleteItem
- - (Object) enableCurrentEditButton
- - (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) GetCurrentName
Returns device name 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(itemId)
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) GetDeviceVar(primary, fallback, key)
- - (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.
-
- (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
- - (Object) InitS390VarsByDefaults
-
- (Object) InterfaceHasAliases
Check if the given device has any virtual alias.
-
- (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) 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) ReplaceItemUdev(replace_key, new_key, new_val)
- - (Object) Rollback
-
- (Object) Select(dev)
Select the given device.
-
- (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.
-
- (void) SetDeviceVars(devmap, defaults)
Set various device variables.
- - (Object) setDriver(driver)
- - (Object) SetItem
-
- (Object) SetItemName(itemId, name)
Updates device name.
- - (Object) SetItemUdev(rule_key, rule_val)
-
- (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) UnsetModified
Function sets internal variable, which indicates, that any settings were modified, to “false”.
- - (Object) WriteUdevDriverRules
-
- (Object) WriteUdevItemsRules
Writes udev rules for all items.
- - (Object) WriteUdevRules
Instance Method Details
- (Object) AddNew
644 645 646 647 648 649 650 |
# File '../../src/modules/LanItems.rb', line 644 def AddNew @current = Builtins.size(@Items) Ops.set(@Items, @current, { "commited" => false }) @operation = :add nil end |
- (Object) BuildBondIndex
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 |
# File '../../src/modules/LanItems.rb', line 1136 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
1155 1156 1157 1158 1159 1160 1161 1162 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 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 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 |
# File '../../src/modules/LanItems.rb', line 1155 def BuildLanOverview overview = [] links = [] 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" ) } Builtins.foreach( Convert.convert( Map.Keys(@Items), :from => "list", :to => "list <integer>" ) ) do |key| rich = "" ip = _("Not configured") descr = Ops.get_string(@Items, [key, "hwinfo", "name"], "") dev = "" note = "" @type = Ops.get_string(@Items, [key, "hwinfo", "type"], "") descr = CheckEmptyName(@type, descr) bullets = [] if IsNotEmpty(Ops.get_string(@Items, [key, "ifcfg"], "")) NetworkInterfaces.Select(Ops.get_string(@Items, [key, "ifcfg"], "")) if IsEmpty(@type) @type = NetworkInterfaces.GetType( Ops.get_string(@Items, [key, "ifcfg"], "") ) end descr = BuildDescription( @type, NetworkInterfaces.GetType( Ops.get_string(@Items, [key, "ifcfg"], "") ), NetworkInterfaces.Current, [Ops.get_map(@Items, [key, "hwinfo"], {})] ) dev = NetworkInterfaces.Name #NetworkInterfaces::device_name(type, NetworkInterfaces::Name); ip = DeviceProtocol(NetworkInterfaces.Current) status = DeviceStatus( @type, NetworkInterfaces.device_num(NetworkInterfaces.Name), NetworkInterfaces.Current ) startmode_descr = Ops.get_locale( startmode_descrs, Ops.get_string(NetworkInterfaces.Current, "STARTMODE", ""), _("Started manually") ) bullets = [ Builtins.sformat(_("Device Name: %1"), dev), startmode_descr ] if Ops.get_string(NetworkInterfaces.Current, "STARTMODE", "") != "managed" if ip != "NONE" prefixlen = Ops.get_string( NetworkInterfaces.Current, "PREFIXLEN", "" ) if Ops.greater_than(Builtins.size(ip), 0) descr2 = Builtins.sformat( "%1 %2", _("IP address assigned using"), ip ) if !Builtins.issubstring(ip, "DHCP") descr2 = Ops.greater_than(Builtins.size(prefixlen), 0) ? Builtins.sformat(_("IP address: %1/%2"), ip, prefixlen) : Builtins.sformat( _("IP address: %1, subnet mask %2"), ip, Ops.get_string(NetworkInterfaces.Current, "NETMASK", "") ) end bullets = Ops.add(bullets, [descr2]) end end # build aliases overview if Ops.greater_than( Builtins.size( Ops.get_map(NetworkInterfaces.Current, "_aliases", {}) ), 0 ) && !NetworkService.IsManaged Builtins.foreach( Ops.get_map(NetworkInterfaces.Current, "_aliases", {}) ) do |key2, desc| parameters = Builtins.sformat( "%1/%2", Ops.get_string(desc, "IPADDR", ""), Ops.get_string(desc, "PREFIXLEN", "") ) bullets = Builtins.add( bullets, Builtins.sformat( "%1 (%2)", Ops.get_string(desc, "LABEL", ""), parameters ) ) end end end if @type == "wlan" && !(Ops.get_string( NetworkInterfaces.Current, "WIRELESS_AUTH_MODE", "" ) != "open") && IsEmpty( Ops.get_string(NetworkInterfaces.Current, "WIRELESS_KEY_0", "") ) # avoid colons dev = Builtins.mergestring(Builtins.splitstring(dev, ":"), "/") href = Ops.add("lan--wifi-encryption-", dev) # interface summary: WiFi without encryption warning = HTML.Colorize(_("Warning: no encryption is used."), "red") status = Ops.add( Ops.add(Ops.add(Ops.add(status, " "), warning), " "), # Hyperlink: Change the configuration of an interface Hyperlink(href, _("Change.")) ) links = Builtins.add(links, href) end if @type == "bond" bullets = Builtins.add( bullets, Builtins.sformat( "%1: %2", _("Bonding slaves"), Builtins.mergestring(GetBondSlaves(dev), " ") ) ) end bond_index = BuildBondIndex() bond_master = Ops.get( bond_index, Ops.get_string(@Items, [key, "ifcfg"], ""), "" ) if Ops.greater_than(Builtins.size(bond_master), 0) note = Builtins.sformat(_("enslaved in %1"), bond_master) bullets = Builtins.add( bullets, Builtins.sformat("%1: %2", _("Bonding master"), bond_master) ) end overview = Builtins.add(overview, Summary.Device(descr, status)) else overview = Builtins.add( overview, Summary.Device(descr, Summary.NotConfigured) ) end conn = HTML.Bold( Ops.get_boolean(@Items, [key, "hwinfo", "link"], false) == true ? "" : Builtins.sformat("(%1)", _("Not connected")) ) if Builtins.size(Ops.get_map(@Items, [key, "hwinfo"], {})) == 0 conn = HTML.Bold(Builtins.sformat("(%1)", _("No hwinfo"))) end mac_dev = Ops.add( Ops.add( HTML.Bold("MAC : "), Ops.get_string(@Items, [key, "hwinfo", "mac"], "") ), "<br>" ) bus_id = Ops.add( Ops.add( HTML.Bold("BusID : "), Ops.get_string(@Items, [key, "hwinfo", "busid"], "") ), "<br>" ) if IsNotEmpty(Ops.get_string(@Items, [key, "hwinfo", "mac"], "")) rich = Ops.add(Ops.add(Ops.add(rich, " "), conn), "<br>") rich = Ops.add(rich, mac_dev) end if IsNotEmpty(Ops.get_string(@Items, [key, "hwinfo", "busid"], "")) rich = Ops.add(rich, bus_id) end # display it only if we need it, don't duplicate "dev" above if IsNotEmpty(Ops.get_string(@Items, [key, "hwinfo", "dev_name"], "")) && IsEmpty(Ops.get_string(@Items, [key, "ifcfg"], "")) dev_name = Builtins.sformat( _("Device Name: %1"), Ops.get_string(@Items, [key, "hwinfo", "dev_name"], "") ) dev_name_r = Ops.add(HTML.Bold(dev_name), "<br>") rich = Ops.add(rich, dev_name_r) end rich = Ops.add(HTML.Bold(descr), rich) if IsEmpty(Ops.get_string(@Items, [key, "hwinfo", "dev_name"], "")) && Ops.greater_than( Builtins.size(Ops.get_map(@Items, [key, "hwinfo"], {})), 0 ) && !Arch.s390 rich = Ops.add( rich, _( "<p>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.</p>" ) ) elsif IsNotEmpty(Ops.get_string(@Items, [key, "ifcfg"], "")) rich = Ops.add(rich, HTML.List(bullets)) else rich = Ops.add( rich, _( "<p>The device is not configured. Press <b>Edit</b>\nto configure.</p>\n" ) ) curr = @current @current = key if needFirmwareCurrentItem fw = GetFirmwareForCurrentItem() rich = Ops.add( rich, Builtins.sformat( "%1 : %2", _("Needed firmware"), fw != "" ? fw : _("unknown") ) ) end @current = curr end Ops.set( @Items, [key, "table_descr"], { "rich_descr" => rich, "table_descr" => [descr, ip, dev, note] } ) end [Summary.DevicesList(overview), links] end |
- (Object) Commit
Commit pending operation
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 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 |
# File '../../src/modules/LanItems.rb', line 1914 def Commit if @operation == :add || @operation == :edit 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 if @qeth_layer2 busid = Ops.get_string(@Items, [@current, "hwinfo", "busid"], "") # string sysfs_id = busid_to_sysfs_id(busid, Hardware); # sysfs id has changed from css0... sysfs_id = Ops.add("/devices/qeth/", busid) Builtins.y2milestone("busid %1", busid) if s390_device_needs_persistent_mac(sysfs_id, @Hardware) Ops.set(newdev, "LLADDR", @qeth_macaddress) end end if @alias == "" Ops.set(newdev, "MTU", @mtu) Ops.set(newdev, "ETHTOOL_OPTIONS", @ethtool_options) Ops.set(newdev, "STARTMODE", @startmode) # it is not in Select yet because we don't have a widget for it if @startmode == "ifplugd" if @ifplugd_priority != nil Ops.set(newdev, "IFPLUGD_PRIORITY", @ifplugd_priority) else Ops.set( newdev, "IFPLUGD_PRIORITY", Ops.get(@ifplugd_priorities, @type, "0") ) end end Ops.set(newdev, "USERCONTROL", @usercontrol ? "yes" : "no") Ops.set(newdev, "BOOTPROTO", @bootproto) end Ops.set(newdev, "NAME", @description) Ops.set(newdev, "DHCLIENT_SET_DOWN_LINK", "yes") if @hotplug == "pcmcia" if @type == "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") end if @type == "vlan" Ops.set(newdev, "ETHERDEVICE", @vlan_etherdevice) Ops.set(newdev, "VLAN_ID", @vlan_id) end if @type == "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") end if @type == "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") 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 @alias == "" Ops.set(newdev, "_aliases", @aliases) Builtins.y2milestone("aliases %1", @aliases) end if Builtins.contains(["tun", "tap"], @type) newdev = { "BOOTPROTO" => "static", "STARTMODE" => "auto", "TUNNEL" => @type, "TUNNEL_SET_PERSISTENT" => @tunnel_set_persistent ? "yes" : "no", "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 else Builtins.y2error("Unknown operation: %1", @operation) return false end @modified = true @operation = nil true end |
- (Object) createS390Device
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 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 |
# File '../../src/modules/LanItems.rb', line 2434 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 |
- (Object) DeleteItem
2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 |
# File '../../src/modules/LanItems.rb', line 2307 def DeleteItem Builtins.y2milestone("deleting ... %1", Ops.get_map(@Items, @current, {})) ifcfg = Ops.get_string(@Items, [@current, "ifcfg"], "") hwcfg = Ops.get_string(@Items, [@current, "hwcfg"], "") if IsNotEmpty(ifcfg) NetworkInterfaces.Delete(ifcfg) NetworkInterfaces.Commit Ops.set(@Items, [@current, "ifcfg"], "") end if !Ops.greater_than( Builtins.size(Ops.get_map(@Items, [@current, "hwinfo"], {})), 0 ) tmp_items = {} Builtins.foreach(@Items) do |key, value| if key == @current next else if Ops.less_than(key, @current) Ops.set(tmp_items, key, Ops.get_map(@Items, key, {})) else Ops.set( tmp_items, Ops.subtract(key, 1), Ops.get_map(@Items, key, {}) ) end end end @Items = deep_copy(tmp_items) end SetModified() nil end |
- (Object) enableCurrentEditButton
2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 |
# File '../../src/modules/LanItems.rb', line 2420 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) FindAndSelect(device)
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
# File '../../src/modules/LanItems.rb', line 858 def FindAndSelect(device) found = false Builtins.foreach( Convert.convert( @Items, :from => "map <integer, any>", :to => "map <integer, map <string, any>>" ) ) do |i, a| if Ops.get_string(a, "ifcfg", "") == device found = true @current = i end end found end |
- (Object) FindDeviceIndex(device)
search all known devices to find it's index in Items array
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
# File '../../src/modules/LanItems.rb', line 879 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
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 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 |
# File '../../src/modules/LanItems.rb', line 2179 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
1607 1608 1609 1610 1611 1612 |
# File '../../src/modules/LanItems.rb', line 1607 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
1599 1600 1601 |
# File '../../src/modules/LanItems.rb', line 1599 def FreeDevices(type) NetworkInterfaces.GetFreeDevices(type, 10) end |
- (Object) GetBondableInterfaces(bondMaster)
Creates list of items (interfaces) which can be used as a bond slave.
804 805 806 807 808 809 |
# File '../../src/modules/LanItems.rb', line 804 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.
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
# File '../../src/modules/LanItems.rb', line 1112 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.
815 816 817 818 819 820 |
# File '../../src/modules/LanItems.rb', line 815 def GetBridgeableInterfaces(bridgeMaster) GetSlaveCandidates( bridgeMaster, fun_ref(method(:IsBridgeable), "boolean (string, integer)") ) end |
- (Object) getCurrentItem
Returns configuration for currently modified item.
292 293 294 |
# File '../../src/modules/LanItems.rb', line 292 def getCurrentItem GetLanItem(@current) end |
- (Object) GetCurrentName
Returns device name for current lan item (see LanItems::current)
343 344 345 |
# File '../../src/modules/LanItems.rb', line 343 def GetCurrentName GetDeviceName(@current) end |
- (Object) GetDefaultsForHW
must be in sync with #SetDefaultsForHW
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 |
# File '../../src/modules/LanItems.rb', line 1616 def GetDefaultsForHW ret = {} if @type == "wlan" ret = Builtins.union( ret, # #63767 { "USERCONTROL" => "yes" } ) # 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. elsif 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
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 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
# File '../../src/modules/LanItems.rb', line 1011 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
353 354 355 356 357 358 359 360 361 362 363 364 |
# File '../../src/modules/LanItems.rb', line 353 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(itemId)
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.
323 324 325 326 327 328 329 330 331 |
# File '../../src/modules/LanItems.rb', line 323 def GetDeviceName(itemId) lanItem = GetLanItem(itemId) Ops.get_string( lanItem, "ifcfg", Ops.get_string(lanItem, ["hwinfo", "dev_name"], "") ) end |
- (Object) GetDeviceNames(items)
transforms given list of item ids onto device names
item id is index into internal @Items structure
336 337 338 339 340 |
# File '../../src/modules/LanItems.rb', line 336 def GetDeviceNames( items) return [] unless items items.map { |itemId| GetDeviceName( itemId) }.reject( &:empty?) end |
- (Object) GetDeviceType(itemId)
Returns device type for particular lan item
348 349 350 |
# File '../../src/modules/LanItems.rb', line 348 def GetDeviceType(itemId) NetworkInterfaces.GetType(GetDeviceName(itemId)) end |
- (Object) GetDeviceVar(primary, fallback, key)
1655 1656 1657 1658 1659 1660 1661 |
# File '../../src/modules/LanItems.rb', line 1655 def GetDeviceVar(primary, fallback, key) primary = deep_copy(primary) fallback = deep_copy(fallback) ret = Ops.get_string(primary, key, Ops.get(fallback, key)) Builtins.y2debug("%1 does not have a default defined", key) if ret == nil ret end |
- (Object) GetFirmwareForCurrentItem
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 |
# File '../../src/modules/LanItems.rb', line 1075 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
1453 1454 1455 |
# File '../../src/modules/LanItems.rb', line 1453 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)
656 657 658 659 660 661 662 663 664 665 666 |
# File '../../src/modules/LanItems.rb', line 656 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)
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File '../../src/modules/LanItems.rb', line 427 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
367 368 369 |
# File '../../src/modules/LanItems.rb', line 367 def GetItemUdevRule(itemId) Ops.get_list(GetLanItem(itemId), ["udev", "net"], []) end |
- (Object) GetLanItem(itemId)
Returns configuration of item (see LanItems::Items) with given id.
287 288 289 |
# File '../../src/modules/LanItems.rb', line 287 def GetLanItem(itemId) Ops.get_map(@Items, itemId, {}) end |
- (Boolean) GetModified
Function which returns if the settings were modified
626 627 628 |
# File '../../src/modules/LanItems.rb', line 626 def GetModified @modified end |
- (Hash) GetModuleForInterface(ay_device, ay_modules)
Get the module configuration for the modules configured in the interface section
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
# File '../../src/modules/LanItems.rb', line 2160 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
826 827 828 |
# File '../../src/modules/LanItems.rb', line 826 def GetNetcardInterfaces @Items.keys end |
- (Object) GetNetcardNames
Creates list of names of all known netcards
831 832 833 |
# File '../../src/modules/LanItems.rb', line 831 def GetNetcardNames GetDeviceNames( GetNetcardInterfaces()) end |
- (Object) getNetworkInterfaces
get list of all configurations for “netcard” macro in NetworkInterfaces module
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
# File '../../src/modules/LanItems.rb', line 836 def getNetworkInterfaces confs = [] configurations = NetworkInterfaces.FilterDevices("netcard") Builtins.foreach( Builtins.splitstring( Ops.get(NetworkInterfaces.CardRegex, "netcard", ""), "|" ) ) do |devtype| Builtins.foreach( Convert.convert( Map.Keys(Ops.get_map(configurations, devtype, {})), :from => "list", :to => "list <string>" ) ) { |file| confs = Builtins.add(confs, file) } end deep_copy(confs) end |
- (Array) GetSlaveCandidates(master, validator)
Iterates over all items and lists those for which given validator returns true.
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
# File '../../src/modules/LanItems.rb', line 767 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
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File '../../src/modules/LanItems.rb', line 410 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 |
- (Object) InitS390VarsByDefaults
1822 1823 1824 1825 1826 |
# File '../../src/modules/LanItems.rb', line 1822 def InitS390VarsByDefaults SetS390Vars({}, @s390_defaults) nil end |
- (Object) InterfaceHasAliases
Check if the given device has any virtual alias.
1461 1462 1463 1464 1465 |
# File '../../src/modules/LanItems.rb', line 1461 def InterfaceHasAliases NetworkInterfaces.HasAliases( Ops.get_string(@Items, [@current, "ifcfg"], "") ) 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.
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File '../../src/modules/LanItems.rb', line 676 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.
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File '../../src/modules/LanItems.rb', line 718 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 Ops.get(bonded, devname) != nil Builtins.y2debug( "IsBridgeable: excluding lan item (%1: %2) - is bonded", itemId, devname ) return false end devtype = GetDeviceType(itemId) # exclude forbidden configurations if devtype == "br" Builtins.y2debug( "IsBridgeable: excluding lan item (%1: %2) - is bridge", itemId, devname ) return false end if Ops.get_string(ifcfg, "STARTMODE", "") == "nfsroot" Builtins.y2debug( "IsBridgeable: excluding lan item (%1: %2) - is nfsroot", itemId, devname ) return false end true end |
- (Object) IsCurrentConfigured
Returns true if current (see LanItems::current) has configuration
315 316 317 |
# File '../../src/modules/LanItems.rb', line 315 def IsCurrentConfigured IsItemConfigured(@current) end |
- (Object) isCurrentDHCP
Check if currently edited device gets its IP address from DHCP (v4, v6 or both)
1449 1450 1451 |
# File '../../src/modules/LanItems.rb', line 1449 def isCurrentDHCP Builtins.regexpmatch(@bootproto, "dhcp[46]?") end |
- (Object) isCurrentHotplug
Is current device hotplug or not? I.e. is connected via usb/pcmci?
1437 1438 1439 1440 1441 1442 1443 1444 |
# File '../../src/modules/LanItems.rb', line 1437 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.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File '../../src/modules/LanItems.rb', line 298 def IsItemConfigured(itemId) ret = false if Ops.greater_than( Builtins.size(Ops.get_string(GetLanItem(itemId), "ifcfg", "")), 0 ) ret = true end Builtins.y2milestone("is item %1 configured? %2", itemId, ret) ret end |
- (Object) main
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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 |
# File '../../src/modules/LanItems.rb', line 28 def main Yast.import "UI" textdomain "network" Yast.import "NetworkInterfaces" Yast.import "ProductFeatures" Yast.import "NetworkConfig" Yast.import "NetworkStorage" 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" # 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 = "" #unique - only for backward compatibility #global string unique = ""; @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" @usercontrol = false @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_persistent = true @tunnel_set_owner = "" @tunnel_set_group = "" # propose options @proposal_valid = false @nm_proposal_valid = false # NetworkModules:: name @nm_name = "" @nm_name_old = nil #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" => "", "LLADDR" => "00:00:00:00:00:00", "ETHTOOL_OPTIONS" => "", "NAME" => "", "STARTMODE" => "manual", "IFPLUGD_PRIORITY" => "0", "USERCONTROL" => "no", "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" => "", # aliases = devmap["_aliases"]:$[]; // ? "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" => "", "TUNNEL_SET_PERSISTENT" => "yes" } # 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" => "" } # ifplugd sometimes does not work for wifi # so wired needs higher priority to override it @ifplugd_priorities = { "eth" => "20", "wlan" => "10" } end |
- (Object) needFirmwareCurrentItem
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 |
# File '../../src/modules/LanItems.rb', line 1046 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) Overview
Create an overview table with all configured devices
1431 1432 1433 1434 |
# File '../../src/modules/LanItems.rb', line 1431 def Overview BuildLanOverview() GetDescr() end |
- (Object) ProposeItem
2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 |
# File '../../src/modules/LanItems.rb', line 2376 def ProposeItem Builtins.y2milestone("Propose configuration for %1", getCurrentItem) @operation = nil return false if Select("") != true SetDefaultsForHW() @ipaddr = "" @netmask = "" @bootproto = "dhcp" # #176804 if NetworkStorage.isDiskOnNetwork(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.
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File '../../src/modules/LanItems.rb', line 958 def Read ReadHw() NetworkInterfaces.Read NetworkInterfaces.CleanHotplugSymlink # match configurations to Items list with hwinfo Builtins.foreach(getNetworkInterfaces) 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(getNetworkInterfaces) 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
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 |
# File '../../src/modules/LanItems.rb', line 899 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
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File '../../src/modules/LanItems.rb', line 371 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) # driver_options[driver] = SCR::Read(topath(pth)); 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) ReplaceItemUdev(replace_key, new_key, new_val)
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File '../../src/modules/LanItems.rb', line 449 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
2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 |
# File '../../src/modules/LanItems.rb', line 2128 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
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 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 |
# File '../../src/modules/LanItems.rb', line 1831 def Select(dev) Builtins.y2debug("dev=%1", dev) devmap = {} # defaults for a new device devmap = { # for hotplug devices set STARTMODE=hotplug (#132583) "STARTMODE" => IsNotEmpty( Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "") ) ? "hotplug" : "auto", # #115448, #156388 "NETMASK" => Ops.get_string( NetHwDetection.result, "NETMASK", "255.255.255.0" ) } # #31369 product_startmode = ProductFeatures.GetStringFeature( "network", "startmode" ) if Builtins.contains(["auto", "ifplugd"], product_startmode) Builtins.y2milestone("Product startmode: %1", product_startmode) if product_startmode == "ifplugd" && !Arch.is_laptop # #164816 Builtins.y2milestone("Not a laptop, will not prefer ifplugd") product_startmode = IsNotEmpty( Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "") ) ? "hotplug" : "auto" end if product_startmode == "ifplugd" && NetworkService.IsManaged Builtins.y2milestone("For NetworkManager will not prefer ifplugd") product_startmode = IsNotEmpty( Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "") ) ? "hotplug" : "auto" end if product_startmode == "ifplugd" && Builtins.contains(["bond", "vlan", "br"], @type) Builtins.y2milestone( "For virtual networktypes (bond, bridge, vlan) will not prefer ifplugd" ) product_startmode = IsNotEmpty( Ops.get_string(@Items, [@current, "hwinfo", "hotplug"], "") ) ? "hotplug" : "auto" end Ops.set(devmap, "STARTMODE", product_startmode) end @type = Ops.get_string(@Items, [@current, "hwinfo", "type"], "eth") @device = 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) # We always have to set the MAC Address for qeth Layer2 support if @qeth_layer2 @qeth_macaddress = Ops.get_string(devmap, "LLADDR", "00:00:00:00:00:00") end true end |
- (Object) SelectHW(which)
Select the hardware component
1585 1586 1587 1588 1589 |
# File '../../src/modules/LanItems.rb', line 1585 def SelectHW(which) SelectHWMap(FindHardware(@Hardware, which)) nil end |
- (Object) SelectHWMap(hardware)
Select the hardware component
1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 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 |
# File '../../src/modules/LanItems.rb', line 1469 def SelectHWMap(hardware) hardware = deep_copy(hardware) # sysfs_id = hardware["sysfs_id"]:""; 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.
Returns new name
506 507 508 |
# File '../../src/modules/LanItems.rb', line 506 def SetCurrentName( name) SetItemName( @current, name) end |
- (Object) SetDefaultsForHW
must be in sync with #GetDefaultsForHW
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 |
# File '../../src/modules/LanItems.rb', line 1639 def SetDefaultsForHW Builtins.y2milestone("SetDefaultsForHW type %1", @type) if @type == "wlan" @usercontrol = true elsif Arch.s390 && Builtins.contains(["lcs", "eth"], @type) @mtu = "1492" end # if (!needHwcfg(hw)){ # nm_name_old = nm_name; # nm_name = ""; # } # y2milestone("hwcfg name %1", nm_name); nil end |
- (void) SetDeviceVars(devmap, defaults)
This method returns an undefined value.
Set various device variables
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 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 |
# File '../../src/modules/LanItems.rb', line 1667 def SetDeviceVars(devmap, defaults) devmap = deep_copy(devmap) defaults = deep_copy(defaults) # address options @bootproto = GetDeviceVar(devmap, defaults, "BOOTPROTO") @ipaddr = GetDeviceVar(devmap, defaults, "IPADDR") @prefix = GetDeviceVar(devmap, defaults, "PREFIXLEN") @remoteip = GetDeviceVar(devmap, defaults, "REMOTE_IPADDR") @netmask = GetDeviceVar(devmap, defaults, "NETMASK") @mtu = GetDeviceVar(devmap, defaults, "MTU") @ethtool_options = GetDeviceVar(devmap, defaults, "ETHTOOL_OPTIONS") @startmode = GetDeviceVar(devmap, defaults, "STARTMODE") @ifplugd_priority = GetDeviceVar(devmap, defaults, "IFPLUGD_PRIORITY") @usercontrol = GetDeviceVar(devmap, defaults, "USERCONTROL") == "yes" @description = GetDeviceVar(devmap, defaults, "NAME") @bond_option = GetDeviceVar(devmap, defaults, "BONDING_MODULE_OPTS") @vlan_etherdevice = GetDeviceVar(devmap, defaults, "ETHERDEVICE") @vlan_id = GetDeviceVar(devmap, defaults, "VLAN_ID") # FIXME, remember that it can be implied from the name. probably @bridge_ports = GetDeviceVar(devmap, defaults, "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 = GetDeviceVar(devmap, defaults, "TUNNEL_SET_OWNER") @tunnel_set_group = GetDeviceVar(devmap, defaults, "TUNNEL_SET_GROUP") @tunnel_set_persistent = GetDeviceVar( devmap, defaults, "TUNNEL_SET_PERSISTENT" ) == "yes" # wireless options @wl_mode = GetDeviceVar(devmap, defaults, "WIRELESS_MODE") @wl_essid = GetDeviceVar(devmap, defaults, "WIRELESS_ESSID") @wl_nwid = GetDeviceVar(devmap, defaults, "WIRELESS_NWID") @wl_auth_mode = GetDeviceVar(devmap, defaults, "WIRELESS_AUTH_MODE") @wl_wpa_psk = GetDeviceVar(devmap, defaults, "WIRELESS_WPA_PSK") @wl_key_length = GetDeviceVar(devmap, defaults, "WIRELESS_KEY_LENGTH") @wl_key = [] # ensure exactly 4 entries Ops.set(@wl_key, 0, GetDeviceVar(devmap, defaults, "WIRELESS_KEY_0")) if Ops.get(@wl_key, 0, "") == "" Ops.set(@wl_key, 0, GetDeviceVar(devmap, defaults, "WIRELESS_KEY")) end Ops.set(@wl_key, 1, GetDeviceVar(devmap, defaults, "WIRELESS_KEY_1")) Ops.set(@wl_key, 2, GetDeviceVar(devmap, defaults, "WIRELESS_KEY_2")) Ops.set(@wl_key, 3, GetDeviceVar(devmap, defaults, "WIRELESS_KEY_3")) @wl_default_key = Builtins.tointeger( GetDeviceVar(devmap, defaults, "WIRELESS_DEFAULT_KEY") ) @wl_nick = GetDeviceVar(devmap, defaults, "WIRELESS_NICK") @wl_wpa_eap = {} Ops.set( @wl_wpa_eap, "WPA_EAP_MODE", GetDeviceVar(devmap, defaults, "WIRELESS_EAP_MODE") ) Ops.set( @wl_wpa_eap, "WPA_EAP_IDENTITY", GetDeviceVar(devmap, defaults, "WIRELESS_WPA_IDENTITY") ) Ops.set( @wl_wpa_eap, "WPA_EAP_PASSWORD", GetDeviceVar(devmap, defaults, "WIRELESS_WPA_PASSWORD") ) Ops.set( @wl_wpa_eap, "WPA_EAP_ANONID", GetDeviceVar(devmap, defaults, "WIRELESS_WPA_ANONID") ) Ops.set( @wl_wpa_eap, "WPA_EAP_CLIENT_CERT", GetDeviceVar(devmap, defaults, "WIRELESS_CLIENT_CERT") ) Ops.set( @wl_wpa_eap, "WPA_EAP_CLIENT_KEY", GetDeviceVar(devmap, defaults, "WIRELESS_CLIENT_KEY") ) Ops.set( @wl_wpa_eap, "WPA_EAP_CLIENT_KEY_PASSWORD", GetDeviceVar(devmap, defaults, "WIRELESS_CLIENT_KEY_PASSWORD") ) Ops.set( @wl_wpa_eap, "WPA_EAP_CA_CERT", GetDeviceVar(devmap, defaults, "WIRELESS_CA_CERT") ) Ops.set( @wl_wpa_eap, "WPA_EAP_AUTH", GetDeviceVar(devmap, defaults, "WIRELESS_EAP_AUTH") ) Ops.set( @wl_wpa_eap, "WPA_EAP_PEAP_VERSION", GetDeviceVar(devmap, defaults, "WIRELESS_PEAP_VERSION") ) @wl_channel = GetDeviceVar(devmap, defaults, "WIRELESS_CHANNEL") @wl_frequency = GetDeviceVar(devmap, defaults, "WIRELESS_FREQUENCY") @wl_bitrate = GetDeviceVar(devmap, defaults, "WIRELESS_BITRATE") @wl_accesspoint = GetDeviceVar(devmap, defaults, "WIRELESS_AP") @wl_power = GetDeviceVar(devmap, defaults, "WIRELESS_POWER") == "yes" @wl_ap_scanmode = GetDeviceVar(devmap, defaults, "WIRELESS_AP_SCANMODE") # s/390 options # We always have to set the MAC Address for qeth Layer2 support @qeth_macaddress = GetDeviceVar(devmap, defaults, "LLADDR") @aliases = Ops.get_map(devmap, "_aliases", {}) nil end |
- (Object) setDriver(driver)
2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 |
# File '../../src/modules/LanItems.rb', line 2405 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
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 2370 2371 2372 2373 2374 |
# File '../../src/modules/LanItems.rb', line 2344 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.
Returns new name
490 491 492 493 494 495 496 497 498 499 |
# File '../../src/modules/LanItems.rb', line 490 def SetItemName( itemId, name) SetItemUdev("NAME", name) if @Items[ itemId].has_key?( "ifcfg") NetworkInterfaces.Delete2( @Items[ itemId][ "ifcfg"]) @Items[ itemId][ "ifcfg"] = name end name end |
- (Object) SetItemUdev(rule_key, rule_val)
481 482 483 |
# File '../../src/modules/LanItems.rb', line 481 def SetItemUdev(rule_key, rule_val) ReplaceItemUdev(rule_key, rule_key, rule_val) end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to "true"
631 632 633 634 635 |
# File '../../src/modules/LanItems.rb', line 631 def SetModified @modified = true nil end |
- (Object) SetS390Vars(devmap, defaults)
Initializes s390 specific device variables.
1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 |
# File '../../src/modules/LanItems.rb', line 1799 def SetS390Vars(devmap, defaults) devmap = deep_copy(devmap) defaults = deep_copy(defaults) return if !Arch.s390 @qeth_portname = GetDeviceVar(devmap, defaults, "QETH_PORTNAME") @qeth_portnumber = GetDeviceVar(devmap, defaults, "QETH_PORTNUMBER") @qeth_layer2 = GetDeviceVar(devmap, defaults, "QETH_LAYER2") == "yes" @qeth_chanids = GetDeviceVar(devmap, defaults, "QETH_CHANIDS") # 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) UnsetModified
Function sets internal variable, which indicates, that any settings were modified, to "false"
638 639 640 641 642 |
# File '../../src/modules/LanItems.rb', line 638 def UnsetModified @modified = false nil end |
- (Object) WriteUdevDriverRules
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
# File '../../src/modules/LanItems.rb', line 563 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.
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File '../../src/modules/LanItems.rb', line 513 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
617 618 619 620 621 622 |
# File '../../src/modules/LanItems.rb', line 617 def WriteUdevRules WriteUdevItemsRules() WriteUdevDriverRules() nil end |