Method: Yast::NetworkInterfacesClass#GetTypeFromIfcfg

Defined in:
library/network/src/modules/NetworkInterfaces.rb

#GetTypeFromIfcfg(ifcfg) ⇒ Object

Detects device type according given ifcfg configuration

Returns:

  • device type or nil if type cannot be recognized from ifcfg config



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'library/network/src/modules/NetworkInterfaces.rb', line 288

def GetTypeFromIfcfg(ifcfg)
  ifcfg = deep_copy(ifcfg)
  type = nil

  return nil if IsEmpty(ifcfg)

  Builtins.foreach(@TypeByValueMatch) do |key_type|
    rule_key = Ops.get(key_type, 0, "")
    rule_value = Ops.get(key_type, 1, "")
    rule_type = Ops.get(key_type, 2, "")
    type = rule_type if (ifcfg[rule_key] || "").casecmp?(rule_value)
  end

  Builtins.foreach(@TypeByKeyExistence) do |key_type|
    rule_key = Ops.get(key_type, 0, "")
    rule_type = Ops.get(key_type, 1, "")
    type = rule_type if Ops.get_string(ifcfg, rule_key, "") != ""
  end

  Builtins.foreach(@TypeByKeyValue) do |rule_key|
    rule_type = Ops.get_string(ifcfg, rule_key, "")
    type = rule_type if rule_type != ""
  end

  type
end