mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vmware_vmkernel: no error on state=absent
The `network.type` parameter is set to default on default on `static`. As a consequence, the network parameter is always defined as `dict`. This patch ensures we don't check the value of the network configuration if we want to delete the interface.
This commit is contained in:
parent
26d38dd642
commit
3095df099d
1 changed files with 8 additions and 11 deletions
|
@ -286,18 +286,7 @@ class PyVmomiHelper(PyVmomi):
|
|||
self.ip_address = self.params['network'].get('ip_address', None)
|
||||
self.subnet_mask = self.params['network'].get('subnet_mask', None)
|
||||
self.default_gateway = self.params['network'].get('default_gateway', None)
|
||||
if self.network_type == 'static':
|
||||
if not self.ip_address:
|
||||
module.fail_json(msg="ip_address is a required parameter when network type is set to 'static'")
|
||||
if not self.subnet_mask:
|
||||
module.fail_json(msg="subnet_mask is a required parameter when network type is set to 'static'")
|
||||
self.tcpip_stack = self.params['network'].get('tcpip_stack')
|
||||
else:
|
||||
self.network_type = 'dhcp'
|
||||
self.ip_address = None
|
||||
self.subnet_mask = None
|
||||
self.default_gateway = None
|
||||
self.tcpip_stack = 'default'
|
||||
self.device = self.params['device']
|
||||
if self.network_type == 'dhcp' and not self.device:
|
||||
module.fail_json(msg="device is a required parameter when network type is set to 'dhcp'")
|
||||
|
@ -323,6 +312,14 @@ class PyVmomiHelper(PyVmomi):
|
|||
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(
|
||||
|
|
Loading…
Reference in a new issue