-
Notifications
You must be signed in to change notification settings - Fork 58
[Bug] fix(ntnx_subnets_v2): only run remove_empty_ip_config if ip_config isn’t empty #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…nfig when ip_config key is empty
plugins/modules/ntnx_subnets_v2.py
Outdated
| subnets = get_subnet_api_instance(module) | ||
| current_spec = get_subnet(module, subnets, ext_id=ext_id) | ||
| remove_empty_ip_config(current_spec) | ||
| if current_spec.to_dict()['ip_config'] is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we move this check inside remove_empty_ip_config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if empty_ipv6 and empty_ipv4: | ||
| ip_config.remove(item) | ||
| setattr(obj, "ip_config", ip_config) | ||
| if obj.to_dict()['ip_config'] is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if ip_config is not present in obj?
| if empty_ipv6 and empty_ipv4: | ||
| ip_config.remove(item) | ||
| setattr(obj, "ip_config", ip_config) | ||
| if obj.to_dict()['ip_config'] is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if obj.to_dict()['ip_config'] is not None: | |
| ip_config = obj.to_dict().get("ip_config", []) | |
| if len(ip_config)!=0: |
| "$dataItemDiscriminator", | ||
| ] | ||
|
|
||
| ip_config = obj.to_dict().get("ip_config", []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this, if you are using the above suggested change.
|
Hi @ntnx-cpranava , Can you please have a look to the mentioned comments? |
|
Hi @ntnx-cpranava , Can you please have a look to the above mentioned comments? |
Summary:
On update_subnet() in ntnx_subnets_v2.py, previously remove_empty_ip_config(current_spec) was always invoked—even when current_spec.ip_config was None, which triggers errors when subnet does not IPAM features enabled. This commit ensures we only perform this clean‑up when ip_config actually exists.
Changes