Adds minor fixes and features to f5 modules (#39202)

* Add Mac_address parameter to bigip_traffic_group
* Fix docs
* Fix f5 conventions
pull/39206/head
Tim Rupp 6 years ago committed by GitHub
parent 0c96863ec6
commit e254121729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,7 @@ module: bigip_traffic_group
short_description: Manages traffic groups on BIG-IP short_description: Manages traffic groups on BIG-IP
description: description:
- Supports managing traffic groups and their attributes on a BIG-IP. - Supports managing traffic groups and their attributes on a BIG-IP.
version_added: "2.5" version_added: 2.5
options: options:
name: name:
description: description:
@ -28,7 +28,6 @@ options:
description: description:
- Device partition to manage resources on. - Device partition to manage resources on.
default: Common default: Common
version_added: 2.5
state: state:
description: description:
- When C(present), ensures that the traffic group exists. - When C(present), ensures that the traffic group exists.
@ -37,7 +36,18 @@ options:
choices: choices:
- present - present
- absent - absent
version_added: 2.5 mac_address:
description:
- Specifies the floating Media Access Control (MAC) address associated with the floating IP addresses
defined for a traffic group.
- Primarily, a MAC masquerade address minimizes ARP communications or dropped packets as a result of failover.
- A MAC masquerade address ensures that any traffic destined for a specific traffic group reaches an available
device after failover, which happens because along with the traffic group, the MAC masquerade address floats
to the available device.
- Without a MAC masquerade address, the sending host must learn the MAC address for a newly-active device,
either by sending an ARP request or by relying on the gratuitous ARP from the newly-active device.
- To unset the MAC address, specify an empty value (C("")) to this parameter.
version_added: 2.6
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
@ -61,31 +71,26 @@ RETURN = r'''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback from ansible.module_utils.basic import env_fallback
HAS_DEVEL_IMPORTS = False
try: try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
from library.module_utils.network.f5.common import fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec from library.module_utils.network.f5.common import f5_argument_spec
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError: except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
from ansible.module_utils.network.f5.common import fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec from ansible.module_utils.network.f5.common import f5_argument_spec
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -94,19 +99,19 @@ except ImportError:
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
'mac': 'mac_address'
} }
api_attributes = [ api_attributes = [
'mac'
] ]
returnables = [ returnables = [
'mac_address'
] ]
updatables = [ updatables = [
'mac_address'
] ]
def to_return(self): def to_return(self):
@ -120,6 +125,20 @@ class Parameters(AnsibleF5Parameters):
return result return result
class ApiParameters(Parameters):
pass
class ModuleParameters(Parameters):
@property
def mac_address(self):
if self._values['mac_address'] is None:
return None
if self._values['mac_address'] == '':
return 'none'
return self._values['mac_address']
class Changes(Parameters): class Changes(Parameters):
pass pass
@ -156,7 +175,7 @@ class ModuleManager(object):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.module = kwargs.get('module', None) self.module = kwargs.get('module', None)
self.client = kwargs.get('client', None) self.client = kwargs.get('client', None)
self.want = Parameters(params=self.module.params) self.want = ModuleParameters(params=self.module.params)
self.changes = Changes() self.changes = Changes()
def _set_changed_options(self): def _set_changed_options(self):
@ -294,7 +313,7 @@ class ModuleManager(object):
partition=self.want.partition partition=self.want.partition
) )
result = resource.attrs result = resource.attrs
return Parameters(params=result) return ApiParameters(params=result)
class ArgumentSpec(object): class ArgumentSpec(object):
@ -306,7 +325,8 @@ class ArgumentSpec(object):
partition=dict( partition=dict(
default='Common', default='Common',
fallback=(env_fallback, ['F5_PARTITION']) fallback=(env_fallback, ['F5_PARTITION'])
) ),
mac_address=dict()
) )
self.argument_spec = {} self.argument_spec = {}
self.argument_spec.update(f5_argument_spec) self.argument_spec.update(f5_argument_spec)

@ -18,16 +18,14 @@ module: bigip_ucs
short_description: Manage upload, installation and removal of UCS files short_description: Manage upload, installation and removal of UCS files
description: description:
- Manage upload, installation and removal of UCS files. - Manage upload, installation and removal of UCS files.
version_added: "2.4" version_added: 2.4
options: options:
include_chassis_level_config: include_chassis_level_config:
description: description:
- During restore of the UCS file, include chassis level configuration - During restore of the UCS file, include chassis level configuration
that is shared among boot volume sets. For example, cluster default that is shared among boot volume sets. For example, cluster default
configuration. configuration.
choices: type: bool
- yes
- no
ucs: ucs:
description: description:
- The path to the UCS file to install. The parameter must be - The path to the UCS file to install. The parameter must be
@ -42,38 +40,29 @@ options:
device. If C(no), the file will only be uploaded if it does not already device. If C(no), the file will only be uploaded if it does not already
exist. Generally should be C(yes) only in cases where you have reason exist. Generally should be C(yes) only in cases where you have reason
to believe that the image was corrupted during upload. to believe that the image was corrupted during upload.
choices: type: bool
- yes default: no
- no
no_license: no_license:
description: description:
- Performs a full restore of the UCS file and all the files it contains, - Performs a full restore of the UCS file and all the files it contains,
with the exception of the license file. The option must be used to with the exception of the license file. The option must be used to
restore a UCS on RMA devices (Returned Materials Authorization). restore a UCS on RMA devices (Returned Materials Authorization).
choices: type: bool
- yes
- no
no_platform_check: no_platform_check:
description: description:
- Bypasses the platform check and allows a UCS that was created using a - Bypasses the platform check and allows a UCS that was created using a
different platform to be installed. By default (without this option), different platform to be installed. By default (without this option),
a UCS created from a different platform is not allowed to be installed. a UCS created from a different platform is not allowed to be installed.
choices: type: bool
- yes
- no
passphrase: passphrase:
description: description:
- Specifies the passphrase that is necessary to load the specified UCS file. - Specifies the passphrase that is necessary to load the specified UCS file.
choices: type: bool
- yes
- no
reset_trust: reset_trust:
description: description:
- When specified, the device and trust domain certs and keys are not - When specified, the device and trust domain certs and keys are not
loaded from the UCS. Instead, a new set is regenerated. loaded from the UCS. Instead, a new set is regenerated.
choices: type: bool
- yes
- no
state: state:
description: description:
- When C(installed), ensures that the UCS is uploaded and installed, - When C(installed), ensures that the UCS is uploaded and installed,
@ -184,30 +173,23 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems from ansible.module_utils.six import iteritems
from distutils.version import LooseVersion from distutils.version import LooseVersion
HAS_DEVEL_IMPORTS = False
try: try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
from library.module_utils.network.f5.common import fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec from library.module_utils.network.f5.common import f5_argument_spec
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError: except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
from ansible.module_utils.network.f5.common import fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec from ansible.module_utils.network.f5.common import f5_argument_spec
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError

@ -145,30 +145,23 @@ import tempfile
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from distutils.version import LooseVersion from distutils.version import LooseVersion
HAS_DEVEL_IMPORTS = False
try: try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
from library.module_utils.network.f5.common import fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec from library.module_utils.network.f5.common import f5_argument_spec
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError: except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
from ansible.module_utils.network.f5.common import fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec from ansible.module_utils.network.f5.common import f5_argument_spec
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError

@ -1166,8 +1166,6 @@ lib/ansible/modules/network/f5/bigip_routedomain.py E326
lib/ansible/modules/network/f5/bigip_selfip.py E324 lib/ansible/modules/network/f5/bigip_selfip.py E324
lib/ansible/modules/network/f5/bigip_static_route.py E325 lib/ansible/modules/network/f5/bigip_static_route.py E325
lib/ansible/modules/network/f5/bigip_sys_global.py E326 lib/ansible/modules/network/f5/bigip_sys_global.py E326
lib/ansible/modules/network/f5/bigip_ucs.py E325
lib/ansible/modules/network/f5/bigip_ucs.py E326
lib/ansible/modules/network/f5/bigip_virtual_server.py E326 lib/ansible/modules/network/f5/bigip_virtual_server.py E326
lib/ansible/modules/network/f5/bigiq_regkey_license.py E325 lib/ansible/modules/network/f5/bigiq_regkey_license.py E325
lib/ansible/modules/network/fortimanager/fmgr_script.py E324 lib/ansible/modules/network/fortimanager/fmgr_script.py E324

@ -0,0 +1,9 @@
{
"kind": "tm:net:timer-policy:timer-policystate",
"name": "timer1",
"partition": "Common",
"fullPath": "/Common/timer1",
"generation": 148,
"selfLink": "https://localhost/mgmt/tm/net/timer-policy/~Common~timer1?ver=13.1.0.4",
"description": "my description"
}

@ -0,0 +1,16 @@
{
"kind": "tm:cm:traffic-group:traffic-groupstate",
"name": "traffic-group-1",
"partition": "Common",
"fullPath": "/Common/traffic-group-1",
"generation": 1,
"selfLink": "https://localhost/mgmt/tm/cm/traffic-group/~Common~traffic-group-1?ver=13.0.0",
"autoFailbackEnabled": "false",
"autoFailbackTime": 60,
"failoverMethod": "ha-order",
"haLoadFactor": 1,
"isFloating": "true",
"mac": "none",
"monitor": {},
"unitId": 1
}

@ -0,0 +1,16 @@
{
"kind": "tm:cm:traffic-group:traffic-groupstate",
"name": "asd",
"partition": "Common",
"fullPath": "/Common/asd",
"generation": 176,
"selfLink": "https://localhost/mgmt/tm/cm/traffic-group/~Common~asd?ver=13.0.0",
"autoFailbackEnabled": "false",
"autoFailbackTime": 60,
"failoverMethod": "ha-order",
"haLoadFactor": 1,
"isFloating": "true",
"mac": "00:00:00:00:00:02",
"monitor": {},
"unitId": 2
}

@ -0,0 +1,29 @@
{
"kind": "tm:net:trunk:trunkstate",
"name": "foo",
"fullPath": "foo",
"generation": 79,
"selfLink": "https://localhost/mgmt/tm/net/trunk/foo?ver=13.1.0.4",
"bandwidth": 10000,
"cfgMbrCount": 1,
"distributionHash": "dst-mac",
"id": 0,
"lacp": "disabled",
"lacpMode": "active",
"lacpTimeout": "long",
"linkSelectPolicy": "maximum-bandwidth",
"macAddress": "08:00:27:ea:18:52",
"media": "10000",
"qinqEthertype": "0x8100",
"stp": "enabled",
"type": "normal",
"workingMbrCount": 1,
"interfaces": [
"1.3"
],
"interfacesReference": [
{
"link": "https://localhost/mgmt/tm/net/interface/1.3?ver=13.1.0.4"
}
]
}

@ -21,15 +21,17 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
try: try:
from library.bigip_traffic_group import Parameters from library.modules.bigip_traffic_group import ApiParameters
from library.bigip_traffic_group import ModuleManager from library.modules.bigip_traffic_group import ModuleParameters
from library.bigip_traffic_group import ArgumentSpec from library.modules.bigip_traffic_group import ModuleManager
from library.modules.bigip_traffic_group import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args from test.unit.modules.utils import set_module_args
except ImportError: except ImportError:
try: try:
from ansible.modules.network.f5.bigip_traffic_group import Parameters from ansible.modules.network.f5.bigip_traffic_group import ApiParameters
from ansible.modules.network.f5.bigip_traffic_group import ModuleParameters
from ansible.modules.network.f5.bigip_traffic_group import ModuleManager from ansible.modules.network.f5.bigip_traffic_group import ModuleManager
from ansible.modules.network.f5.bigip_traffic_group import ArgumentSpec from ansible.modules.network.f5.bigip_traffic_group import ArgumentSpec
from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import F5ModuleError
@ -61,13 +63,35 @@ def load_fixture(name):
class TestParameters(unittest.TestCase): class TestParameters(unittest.TestCase):
def test_module_parameters(self): def test_module_parameters_1(self):
args = dict( args = dict(
name='foo' name='foo',
mac_address=''
) )
p = Parameters(params=args) p = ModuleParameters(params=args)
assert p.name == 'foo' assert p.name == 'foo'
assert p.mac_address == 'none'
def test_module_parameters_2(self):
args = dict(
mac_address='00:00:00:00:00:02'
)
p = ModuleParameters(params=args)
assert p.mac_address == '00:00:00:00:00:02'
def test_api_parameters_1(self):
args = load_fixture('load_tm_cm_traffic_group_1.json')
p = ApiParameters(params=args)
assert p.mac_address == 'none'
def test_api_parameters_2(self):
args = load_fixture('load_tm_cm_traffic_group_2.json')
p = ApiParameters(params=args)
assert p.mac_address == '00:00:00:00:00:02'
class TestManager(unittest.TestCase): class TestManager(unittest.TestCase):

@ -21,11 +21,11 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
try: try:
from library.bigip_ucs import Parameters from library.modules.bigip_ucs import Parameters
from library.bigip_ucs import ModuleManager from library.modules.bigip_ucs import ModuleManager
from library.bigip_ucs import ArgumentSpec from library.modules.bigip_ucs import ArgumentSpec
from library.bigip_ucs import V1Manager from library.modules.bigip_ucs import V1Manager
from library.bigip_ucs import V2Manager from library.modules.bigip_ucs import V2Manager
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args from test.unit.modules.utils import set_module_args

@ -20,11 +20,11 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
try: try:
from library.bigip_ucs_fetch import Parameters from library.modules.bigip_ucs_fetch import Parameters
from library.bigip_ucs_fetch import ModuleManager from library.modules.bigip_ucs_fetch import ModuleManager
from library.bigip_ucs_fetch import V1Manager from library.modules.bigip_ucs_fetch import V1Manager
from library.bigip_ucs_fetch import V2Manager from library.modules.bigip_ucs_fetch import V2Manager
from library.bigip_ucs_fetch import ArgumentSpec from library.modules.bigip_ucs_fetch import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args from test.unit.modules.utils import set_module_args

Loading…
Cancel
Save