Skip to content

Commit

Permalink
New options to Interface (ansible#60499)
Browse files Browse the repository at this point in the history
* update to interface

* force ansibot to run again

* fixes
  • Loading branch information
carchi8py authored and anas-shami committed Sep 23, 2019
1 parent 71fb5a6 commit ad85e78
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
46 changes: 43 additions & 3 deletions lib/ansible/modules/storage/netapp/na_ontap_interface.py
Expand Up @@ -76,9 +76,9 @@
- Specifies the firewall policy for the LIF.
failover_policy:
choices: ['disabled', 'system-defined', 'local-only', 'sfo-partner-only', 'broadcast-domain-wide']
description:
- Specifies the failover policy for the LIF.
- Possible values are 'disabled', 'system-defined', 'local-only', 'sfo-partner-only', and 'broadcast-domain-wide'
subnet_name:
description:
Expand Down Expand Up @@ -111,6 +111,24 @@
- Protocol values of none, iscsi, fc-nvme or fcp can't be combined with any other data protocol(s).
- address, netmask and firewall_policy parameters are not supported for 'fc-nvme' option.
dns_domain_name:
description:
- Specifies the unique, fully qualified domain name of the DNS zone of this LIF.
type: str
version_added: '2.9'
listen_for_dns_query:
description:
- If True, this IP address will listen for DNS queries for the dnszone specified.
type: bool
version_added: '2.9'
is_dns_update_enabled:
description:
- Specifies if DNS update is enabled for this LIF. Dynamic updates will be sent for this LIF if updates are enabled at Vserver level.
type: bool
version_added: '2.9'
'''

EXAMPLES = '''
Expand All @@ -129,6 +147,9 @@
address: 10.10.10.10
netmask: 255.255.255.0
force_subnet_association: false
dns_domain_name: test.com
listen_for_dns_query: true
is_dns_update_enabled: true
vserver: svm1
hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}"
Expand Down Expand Up @@ -174,12 +195,17 @@ def __init__(self):
netmask=dict(required=False, type='str'),
vserver=dict(required=True, type='str'),
firewall_policy=dict(required=False, type='str', default=None),
failover_policy=dict(required=False, type='str', default=None),
failover_policy=dict(required=False, type='str', default=None,
choices=['disabled', 'system-defined',
'local-only', 'sfo-partner-only', 'broadcast-domain-wide']),
admin_status=dict(required=False, choices=['up', 'down']),
subnet_name=dict(required=False, type='str'),
is_auto_revert=dict(required=False, type='bool', default=None),
protocols=dict(required=False, type='list'),
force_subnet_association=dict(required=False, type='bool', default=None)
force_subnet_association=dict(required=False, type='bool', default=None),
dns_domain_name=dict(required=False, type='str'),
listen_for_dns_query=dict(required=False, type='bool'),
is_dns_update_enabled=dict(required=False, type='bool')
))

self.module = AnsibleModule(
Expand Down Expand Up @@ -237,6 +263,14 @@ def get_interface(self):
return_value['netmask'] = interface_attributes['netmask']
if interface_attributes.get_child_by_name('firewall-policy'):
return_value['firewall_policy'] = interface_attributes['firewall-policy']
if interface_attributes.get_child_by_name('dns-domain-name') != 'none':
return_value['dns_domain_name'] = interface_attributes['dns-domain-name']
else:
return_value['dns_domain_name'] = None
if interface_attributes.get_child_by_name('listen-for-dns-query'):
return_value['listen_for_dns_query'] = self.na_helper.get_value_for_bool(True, interface_attributes['listen-for-dns-query'])
if interface_attributes.get_child_by_name('is-dns-update-enabled'):
return_value['is_dns_update_enabled'] = self.na_helper.get_value_for_bool(True, interface_attributes['is-dns-update-enabled'])
return return_value

@staticmethod
Expand All @@ -260,6 +294,12 @@ def set_options(options, parameters):
options['administrative-status'] = parameters['admin_status']
if parameters.get('force_subnet_association') is not None:
options['force-subnet-association'] = 'true' if parameters['force_subnet_association'] else 'false'
if parameters.get('dns_domain_name') is not None:
options['dns-domain-name'] = parameters['dns_domain_name']
if parameters.get('listen_for_dns_query') is not None:
options['listen-for-dns-query'] = str(parameters['listen_for_dns_query'])
if parameters.get('is_dns_update_enabled') is not None:
options['is-dns-update-enabled'] = str(parameters['is_dns_update_enabled'])

def set_protocol_option(self, required_keys):
""" set protocols for create """
Expand Down
11 changes: 10 additions & 1 deletion test/units/modules/storage/netapp/test_na_ontap_interface.py
Expand Up @@ -85,7 +85,10 @@ def build_interface_info(data):
'address': data['address'],
'netmask': data['netmask'],
'role': data['role'],
'protocols': data['protocols'] if data.get('protocols') else None
'protocols': data['protocols'] if data.get('protocols') else None,
'dns-domain-name': data['dns_domain_name'],
'listen-for-dns_query': data['listen_for_dns_query'],
'is-dns-update-enabled': data['is_dns_update_enabled']
}
}
}
Expand Down Expand Up @@ -113,6 +116,9 @@ def setUp(self):
'home_port': 'e0c',
'address': '2.2.2.2',
'netmask': '1.1.1.1',
'dns_domain_name': 'test.com',
'listen_for_dns_query': True,
'is_dns_update_enabled': True
}

def mock_args(self):
Expand Down Expand Up @@ -248,6 +254,9 @@ def test_successful_modify(self):
''' Test successful modify interface_minutes '''
data = self.mock_args()
data['home_port'] = 'new_port'
data['dns_domain_name'] = 'test2.com'
data['listen_for_dns_query'] = False
data['is_dns_update_enabled'] = False
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
interface_obj = self.get_interface_mock_object('interface')
Expand Down

0 comments on commit ad85e78

Please sign in to comment.