Navigation Menu

Skip to content

Commit

Permalink
vmware_vmkernel: no error on state=absent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
goneri committed Apr 11, 2019
1 parent 6579dfd commit e0f5de4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/ansible/modules/cloud/vmware/vmware_vmkernel.py
Expand Up @@ -286,18 +286,7 @@ def __init__(self, module):
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'")
Expand All @@ -323,6 +312,14 @@ 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

0 comments on commit e0f5de4

Please sign in to comment.