Skip to content

Conversation

@BogdanEmilian
Copy link

Handle cases where TYPE is present but empty, as well as when TYPE is missing entirely from the ifcfg file.

NOTE: The case tried before with using ifcfg.get("TYPE", "Ethernet") was not also handling the case where TYPE was missing entirely.

ifcfg = self.osmorphing_tool._read_config_file_sudo(ifcfg_file)
if not ifcfg.get("TYPE"):
ifcfg["TYPE"] = "Ethernet"
if ifcfg.get("TYPE") == ifcfg_type:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the configs may not have case-sensitive values, please also do the following:

Suggested change
if ifcfg.get("TYPE") == ifcfg_type:
if ifcfg.get("TYPE").lower() == ifcfg_type.lower():

for ifcfg_file in self._get_net_config_files(network_scripts_path):
ifcfg = self.osmorphing_tool._read_config_file_sudo(ifcfg_file)
if not ifcfg.get("TYPE"):
ifcfg["TYPE"] = "Ethernet"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also prefer if the ifcfg type is saved in a separate variable, so that we avoid some dict-related bugs when editing this code:

detected_type = ifcfg.get('TYPE')
if not detected_type:
    detected_type = "Ethernet"
if detected_type.lower() == ifcfg_type.lower():
    # ...

@Dany9966
Copy link
Contributor

Please squash the 2 commits into one. After that, we can merge it.

@BogdanEmilian BogdanEmilian force-pushed the fix/ifcfg-missing-type-value branch from f819fc1 to f4741ac Compare January 27, 2026 16:48
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.
@BogdanEmilian BogdanEmilian force-pushed the fix/ifcfg-missing-type-value branch 2 times, most recently from f4741ac to cd5ee5a Compare January 27, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants