adds description to bigip snatpool (#58179)
This commit is contained in:
parent
655ad7456d
commit
95e59e7ee7
2 changed files with 44 additions and 3 deletions
|
@ -27,6 +27,12 @@ options:
|
||||||
type: list
|
type: list
|
||||||
aliases:
|
aliases:
|
||||||
- member
|
- member
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- A general description of the SNAT pool, provided by the user for their
|
||||||
|
benefit. It is optional.
|
||||||
|
type: str
|
||||||
|
version_added: 2.9
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- The name of the SNAT pool.
|
- The name of the SNAT pool.
|
||||||
|
@ -86,6 +92,20 @@ EXAMPLES = r'''
|
||||||
user: admin
|
user: admin
|
||||||
password: secret
|
password: secret
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Add the SNAT pool 'my-snat-pool' with a description
|
||||||
|
bigip_snat_pool:
|
||||||
|
name: my-snat-pool
|
||||||
|
state: present
|
||||||
|
members:
|
||||||
|
- 10.10.10.10
|
||||||
|
- 20.20.20.20
|
||||||
|
description: A SNAT pool description
|
||||||
|
provider:
|
||||||
|
server: lb.mydomain.com
|
||||||
|
user: admin
|
||||||
|
password: secret
|
||||||
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = r'''
|
RETURN = r'''
|
||||||
|
@ -110,6 +130,7 @@ try:
|
||||||
from library.module_utils.network.f5.common import f5_argument_spec
|
from library.module_utils.network.f5.common import f5_argument_spec
|
||||||
from library.module_utils.network.f5.common import transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
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
|
||||||
|
@ -118,21 +139,25 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||||
from ansible.module_utils.network.f5.common import transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
from ansible.module_utils.network.f5.compare import cmp_str_with_none
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
api_map = {}
|
api_map = {}
|
||||||
|
|
||||||
updatables = [
|
updatables = [
|
||||||
'members'
|
'members',
|
||||||
|
'description',
|
||||||
]
|
]
|
||||||
|
|
||||||
returnables = [
|
returnables = [
|
||||||
'members'
|
'members',
|
||||||
|
'description',
|
||||||
]
|
]
|
||||||
|
|
||||||
api_attributes = [
|
api_attributes = [
|
||||||
'members'
|
'members',
|
||||||
|
'description',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +190,14 @@ class ModuleParameters(Parameters):
|
||||||
result.update([address])
|
result.update([address])
|
||||||
return list(result)
|
return list(result)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
if self._values['description'] is None:
|
||||||
|
return None
|
||||||
|
elif self._values['description'] in ['none', '']:
|
||||||
|
return ''
|
||||||
|
return self._values['description']
|
||||||
|
|
||||||
|
|
||||||
class Changes(Parameters):
|
class Changes(Parameters):
|
||||||
def to_return(self):
|
def to_return(self):
|
||||||
|
@ -216,6 +249,11 @@ class Difference(object):
|
||||||
result = list(set(self.want.members))
|
result = list(set(self.want.members))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
result = cmp_str_with_none(self.want.description, self.have.description)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class ModuleManager(object):
|
class ModuleManager(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -416,6 +454,7 @@ class ArgumentSpec(object):
|
||||||
type='list',
|
type='list',
|
||||||
aliases=['member']
|
aliases=['member']
|
||||||
),
|
),
|
||||||
|
description=dict(),
|
||||||
state=dict(
|
state=dict(
|
||||||
default='present',
|
default='present',
|
||||||
choices=['absent', 'present']
|
choices=['absent', 'present']
|
||||||
|
|
|
@ -70,11 +70,13 @@ class TestParameters(unittest.TestCase):
|
||||||
name='my-snat-pool',
|
name='my-snat-pool',
|
||||||
state='present',
|
state='present',
|
||||||
members=['10.10.10.10', '20.20.20.20'],
|
members=['10.10.10.10', '20.20.20.20'],
|
||||||
|
description='A SNAT pool description',
|
||||||
partition='Common'
|
partition='Common'
|
||||||
)
|
)
|
||||||
p = ModuleParameters(params=args)
|
p = ModuleParameters(params=args)
|
||||||
assert p.name == 'my-snat-pool'
|
assert p.name == 'my-snat-pool'
|
||||||
assert p.state == 'present'
|
assert p.state == 'present'
|
||||||
|
assert p.description == 'A SNAT pool description'
|
||||||
assert len(p.members) == 2
|
assert len(p.members) == 2
|
||||||
assert '/Common/10.10.10.10' in p.members
|
assert '/Common/10.10.10.10' in p.members
|
||||||
assert '/Common/20.20.20.20' in p.members
|
assert '/Common/20.20.20.20' in p.members
|
||||||
|
|
Loading…
Reference in a new issue