diff --git a/lib/ansible/modules/network/f5/bigip_user.py b/lib/ansible/modules/network/f5/bigip_user.py index 92d847ed50..9c3ca2a2f7 100644 --- a/lib/ansible/modules/network/f5/bigip_user.py +++ b/lib/ansible/modules/network/f5/bigip_user.py @@ -24,7 +24,7 @@ description: Your other parameters will be ignored in this case. Changing the C(root) password is not an idempotent operation. Therefore, it will change it every time this module attempts to change it. -version_added: "2.4" +version_added: 2.4 options: full_name: description: @@ -70,7 +70,7 @@ options: - C(always) will allow to update passwords if the user chooses to do so. C(on_create) will only set the password for newly created users. When C(username_credential) is C(root), this value will be forced to C(always). - default: on_create + default: always choices: - always - on_create @@ -196,30 +196,23 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import env_fallback from distutils.version import LooseVersion -HAS_DEVEL_IMPORTS = False - try: - # Sideband repository used for dev 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.common import F5ModuleError 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 fqdn_name from library.module_utils.network.f5.common import f5_argument_spec try: from library.module_utils.network.f5.common import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False - HAS_DEVEL_IMPORTS = True except ImportError: - # Upstream Ansible 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.common import F5ModuleError 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 fqdn_name from ansible.module_utils.network.f5.common import f5_argument_spec try: from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError diff --git a/lib/ansible/modules/network/f5/bigip_vcmp_guest.py b/lib/ansible/modules/network/f5/bigip_vcmp_guest.py index 59033c6963..7720abf4c2 100644 --- a/lib/ansible/modules/network/f5/bigip_vcmp_guest.py +++ b/lib/ansible/modules/network/f5/bigip_vcmp_guest.py @@ -20,7 +20,7 @@ description: - Manages vCMP guests on a BIG-IP. This functionality only exists on actual hardware and must be enabled by provisioning C(vcmp) with the C(bigip_provision) module. -version_added: "2.5" +version_added: 2.5 options: name: description: @@ -68,6 +68,7 @@ options: description: - When C(state) is C(absent), will additionally delete the virtual disk associated with the vCMP guest. By default, this value is C(no). + type: bool default: no mgmt_address: description: @@ -179,33 +180,30 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import env_fallback from collections import namedtuple -HAS_DEVEL_IMPORTS = False - try: - # Sideband repository used for dev 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.common import F5ModuleError 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 fqdn_name + from library.module_utils.network.f5.common import fq_name from library.module_utils.network.f5.common import f5_argument_spec try: from library.module_utils.network.f5.common import iControlUnexpectedHTTPError + from f5.utils.responses.handlers import Stats except ImportError: HAS_F5SDK = False - HAS_DEVEL_IMPORTS = True except ImportError: - # Upstream Ansible 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.common import F5ModuleError 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 fqdn_name + from ansible.module_utils.network.f5.common import fq_name from ansible.module_utils.network.f5.common import f5_argument_spec try: from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError + from f5.utils.responses.handlers import Stats except ImportError: HAS_F5SDK = False @@ -215,11 +213,6 @@ try: except ImportError: HAS_NETADDR = False -try: - from f5.utils.responses.handlers import Stats -except ImportError: - HAS_F5SDK = False - class Parameters(AnsibleF5Parameters): api_map = { @@ -246,11 +239,6 @@ class Parameters(AnsibleF5Parameters): 'state' ] - def _fqdn_name(self, value): - if value is not None and not value.startswith('/'): - return '/{0}/{1}'.format(self.partition, value) - return value - def to_return(self): result = {} try: @@ -318,7 +306,7 @@ class Parameters(AnsibleF5Parameters): def vlans(self): if self._values['vlans'] is None: return None - result = [self._fqdn_name(x) for x in self._values['vlans']] + result = [fq_name(self.partition, x) for x in self._values['vlans']] result.sort() return result @@ -439,11 +427,6 @@ class ModuleManager(object): version=warning['version'] ) - def _fqdn_name(self, value): - if value is not None and not value.startswith('/'): - return '/{0}/{1}'.format(self.partition, value) - return value - def present(self): if self.exists(): return self.update() diff --git a/lib/ansible/modules/network/f5/bigip_virtual_address.py b/lib/ansible/modules/network/f5/bigip_virtual_address.py index 9234dd5185..56d7b3f707 100644 --- a/lib/ansible/modules/network/f5/bigip_virtual_address.py +++ b/lib/ansible/modules/network/f5/bigip_virtual_address.py @@ -18,14 +18,20 @@ module: bigip_virtual_address short_description: Manage LTM virtual addresses on a BIG-IP description: - Manage LTM virtual addresses on a BIG-IP. -version_added: "2.4" +version_added: 2.4 options: + name: + description: + - Name of the virtual address. + - If this parameter is not provided, then the value of C(address) will + be used. + version_added: 2.6 address: description: - Virtual address. This value cannot be modified after it is set. - required: True - aliases: - - name + - If you never created a virtual address, but did create virtual servers, then + a virtual address for each virtual server was created automatically. The name + of this virtual address is its IP address value. netmask: description: - Netmask of the provided virtual address. This value cannot be @@ -192,30 +198,25 @@ from ansible.module_utils.basic import env_fallback from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE -HAS_DEVEL_IMPORTS = False - try: - # Sideband repository used for dev 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.common import F5ModuleError 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 fqdn_name + from library.module_utils.network.f5.common import fq_name from library.module_utils.network.f5.common import f5_argument_spec try: from library.module_utils.network.f5.common import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False - HAS_DEVEL_IMPORTS = True except ImportError: - # Upstream Ansible 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.common import F5ModuleError 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 fqdn_name + from ansible.module_utils.network.f5.common import fq_name from ansible.module_utils.network.f5.common import f5_argument_spec try: from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError @@ -243,12 +244,12 @@ class Parameters(AnsibleF5Parameters): updatables = [ 'use_route_advertisement', 'auto_delete', 'icmp_echo', 'connection_limit', - 'arp_state', 'enabled', 'advertise_route', 'traffic_group' + 'arp_state', 'enabled', 'advertise_route', 'traffic_group', 'address' ] returnables = [ 'use_route_advertisement', 'auto_delete', 'icmp_echo', 'connection_limit', - 'netmask', 'arp_state', 'address', 'state' + 'netmask', 'arp_state', 'address', 'state', 'traffic_group' ] api_attributes = [ @@ -256,11 +257,6 @@ class Parameters(AnsibleF5Parameters): 'advertiseRoute', 'arp', 'mask', 'enabled', 'serverScope', 'trafficGroup' ] - def _fqdn_name(self, value): - if value is not None and not value.startswith('/'): - return '/{0}/{1}'.format(self.partition, value) - return value - @property def advertise_route(self): if self._values['advertise_route'] is None: @@ -351,7 +347,7 @@ class Parameters(AnsibleF5Parameters): if self._values['traffic_group'] is None: return None else: - result = self._fqdn_name(self._values['traffic_group']) + result = fq_name(self.partition, self._values['traffic_group']) if result.startswith('/Common/'): return result else: @@ -367,10 +363,30 @@ class Parameters(AnsibleF5Parameters): return result +class ApiParameters(Parameters): + pass + + +class ModuleParameters(Parameters): + @property + def name(self): + if self._values['name'] is None: + return str(self.address) + return self._values['name'] + + class Changes(Parameters): pass +class UsableChanges(Changes): + pass + + +class ReportableChanges(Changes): + pass + + class Difference(object): def __init__(self, want, have=None): self.want = want @@ -403,8 +419,8 @@ class ModuleManager(object): self.module = kwargs.get('module', None) self.client = kwargs.get('client', None) self.have = None - self.want = Parameters(client=self.client, params=self.module.params) - self.changes = Changes() + self.want = ModuleParameters(client=self.client, params=self.module.params) + self.changes = UsableChanges() def _set_changed_options(self): changed = {} @@ -412,7 +428,7 @@ class ModuleManager(object): if getattr(self.want, key) is not None: changed[key] = getattr(self.want, key) if changed: - self.changes = Changes(params=changed) + self.changes = UsableChanges(params=changed) def _update_changed_options(self): diff = Difference(self.want, self.have) @@ -428,7 +444,7 @@ class ModuleManager(object): else: changed[k] = change if changed: - self.changes = Changes(params=changed) + self.changes = UsableChanges(params=changed) return True return False @@ -470,15 +486,15 @@ class ModuleManager(object): def read_current_from_device(self): resource = self.client.api.tm.ltm.virtual_address_s.virtual_address.load( - name=self.want.address, + name=self.want.name, partition=self.want.partition ) result = resource.attrs - return Parameters(params=result) + return ApiParameters(params=result) def exists(self): result = self.client.api.tm.ltm.virtual_address_s.virtual_address.exists( - name=self.want.address, + name=self.want.name, partition=self.want.partition ) return result @@ -505,9 +521,9 @@ class ModuleManager(object): return True def update_on_device(self): - params = self.want.api_params() + params = self.changes.api_params() resource = self.client.api.tm.ltm.virtual_address_s.virtual_address.load( - name=self.want.address, + name=self.want.name, partition=self.want.partition ) resource.modify(**params) @@ -525,9 +541,9 @@ class ModuleManager(object): raise F5ModuleError("Failed to create the virtual address") def create_on_device(self): - params = self.want.api_params() + params = self.changes.api_params() self.client.api.tm.ltm.virtual_address_s.virtual_address.create( - name=self.want.address, + name=self.want.name, partition=self.want.partition, address=self.want.address, **params @@ -543,7 +559,7 @@ class ModuleManager(object): def remove_from_device(self): resource = self.client.api.tm.ltm.virtual_address_s.virtual_address.load( - name=self.want.address, + name=self.want.name, partition=self.want.partition ) resource.delete() @@ -557,11 +573,8 @@ class ArgumentSpec(object): default='present', choices=['present', 'absent', 'disabled', 'enabled'] ), - address=dict( - type='str', - required=True, - aliases=['name'] - ), + name=dict(), + address=dict(), netmask=dict( type='str', default='255.255.255.255', @@ -593,6 +606,9 @@ class ArgumentSpec(object): self.argument_spec = {} self.argument_spec.update(f5_argument_spec) self.argument_spec.update(argument_spec) + self.required_one_of = [ + ['name', 'address'] + ] def main(): diff --git a/lib/ansible/modules/network/f5/bigip_vlan.py b/lib/ansible/modules/network/f5/bigip_vlan.py index b8285bdea7..9b5b7a7040 100644 --- a/lib/ansible/modules/network/f5/bigip_vlan.py +++ b/lib/ansible/modules/network/f5/bigip_vlan.py @@ -18,7 +18,7 @@ module: bigip_vlan short_description: Manage VLANs on a BIG-IP system description: - Manage VLANs on a BIG-IP system -version_added: "2.2" +version_added: 2.2 options: description: description: @@ -71,6 +71,17 @@ options: specifies that the default CMP hash uses L4 ports. - When creating a new VLAN, if this parameter is not specified, the default of C(default) is used. + choices: + - default + - destination-address + - source-address + - dst-ip + - src-ip + - dest + - destination + - source + - dst + - src version_added: 2.5 dag_tunnel: description: @@ -82,6 +93,9 @@ options: of C(outer) is used. - This parameter is not supported on Virtual Editions of BIG-IP. version_added: 2.5 + choices: + - inner + - outer dag_round_robin: description: - Specifies whether some of the stateless traffic on the VLAN should be @@ -187,27 +201,22 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import env_fallback try: - # Sideband repository used for dev 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.common import F5ModuleError 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 fqdn_name from library.module_utils.network.f5.common import f5_argument_spec try: from library.module_utils.network.f5.common import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False - HAS_DEVEL_IMPORTS = True except ImportError: - # Upstream Ansible 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.common import F5ModuleError 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 fqdn_name from ansible.module_utils.network.f5.common import f5_argument_spec try: from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 2d7f9d7d36..d8a2476faa 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -1172,10 +1172,7 @@ 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_ucs.py E325 lib/ansible/modules/network/f5/bigip_ucs.py E326 -lib/ansible/modules/network/f5/bigip_user.py E324 -lib/ansible/modules/network/f5/bigip_vcmp_guest.py E325 lib/ansible/modules/network/f5/bigip_virtual_server.py E326 -lib/ansible/modules/network/f5/bigip_vlan.py E326 lib/ansible/modules/network/f5/bigiq_regkey_license.py E325 lib/ansible/modules/network/fortimanager/fmgr_script.py E324 lib/ansible/modules/network/fortios/fortios_address.py E324 diff --git a/test/units/modules/network/f5/test_bigip_user.py b/test/units/modules/network/f5/test_bigip_user.py index 3e53c019c0..b21e77d8ab 100644 --- a/test/units/modules/network/f5/test_bigip_user.py +++ b/test/units/modules/network/f5/test_bigip_user.py @@ -21,11 +21,11 @@ from ansible.compat.tests.mock import patch from ansible.module_utils.basic import AnsibleModule try: - from library.bigip_user import Parameters - from library.bigip_user import ModuleManager - from library.bigip_user import ArgumentSpec - from library.bigip_user import UnparitionedManager - from library.bigip_user import PartitionedManager + from library.modules.bigip_user import Parameters + from library.modules.bigip_user import ModuleManager + from library.modules.bigip_user import ArgumentSpec + from library.modules.bigip_user import UnparitionedManager + from library.modules.bigip_user import PartitionedManager from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from test.unit.modules.utils import set_module_args diff --git a/test/units/modules/network/f5/test_bigip_vcmp_guest.py b/test/units/modules/network/f5/test_bigip_vcmp_guest.py index 91913ab8a8..1bdec45b01 100644 --- a/test/units/modules/network/f5/test_bigip_vcmp_guest.py +++ b/test/units/modules/network/f5/test_bigip_vcmp_guest.py @@ -21,9 +21,9 @@ from ansible.compat.tests.mock import patch from ansible.module_utils.basic import AnsibleModule try: - from library.bigip_vcmp_guest import Parameters - from library.bigip_vcmp_guest import ModuleManager - from library.bigip_vcmp_guest import ArgumentSpec + from library.modules.bigip_vcmp_guest import Parameters + from library.modules.bigip_vcmp_guest import ModuleManager + from library.modules.bigip_vcmp_guest import ArgumentSpec from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from test.unit.modules.utils import set_module_args diff --git a/test/units/modules/network/f5/test_bigip_virtual_address.py b/test/units/modules/network/f5/test_bigip_virtual_address.py index dbb5ee389b..be3536ac54 100644 --- a/test/units/modules/network/f5/test_bigip_virtual_address.py +++ b/test/units/modules/network/f5/test_bigip_virtual_address.py @@ -20,9 +20,9 @@ from ansible.compat.tests.mock import patch from ansible.module_utils.basic import AnsibleModule try: - from library.bigip_virtual_address import Parameters - from library.bigip_virtual_address import ModuleManager - from library.bigip_virtual_address import ArgumentSpec + from library.modules.bigip_virtual_address import Parameters + from library.modules.bigip_virtual_address import ModuleManager + from library.modules.bigip_virtual_address import ArgumentSpec from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from test.unit.modules.utils import set_module_args diff --git a/test/units/modules/network/f5/test_bigip_vlan.py b/test/units/modules/network/f5/test_bigip_vlan.py index 322e233b69..a98c2cafe3 100644 --- a/test/units/modules/network/f5/test_bigip_vlan.py +++ b/test/units/modules/network/f5/test_bigip_vlan.py @@ -20,10 +20,10 @@ from ansible.compat.tests.mock import patch from ansible.module_utils.basic import AnsibleModule try: - from library.bigip_vlan import ApiParameters - from library.bigip_vlan import ModuleParameters - from library.bigip_vlan import ModuleManager - from library.bigip_vlan import ArgumentSpec + from library.modules.bigip_vlan import ApiParameters + from library.modules.bigip_vlan import ModuleParameters + from library.modules.bigip_vlan import ModuleManager + from library.modules.bigip_vlan import ArgumentSpec from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from test.unit.modules.utils import set_module_args