Fix missing TYPE value for ifcfg files#385
Open
BogdanEmilian wants to merge 1 commit intocloudbase:masterfrom
Open
Fix missing TYPE value for ifcfg files#385BogdanEmilian wants to merge 1 commit intocloudbase:masterfrom
BogdanEmilian wants to merge 1 commit intocloudbase:masterfrom
Conversation
Dany9966
requested changes
Jan 23, 2026
| ifcfg = self.osmorphing_tool._read_config_file_sudo(ifcfg_file) | ||
| if not ifcfg.get("TYPE"): | ||
| ifcfg["TYPE"] = "Ethernet" | ||
| if ifcfg.get("TYPE") == ifcfg_type: |
Contributor
There was a problem hiding this comment.
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" |
Contributor
There was a problem hiding this comment.
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
approved these changes
Jan 27, 2026
Contributor
|
Please squash the 2 commits into one. After that, we can merge it. |
f819fc1 to
f4741ac
Compare
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.
f4741ac to
cd5ee5a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.