147. NetworkInterfaces

Interface manipulation (/etc/sysconfig/network/ifcfg-*)

147.1. Authors

  • Michal Svec <msvec@suse.cz>

147.2. Summary of Module Globals

List of Global Functions

  • Add - Add a new device

  • CanonicalizeIP - Canonicalize netmask data (#46885) Sysconfig allows: IPADDR=10.0.0.1/8 IPADDR=10.0.0.1 PREFIXLEN=8 IPADDR=10.0.0.1 NETMASK=255.0.0.0 (IPADDR overrides PREFIXLEN, NETMASK used only if prefix length unspecified) If prefix length and NETMASK are unspecified, 32 is implied. Canonicalize it to IPADDR=10.0.0.1 PREFIXLEN= NETMASK=255.0.0.0

  • CanonicalizeStartmode - STARTMODE: onboot, on and boot are aliases for auto

  • Check - Check presence of the device (alias)

  • CleanCacheRead - re-read all settings again from system for creating new proposal from scratch (#170558)

  • CleanHotplugSymlink - Clean the hotplug devices compatibility symlink, usually ifcfg-eth-pcmcia -> ifcfg-eth-pcmcia-0.

  • ConcealSecrets - Conceal secret information, such as WEP keys, so that the output can be passed to y2log and bugzilla. (#65741)

  • ConcealSecrets1 - Conceal secret information, such as WEP keys, so that the output can be passed to y2log and bugzilla.

  • Delete - Delete the given device

  • DeleteAlias - Add the alias to the list of deleted items. Called when exiting from the aliases-of-device dialog. #48191

  • Edit - Edit the given device

  • Export - Export data

  • Fastest - Find the fastest available device

  • FilterDevices - Used in BuildSummary, BuildOverview

  • GetDevTypeDescription - Return textual device type

  • GetDeviceType - Return device type in human readable form :-)

  • GetDeviceTypes - Return supported network device types (for type netcard) for this hardware

  • GetFreeDevice - Return free device

  • GetFreeDevicesOld - Compute free devices

  • GetIP - get IP addres + additional IP addresses

  • HasAliases - Check if the given device has any virtual alias.

  • Import - Import data

  • IsConnected - Test whether device is connected (Link:up) The info is taken from sysfs

  • IsHotplug - Test hotplugability of a device

  • List - Get devices of the given type

  • ListDevicesExcept - list of all devices except given one by parameter dev also loopback is ommited

  • Locate - Locate devices of the given type and value

  • LocateNOT - Locate devices of the given type and value

  • LocateProvider - Check if any device is using the specified provider

  • Modified - Were the devices changed?

  • Push - DSL needs to save its config while the underlying network card is being configured.

  • Read - Read devices from files

  • RealType - Return real type of the device (incl. PCMCIA, USB, ...)

  • Select - Select the given device

  • UpdateModemSymlink - Update /dev/modem symlink

  • ValidCharsIfcfg - #46803: forbid "/" (filename), maybe also "-" (separator) "_" (escape)

  • Write - Write devices to files

  • alias_name - Create a alias name from its type and numbers

  • alias_num - Return a device alias number

  • device_name - Create a device name from its type and number

  • device_num - Return a device number

  • device_type - Return a device type

List of Global Variables

  • CardRegex - Predefined network card regular expressions

  • Current - Current device information

  • DeviceRegex - Predefined network device regular expressions

  • Name - Current device identifier

  • report_every_check - False suppresses tones of logs 'NetworkInterfaces.ycp:ABC Check(eth,id-00:aa:bb:cc:dd:ee,)'

147.3. Global Functions

147.3.1. Add

Add a new device

Return value

  • boolean - true if success

147.3.2. CanonicalizeIP

Canonicalize netmask data (#46885) Sysconfig allows: IPADDR=10.0.0.1/8 IPADDR=10.0.0.1 PREFIXLEN=8 IPADDR=10.0.0.1 NETMASK=255.0.0.0 (IPADDR overrides PREFIXLEN, NETMASK used only if prefix length unspecified) If prefix length and NETMASK are unspecified, 32 is implied. Canonicalize it to IPADDR=10.0.0.1 PREFIXLEN= NETMASK=255.0.0.0

Function parameters

  • map<string, any> ifcfg

Return value

  • map<string, any> - the map with IPADDR, NETMASK adjusted; PREFIXLEN "" others unchanged. If IPADDR is empty, return the original.

147.3.3. CanonicalizeStartmode

STARTMODE: onboot, on and boot are aliases for auto

Function parameters

  • map<string, any> ifcfg

Return value

  • map<string, any>

147.3.4. Check

Check presence of the device (alias)

Function parameters

  • string dev

Return value

  • boolean - true if device is present

147.3.5. CleanCacheRead

re-read all settings again from system for creating new proposal from scratch (#170558)

Return value

  • boolean

147.3.6. CleanHotplugSymlink

Clean the hotplug devices compatibility symlink, usually ifcfg-eth-pcmcia -> ifcfg-eth-pcmcia-0.

Return value

  • boolean - true if success

147.3.7. ConcealSecrets

Conceal secret information, such as WEP keys, so that the output can be passed to y2log and bugzilla. (#65741)

Function parameters

  • map devs

Return value

  • map - ifcfgs with secret fields masked out

147.3.8. ConcealSecrets1

Conceal secret information, such as WEP keys, so that the output can be passed to y2log and bugzilla.

Function parameters

  • map<string, any> ifcfg

Return value

  • map - ifcfg with secret fields masked out

147.3.9. Delete

Delete the given device

Function parameters

  • string name

Return value

  • boolean - true if success

147.3.10. DeleteAlias

Add the alias to the list of deleted items. Called when exiting from the aliases-of-device dialog. #48191

Function parameters

  • string device

  • string aid

Return value

  • boolean

147.3.11. Edit

Edit the given device

Function parameters

  • string name

Return value

  • boolean - true if success

147.3.12. Export

Export data

Function parameters

  • string devregex

Return value

  • map<string,map> - dumped settings (later acceptable by Import())

147.3.13. Fastest

Find the fastest available device

Return value

  • string

147.3.14. FilterDevices

Used in BuildSummary, BuildOverview

Function parameters

  • string devregex

Return value

  • map<string,map>

147.3.15. GetDevTypeDescription

Return textual device type

Function parameters

  • string type

  • boolean longdescr

Return value

  • string - textual form of device type

Example 26. 

 GetDevTypeDescription("eth", false) -> "Ethernet"
 GetDevTypeDescription("eth", true)  -> "Ethernet Network Card"


147.3.16. GetDeviceType

Return device type in human readable form :-)

Function parameters

  • string dev

Return value

  • string - device type

Example 27. 

 GetDeviceType(eth-bus-pci-0000:01:07.0) -> "Network Card"
 GetDeviceType(modem0) -> "Modem"


147.3.17. GetDeviceTypes

Return supported network device types (for type netcard) for this hardware

Return value

  • list<string>

147.3.18. GetFreeDevice

Return free device

Function parameters

  • string type

Return value

  • string - free device

Example 28. 

 GetFreeDevice("eth") -&gt; "1"


147.3.19. GetFreeDevicesOld

Compute free devices

Function parameters

  • string type

  • integer num

Return value

  • list - num of free devices

Example 29. 

 GetFreeDevices("eth", 2) -&gt; [ 1, 2 ]


147.3.20. GetIP

get IP addres + additional IP addresses

Function parameters

  • string device

Return value

  • list<string> - of IP addresses of selected interface

147.3.21. HasAliases

Check if the given device has any virtual alias.

Function parameters

  • string name

Return value

  • boolean - true if there are some aliases

147.3.22. Import

Import data

Function parameters

  • string devregex

  • map<string,map> devices

Return value

  • boolean - true on success

147.3.23. IsConnected

Test whether device is connected (Link:up) The info is taken from sysfs

Function parameters

  • string dev

Return value

  • boolean - true if connected

147.3.24. IsHotplug

Test hotplugability of a device

Function parameters

  • string type

Return value

  • boolean - true if hotpluggable

147.3.25. List

Get devices of the given type

Function parameters

  • string devregex

Return value

  • list<string> - of found devices

147.3.26. ListDevicesExcept

list of all devices except given one by parameter dev also loopback is ommited

Function parameters

  • string dev

Return value

  • list<string>

147.3.27. Locate

Locate devices of the given type and value

Function parameters

  • string key

  • string val

Return value

  • list<string> - of devices with key=val

147.3.28. LocateNOT

Locate devices of the given type and value

Function parameters

  • string key

  • string val

Return value

  • list<string> - of devices with key!=val

147.3.29. LocateProvider

Check if any device is using the specified provider

Function parameters

  • string provider

Return value

  • boolean - true if there is any

147.3.30. Modified

Were the devices changed?

Function parameters

  • string devregex

Return value

  • boolean - true if modified

147.3.31. Push

DSL needs to save its config while the underlying network card is being configured.

Return value

  • void

147.3.32. Read

Read devices from files

Return value

  • boolean - true if sucess

147.3.33. RealType

Return real type of the device (incl. PCMCIA, USB, ...)

Function parameters

  • string type

  • string hotplug

Return value

  • string - real type

Example 30. 

 RealType("eth", "usb") -> "eth-usb"


147.3.34. Select

Select the given device

Function parameters

  • string name

Return value

  • boolean - true if success

147.3.35. UpdateModemSymlink

Update /dev/modem symlink

Return value

  • boolean - true if success

147.3.36. ValidCharsIfcfg

#46803: forbid "/" (filename), maybe also "-" (separator) "_" (escape)

Return value

  • string

147.3.37. Write

Write devices to files

Function parameters

  • string devregex

Return value

  • boolean - true if success

Example 31. 

 NetworkDevice::Write("eth|tr");


147.3.38. alias_name

Create a alias name from its type and numbers

Function parameters

  • string typ

  • string num

  • string anum

Return value

  • string - alias name

Example 32. 

 alias_name("eth", "1", "2") -> "eth1#2"


147.3.39. alias_num

Return a device alias number

Function parameters

  • string dev

Return value

  • string - alias number

Example 33. 

 alias_num("eth1#2") -> "2"
 alias_num("eth1#blah") -> "blah"


147.3.40. device_name

Create a device name from its type and number

Function parameters

  • string typ

  • string num

Return value

  • string - device name

Example 34. 

 device_name("eth", "1") -> "eth1"
 device_name("lo", "") -> "lo"


147.3.41. device_num

Return a device number

Function parameters

  • string dev

Return value

  • string - device number

Example 35. 

 device_num("eth1") -> "1"
 device_num("lo") -> ""


147.3.42. device_type

Return a device type

Function parameters

  • string dev

Return value

  • string - device type

Example 36. 

 device_type("eth1") -> "eth"
 device_type("eth-pcmcia-0") -> "eth-pcmcia"


147.4. Global Variables

147.4.1. CardRegex

Predefined network card regular expressions

147.4.2. Current

Current device information

147.4.3. DeviceRegex

Predefined network device regular expressions

147.4.4. Name

Current device identifier

147.4.5. report_every_check

False suppresses tones of logs 'NetworkInterfaces.ycp:ABC Check(eth,id-00:aa:bb:cc:dd:ee,)'

147.5. Module Requirements

147.5.1. Module Imports

  • Arch
  • Map
  • Mode
  • Netmask
  • String

147.5.2. Module Includes