Skip to content
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

[WIP] vmware_vmkernel: Requirements in argument_spec #2295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/2295-vmware_vmkernel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- vmware_vmkernel - Improve handling of option dependencies
(https://github.com/ansible-collections/community.vmware/pull/2295).
17 changes: 6 additions & 11 deletions plugins/modules/vmware_vmkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
ip_address:
type: str
description:
- Static IP address.
- Static IPv4 address.
- Required if O(network.type=static).
subnet_mask:
type: str
description:
- Static netmask required.
- Static IPv4 netmask.
- Required if O(network.type=static).
default_gateway:
type: str
description: Default gateway (Override default gateway for this adapter).
description: Default IPv4 gateway (Override default gateway for this adapter).
tcpip_stack:
type: str
description:
Expand Down Expand Up @@ -324,14 +324,6 @@ def __init__(self, module):
msg="Failed to get details of ESXi server. Please specify esxi_hostname."
)

if self.network_type == 'static':
if self.module.params['state'] == 'absent':
pass
elif not self.ip_address:
module.fail_json(msg="ip_address is a required parameter when network type is set to 'static'")
elif not self.subnet_mask:
module.fail_json(msg="subnet_mask is a required parameter when network type is set to 'static'")

# find Port Group
if self.vswitch_name:
self.port_group_obj = self.get_port_group_by_name(
Expand Down Expand Up @@ -1119,6 +1111,9 @@ def main():
type='static',
tcpip_stack='default',
),
required_if=[
('type', 'static', ('ip_address', 'subnet_mask'))
],
),
state=dict(
type='str',
Expand Down
Loading