1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Adds description field to bigip_traffic_selector module (#48007)

This commit is contained in:
Tim Rupp 2018-11-02 12:48:17 -07:00 committed by GitHub
parent 24be9c030c
commit 8abc7e49b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,6 +44,9 @@ options:
- Traffic is matched to the traffic selector with the highest priority (lowest order number). - Traffic is matched to the traffic selector with the highest priority (lowest order number).
- When creating a new traffic selector, if this parameter is not specified, the default - When creating a new traffic selector, if this parameter is not specified, the default
is C(last). is C(last).
description:
description:
- Description of the traffic selector.
partition: partition:
description: description:
- Device partition to manage resources on. - Device partition to manage resources on.
@ -59,6 +62,7 @@ options:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -115,6 +119,7 @@ try:
from library.module_utils.network.f5.common import fail_json from library.module_utils.network.f5.common import fail_json
from library.module_utils.network.f5.common import transform_name from library.module_utils.network.f5.common import transform_name
from library.module_utils.compat.ipaddress import ip_interface from library.module_utils.compat.ipaddress import ip_interface
from library.module_utils.network.f5.compare import cmp_str_with_none
except ImportError: except ImportError:
from ansible.module_utils.network.f5.bigip import F5RestClient from ansible.module_utils.network.f5.bigip import F5RestClient
from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import F5ModuleError
@ -126,6 +131,7 @@ except ImportError:
from ansible.module_utils.network.f5.common import fail_json from ansible.module_utils.network.f5.common import fail_json
from ansible.module_utils.network.f5.common import transform_name from ansible.module_utils.network.f5.common import transform_name
from ansible.module_utils.compat.ipaddress import ip_interface from ansible.module_utils.compat.ipaddress import ip_interface
from ansible.module_utils.network.f5.compare import cmp_str_with_none
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
@ -140,6 +146,7 @@ class Parameters(AnsibleF5Parameters):
'sourceAddress', 'sourceAddress',
'ipsecPolicy', 'ipsecPolicy',
'order', 'order',
'description',
] ]
returnables = [ returnables = [
@ -147,6 +154,7 @@ class Parameters(AnsibleF5Parameters):
'source_address', 'source_address',
'ipsec_policy', 'ipsec_policy',
'order', 'order',
'description',
] ]
updatables = [ updatables = [
@ -154,11 +162,16 @@ class Parameters(AnsibleF5Parameters):
'source_address', 'source_address',
'ipsec_policy', 'ipsec_policy',
'order', 'order',
'description',
] ]
class ApiParameters(Parameters): class ApiParameters(Parameters):
pass @property
def description(self):
if self._values['description'] in [None, 'none']:
return None
return self._values['description']
class ModuleParameters(Parameters): class ModuleParameters(Parameters):
@ -186,6 +199,14 @@ class ModuleParameters(Parameters):
) )
return result return result
@property
def description(self):
if self._values['description'] is None:
return None
elif self._values['description'] in ['none', '']:
return ''
return self._values['description']
def _format_address(self, type): def _format_address(self, type):
if self._values[type] is None: if self._values[type] is None:
return None return None
@ -253,6 +274,10 @@ class Difference(object):
except AttributeError: except AttributeError:
return attr1 return attr1
@property
def description(self):
return cmp_str_with_none(self.want.description, self.have.description)
class ModuleManager(object): class ModuleManager(object):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -447,6 +472,7 @@ class ArgumentSpec(object):
source_address=dict(), source_address=dict(),
ipsec_policy=dict(), ipsec_policy=dict(),
order=dict(type='int'), order=dict(type='int'),
description=dict(),
state=dict( state=dict(
default='present', default='present',
choices=['present', 'absent'] choices=['present', 'absent']
@ -469,8 +495,9 @@ def main():
supports_check_mode=spec.supports_check_mode, supports_check_mode=spec.supports_check_mode,
) )
client = F5RestClient(**module.params)
try: try:
client = F5RestClient(**module.params)
mm = ModuleManager(module=module, client=client) mm = ModuleManager(module=module, client=client)
results = mm.exec_module() results = mm.exec_module()
cleanup_tokens(client) cleanup_tokens(client)