浏览代码

Fix missing TYPE argument and value in ifcfg files

Handle cases where TYPE is present but empty, as well as when TYPE is missing entirely from the ifcfg file.
Also including the case sensitive coverage and preventing any dict unexpected behaviors.
Emilian Bogdan 7 月之前
父节点
当前提交
51618e102f
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      coriolis/osmorphing/netpreserver/ifcfg.py

+ 5 - 1
coriolis/osmorphing/netpreserver/ifcfg.py

@@ -52,6 +52,10 @@ class IfcfgNetPreserver(base.BaseNetPreserver):
         ifcfgs = []
         for ifcfg_file in self._get_net_config_files(network_scripts_path):
             ifcfg = self.osmorphing_tool._read_config_file_sudo(ifcfg_file)
-            if ifcfg.get("TYPE") == ifcfg_type:
+            detected_type = ifcfg.get('TYPE')
+            if not detected_type:
+                detected_type = "Ethernet"
+                ifcfg["TYPE"] = detected_type
+            if detected_type.lower() == ifcfg_type.lower():
                 ifcfgs.append((ifcfg_file, ifcfg))
         return ifcfgs