Various fixes and changes for F5 (#34817)

Primarily, this patch contains refactors to remove tracebacks that
are generated when libraries are missing. There is also,

* Removed re-def of cleanup_tokens.
* Changed parameter args to be keywords.
* Changed imports to include new module_util locations.
* Imports also include developing (sideband) module_util locations.
* Changed to using F5Client and plain AnsibleModule to prevent tracebacks caused by missing libraries.
* Removed init and update methods from most Parameter classes (optimization) as its now included in module_utils.
* Changed module and module param references to take into account the new self.module arg. Minor bug fixes made during this refactor.
This commit is contained in:
Tim Rupp 2018-01-12 13:23:19 -08:00 committed by GitHub
commit eace686044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 860 additions and 958 deletions

View file

@ -17,14 +17,15 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_gtm_datacenter import ApiParameters
from library.bigip_gtm_datacenter import ModuleParameters
from library.bigip_gtm_datacenter import ModuleManager
from library.bigip_gtm_datacenter import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
@ -32,7 +33,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_gtm_datacenter import ModuleParameters
from ansible.modules.network.f5.bigip_gtm_datacenter import ModuleManager
from ansible.modules.network.f5.bigip_gtm_datacenter import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -68,19 +70,19 @@ class TestParameters(unittest.TestCase):
location='baz',
name='datacenter'
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.state == 'present'
def test_api_parameters(self):
args = load_fixture('load_gtm_datacenter_default.json')
p = ApiParameters(args)
p = ApiParameters(params=args)
assert p.name == 'asd'
def test_module_parameters_state_present(self):
args = dict(
state='present'
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.state == 'present'
assert p.enabled is True
@ -88,14 +90,14 @@ class TestParameters(unittest.TestCase):
args = dict(
state='absent'
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.state == 'absent'
def test_module_parameters_state_enabled(self):
args = dict(
state='enabled'
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.state == 'enabled'
assert p.enabled is True
assert p.disabled is None
@ -104,14 +106,12 @@ class TestParameters(unittest.TestCase):
args = dict(
state='disabled'
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.state == 'disabled'
assert p.enabled is None
assert p.disabled is True
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -126,12 +126,11 @@ class TestManager(unittest.TestCase):
name='foo'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])
@ -150,12 +149,11 @@ class TestManager(unittest.TestCase):
name='foo'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])
@ -175,12 +173,11 @@ class TestManager(unittest.TestCase):
name='foo'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])
@ -200,15 +197,14 @@ class TestManager(unittest.TestCase):
name='foo'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
current = ApiParameters(load_fixture('load_gtm_datacenter_disabled.json'))
current = ApiParameters(params=load_fixture('load_gtm_datacenter_disabled.json'))
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=True)

View file

@ -17,7 +17,7 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
try:
@ -34,7 +34,8 @@ try:
from library.bigip_gtm_facts import TypedWideIpFactManager
from library.bigip_gtm_facts import UntypedWideIpFactManager
from library.bigip_gtm_facts import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from f5.bigip.tm.gtm.pool import A
from f5.utils.responses.handlers import Stats
from test.unit.modules.utils import set_module_args
@ -53,7 +54,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_gtm_pool import TypedWideIpFactManager
from ansible.modules.network.f5.bigip_gtm_pool import UntypedWideIpFactManager
from ansible.modules.network.f5.bigip_gtm_pool import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from f5.bigip.tm.gtm.pool import A
from f5.utils.responses.handlers import Stats
from units.modules.utils import set_module_args
@ -100,13 +102,11 @@ class TestParameters(unittest.TestCase):
include=['pool'],
filter='name.*'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.include == ['pool']
assert p.filter == 'name.*'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -125,23 +125,22 @@ class TestManager(unittest.TestCase):
collection = [FakeARecord(attrs=x) for x in fixture1['items']]
stats = Stats(FakeStatResource(fixture2['entries']))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tfm = TypedPoolFactManager(client)
tfm = TypedPoolFactManager(module=module)
tfm.read_collection_from_device = Mock(return_value=collection)
tfm.read_stats_from_device = Mock(return_value=stats.stat)
tm = PoolFactManager(client)
tm = PoolFactManager(module=module)
tm.version_is_less_than_12 = Mock(return_value=False)
tm.get_manager = Mock(return_value=tfm)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)

View file

@ -17,7 +17,7 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_gtm_pool import Parameters
@ -25,7 +25,8 @@ try:
from library.bigip_gtm_pool import ArgumentSpec
from library.bigip_gtm_pool import UntypedManager
from library.bigip_gtm_pool import TypedManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
@ -34,7 +35,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_gtm_pool import ArgumentSpec
from ansible.modules.network.f5.bigip_gtm_pool import UntypedManager
from ansible.modules.network.f5.bigip_gtm_pool import TypedManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -71,7 +73,7 @@ class TestParameters(unittest.TestCase):
fallback_ip='10.10.10.10',
type='a'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.name == 'foo'
assert p.preferred_lb_method == 'topology'
assert p.alternate_lb_method == 'ratio'
@ -87,7 +89,7 @@ class TestParameters(unittest.TestCase):
fallbackMode='fewest-hops',
fallbackIp='10.10.10.10'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.name == 'foo'
assert p.preferred_lb_method == 'topology'
assert p.alternate_lb_method == 'ratio'
@ -95,8 +97,6 @@ class TestParameters(unittest.TestCase):
assert p.fallback_ip == '10.10.10.10'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestUntypedManager(unittest.TestCase):
def setUp(self):
@ -111,19 +111,18 @@ class TestUntypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = UntypedManager(client)
tm = UntypedManager(module=module)
tm.exists = Mock(side_effect=[False, True])
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=True)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)
@ -144,22 +143,21 @@ class TestUntypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
current = Parameters(load_fixture('load_gtm_pool_untyped_default.json'))
current = Parameters(params=load_fixture('load_gtm_pool_untyped_default.json'))
# Override methods in the specific type of manager
tm = UntypedManager(client)
tm = UntypedManager(module=module)
tm.exists = Mock(side_effect=[True, True])
tm.update_on_device = Mock(return_value=True)
tm.read_current_from_device = Mock(return_value=current)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=True)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)
@ -180,19 +178,18 @@ class TestUntypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = UntypedManager(client)
tm = UntypedManager(module=module)
tm.exists = Mock(side_effect=[True, False])
tm.remove_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=True)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)
@ -202,8 +199,6 @@ class TestUntypedManager(unittest.TestCase):
assert results['changed'] is True
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestTypedManager(unittest.TestCase):
def setUp(self):
@ -219,19 +214,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module)
tm.exists = Mock(side_effect=[False, True])
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)
@ -253,22 +247,21 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
current = Parameters(load_fixture('load_gtm_pool_a_default.json'))
current = Parameters(params=load_fixture('load_gtm_pool_a_default.json'))
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module)
tm.exists = Mock(side_effect=[True, True])
tm.update_on_device = Mock(return_value=True)
tm.read_current_from_device = Mock(return_value=current)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)
@ -290,19 +283,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module)
tm.exists = Mock(side_effect=[True, False])
tm.remove_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
mm.gtm_provisioned = Mock(return_value=True)

View file

@ -18,8 +18,7 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.f5_utils import F5ModuleError
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_gtm_server import ApiParameters
@ -28,7 +27,8 @@ try:
from library.bigip_gtm_server import V1Manager
from library.bigip_gtm_server import V2Manager
from library.bigip_gtm_server import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
@ -38,7 +38,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_gtm_server import V1Manager
from ansible.modules.network.f5.bigip_gtm_server import V2Manager
from ansible.modules.network.f5.bigip_gtm_server import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -114,7 +115,7 @@ class TestParameters(unittest.TestCase):
]
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.name == 'GTM_Server'
assert p.datacenter == '/Common/New York'
assert p.server_type == 'bigip'
@ -124,7 +125,7 @@ class TestParameters(unittest.TestCase):
def test_api_parameters(self):
args = load_fixture('load_gtm_server_1.json')
p = ApiParameters(args)
p = ApiParameters(params=args)
assert p.name == 'baz'
assert p.datacenter == '/Common/foo'
assert p.server_type == 'bigip'
@ -132,8 +133,6 @@ class TestParameters(unittest.TestCase):
assert p.virtual_server_discovery == 'disabled'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestV1Manager(unittest.TestCase):
def setUp(self):
@ -189,18 +188,17 @@ class TestV1Manager(unittest.TestCase):
]
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
m1 = V1Manager(client)
m1 = V1Manager(module=module, params=module.params)
m1.exists = Mock(side_effect=[False, True])
m1.create_on_device = Mock(return_value=True)
# Override methods in the specific type of manager
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=m1)
mm.version_is_less_than = Mock(return_value=True)
mm.gtm_provisioned = Mock(return_value=True)
@ -211,8 +209,6 @@ class TestV1Manager(unittest.TestCase):
assert results['server_type'] == 'bigip'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestV2Manager(unittest.TestCase):
def setUp(self):
@ -268,18 +264,17 @@ class TestV2Manager(unittest.TestCase):
]
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
m1 = V2Manager(client)
m1 = V2Manager(module=module)
m1.exists = Mock(side_effect=[False, True])
m1.create_on_device = Mock(return_value=True)
# Override methods in the specific type of manager
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=m1)
mm.version_is_less_than = Mock(return_value=False)
mm.gtm_provisioned = Mock(return_value=True)

View file

@ -18,8 +18,7 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.f5_utils import F5ModuleError
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_gtm_wide_ip import ApiParameters
@ -28,7 +27,8 @@ try:
from library.bigip_gtm_wide_ip import ArgumentSpec
from library.bigip_gtm_wide_ip import UntypedManager
from library.bigip_gtm_wide_ip import TypedManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
@ -38,7 +38,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_gtm_wide_ip import ArgumentSpec
from ansible.modules.network.f5.bigip_gtm_wide_ip import UntypedManager
from ansible.modules.network.f5.bigip_gtm_wide_ip import TypedManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -71,7 +72,7 @@ class TestParameters(unittest.TestCase):
name='foo.baz.bar',
lb_method='round-robin',
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.name == 'foo.baz.bar'
assert p.pool_lb_method == 'round-robin'
@ -84,7 +85,7 @@ class TestParameters(unittest.TestCase):
)
]
)
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert len(p.pools) == 1
def test_api_parameters(self):
@ -92,13 +93,13 @@ class TestParameters(unittest.TestCase):
name='foo.baz.bar',
poolLbMode='round-robin'
)
p = ApiParameters(args)
p = ApiParameters(params=args)
assert p.name == 'foo.baz.bar'
assert p.pool_lb_method == 'round-robin'
def test_api_pools(self):
args = load_fixture('load_gtm_wide_ip_with_pools.json')
p = ApiParameters(args)
p = ApiParameters(params=args)
assert len(p.pools) == 1
assert 'name' in p.pools[0]
assert 'ratio' in p.pools[0]
@ -111,13 +112,11 @@ class TestParameters(unittest.TestCase):
lb_method='round-robin'
)
with pytest.raises(F5ModuleError) as excinfo:
p = ModuleParameters(args)
p = ModuleParameters(params=args)
assert p.name == 'foo.baz'
assert 'The provided name must be a valid FQDN' in str(excinfo)
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestUntypedManager(unittest.TestCase):
def setUp(self):
@ -132,19 +131,18 @@ class TestUntypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = UntypedManager(client)
tm = UntypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=False)
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=True)
mm.get_manager = Mock(return_value=tm)
@ -156,8 +154,6 @@ class TestUntypedManager(unittest.TestCase):
assert results['lb_method'] == 'round-robin'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestTypedManager(unittest.TestCase):
def setUp(self):
@ -173,19 +169,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=False)
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
@ -206,19 +201,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=False)
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
@ -239,19 +233,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=False)
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
@ -278,19 +271,18 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=False)
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
@ -317,20 +309,19 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
current = ApiParameters(load_fixture('load_gtm_wide_ip_with_pools.json'))
client = AnsibleF5Client(
current = ApiParameters(params=load_fixture('load_gtm_wide_ip_with_pools.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=True)
tm.read_current_from_device = Mock(return_value=current)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)
@ -358,21 +349,20 @@ class TestTypedManager(unittest.TestCase):
user='admin'
))
current = ApiParameters(load_fixture('load_gtm_wide_ip_with_pools.json'))
client = AnsibleF5Client(
current = ApiParameters(params=load_fixture('load_gtm_wide_ip_with_pools.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods in the specific type of manager
tm = TypedManager(client)
tm = TypedManager(module=module, params=module.params)
tm.exists = Mock(return_value=True)
tm.read_current_from_device = Mock(return_value=current)
tm.update_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.version_is_less_than_12 = Mock(return_value=False)
mm.get_manager = Mock(return_value=tm)

View file

@ -17,20 +17,22 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_hostname import Parameters
from library.bigip_hostname import ModuleManager
from library.bigip_hostname import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
from ansible.modules.network.f5.bigip_hostname import Parameters
from ansible.modules.network.f5.bigip_hostname import ModuleManager
from ansible.modules.network.f5.bigip_hostname import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -62,12 +64,10 @@ class TestParameters(unittest.TestCase):
args = dict(
hostname='foo.internal.com'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.hostname == 'foo.internal.com'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -88,14 +88,13 @@ class TestManager(unittest.TestCase):
hostname='foo.internal.com'
)
)
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.update_on_device = Mock(return_value=True)
mm.read_current_from_device = Mock(return_value=current)

View file

@ -17,20 +17,22 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_iapp_service import Parameters
from library.bigip_iapp_service import ModuleManager
from library.bigip_iapp_service import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
from ansible.modules.network.f5.bigip_iapp_service import Parameters
from ansible.modules.network.f5.bigip_iapp_service import ModuleManager
from ansible.modules.network.f5.bigip_iapp_service import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -61,7 +63,7 @@ class TestParameters(unittest.TestCase):
def test_module_parameters_keys(self):
args = load_fixture('create_iapp_service_parameters_f5_http.json')
p = Parameters(args)
p = Parameters(params=args)
# Assert the top-level keys
assert p.name == 'http_example'
@ -74,7 +76,7 @@ class TestParameters(unittest.TestCase):
def test_module_parameters_lists(self):
args = load_fixture('create_iapp_service_parameters_f5_http.json')
p = Parameters(args)
p = Parameters(params=args)
assert 'lists' in p._values
@ -90,7 +92,7 @@ class TestParameters(unittest.TestCase):
def test_module_parameters_tables(self):
args = load_fixture('create_iapp_service_parameters_f5_http.json')
p = Parameters(args)
p = Parameters(params=args)
assert 'tables' in p._values
@ -117,7 +119,7 @@ class TestParameters(unittest.TestCase):
def test_module_parameters_variables(self):
args = load_fixture('create_iapp_service_parameters_f5_http.json')
p = Parameters(args)
p = Parameters(params=args)
assert 'variables' in p._values
assert len(p.variables) == 34
@ -140,13 +142,13 @@ class TestParameters(unittest.TestCase):
args = dict(
strict_updates=True
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'enabled'
args = dict(
strict_updates=False
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'disabled'
def test_module_strict_updates_override_from_top_level(self):
@ -156,7 +158,7 @@ class TestParameters(unittest.TestCase):
strictUpdates='disabled'
)
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'enabled'
args = dict(
@ -165,7 +167,7 @@ class TestParameters(unittest.TestCase):
strictUpdates='enabled'
)
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'disabled'
def test_module_strict_updates_only_parameters(self):
@ -174,7 +176,7 @@ class TestParameters(unittest.TestCase):
strictUpdates='disabled'
)
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'disabled'
args = dict(
@ -182,20 +184,20 @@ class TestParameters(unittest.TestCase):
strictUpdates='enabled'
)
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'enabled'
def test_api_strict_updates_from_top_level(self):
args = dict(
strictUpdates='enabled'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'enabled'
args = dict(
strictUpdates='disabled'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.strict_updates == 'disabled'
def test_api_parameters_variables(self):
@ -208,7 +210,7 @@ class TestParameters(unittest.TestCase):
)
]
)
p = Parameters(args)
p = Parameters(params=args)
assert p.variables[0]['name'] == 'client__http_compression'
def test_api_parameters_tables(self):
@ -240,7 +242,7 @@ class TestParameters(unittest.TestCase):
}
]
)
p = Parameters(args)
p = Parameters(params=args)
assert p.tables[0]['name'] == 'pool__members'
assert p.tables[0]['columnNames'] == ['addr', 'port', 'connection_limit']
assert len(p.tables[0]['rows']) == 2
@ -253,28 +255,28 @@ class TestParameters(unittest.TestCase):
args = dict(
deviceGroup='none'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.deviceGroup == 'none'
def test_api_parameters_inherited_traffic_group(self):
args = dict(
inheritedTrafficGroup='true'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.inheritedTrafficGroup == 'true'
def test_api_parameters_inherited_devicegroup(self):
args = dict(
inheritedDevicegroup='true'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.inheritedDevicegroup == 'true'
def test_api_parameters_traffic_group(self):
args = dict(
trafficGroup='/Common/traffic-group-local-only'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.traffic_group == '/Common/traffic-group-local-only'
def test_module_template_same_partition(self):
@ -282,7 +284,7 @@ class TestParameters(unittest.TestCase):
template='foo',
partition='bar'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.template == '/bar/foo'
def test_module_template_same_partition_full_path(self):
@ -290,7 +292,7 @@ class TestParameters(unittest.TestCase):
template='/bar/foo',
partition='bar'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.template == '/bar/foo'
def test_module_template_different_partition_full_path(self):
@ -298,12 +300,10 @@ class TestParameters(unittest.TestCase):
template='/Common/foo',
partition='bar'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.template == '/Common/foo'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -321,12 +321,11 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
@ -352,12 +351,11 @@ class TestManager(unittest.TestCase):
parameters = load_fixture('create_iapp_service_parameters_f5_http.json')
current = Parameters(parameters)
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=True)

View file

@ -17,20 +17,22 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_iapp_template import Parameters
from library.bigip_iapp_template import ModuleManager
from library.bigip_iapp_template import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
from ansible.modules.network.f5.bigip_iapp_template import Parameters
from ansible.modules.network.f5.bigip_iapp_template import ArgumentSpec
from ansible.modules.network.f5.bigip_iapp_template import ModuleManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -63,12 +65,10 @@ class TestParameters(unittest.TestCase):
args = dict(
content=iapp
)
p = Parameters(args)
p = Parameters(params=args)
assert p.name == 'foo.iapp'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -83,12 +83,11 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])
@ -107,14 +106,13 @@ class TestManager(unittest.TestCase):
user='admin'
))
current1 = Parameters(load_fixture('load_sys_application_template_w_new_checksum.json'))
current2 = Parameters(load_fixture('load_sys_application_template_w_old_checksum.json'))
client = AnsibleF5Client(
current1 = Parameters(params=load_fixture('load_sys_application_template_w_new_checksum.json'))
current2 = Parameters(params=load_fixture('load_sys_application_template_w_old_checksum.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[True, True])
@ -138,12 +136,11 @@ class TestManager(unittest.TestCase):
state='absent'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[True, False])
@ -162,12 +159,11 @@ class TestManager(unittest.TestCase):
state='absent'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, False])

View file

@ -17,20 +17,22 @@ if sys.version_info < (2, 7):
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_iapp_template import Parameters
from library.bigip_iapp_template import ModuleManager
from library.bigip_iapp_template import ArgumentSpec
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
from ansible.modules.network.f5.bigip_iapp_template import Parameters
from ansible.modules.network.f5.bigip_iapp_template import ArgumentSpec
from ansible.modules.network.f5.bigip_iapp_template import ModuleManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -63,12 +65,10 @@ class TestParameters(unittest.TestCase):
package='MyApp-0.1.0-0001.noarch.rpm',
state='present'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.package == 'MyApp-0.1.0-0001.noarch.rpm'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -84,12 +84,11 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(client)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(side_effect=[False, True])

View file

@ -18,7 +18,7 @@ from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.compat.tests.mock import mock_open
from ansible.module_utils.f5_utils import AnsibleF5Client
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import PY3
try:
@ -27,7 +27,8 @@ try:
from library.bigip_irule import ArgumentSpec
from library.bigip_irule import GtmManager
from library.bigip_irule import LtmManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
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
except ImportError:
try:
@ -36,7 +37,8 @@ except ImportError:
from ansible.modules.network.f5.bigip_irule import ArgumentSpec
from ansible.modules.network.f5.bigip_irule import GtmManager
from ansible.modules.network.f5.bigip_irule import LtmManager
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -77,7 +79,7 @@ class TestParameters(unittest.TestCase):
name='foo',
state='present'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.content == content.strip()
def test_module_parameters_gtm(self):
@ -88,7 +90,7 @@ class TestParameters(unittest.TestCase):
name='foo',
state='present'
)
p = Parameters(args)
p = Parameters(params=args)
assert p.content == content.strip()
def test_api_parameters_ltm(self):
@ -96,7 +98,7 @@ class TestParameters(unittest.TestCase):
args = dict(
apiAnonymous=content
)
p = Parameters(args)
p = Parameters(params=args)
assert p.content == content.strip()
def test_return_api_params(self):
@ -107,14 +109,12 @@ class TestParameters(unittest.TestCase):
name='foo',
state='present'
)
p = Parameters(args)
p = Parameters(params=args)
params = p.api_params()
assert 'apiAnonymous' in params
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
@ -141,20 +141,19 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name,
mutually_exclusive=self.spec.mutually_exclusive,
)
# Override methods in the specific type of manager
tm = LtmManager(client)
tm = LtmManager(module=module, params=module.params)
tm.exists = Mock(side_effect=[False, True])
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=tm)
results = mm.exec_module()
@ -173,20 +172,19 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name,
mutually_exclusive=self.spec.mutually_exclusive,
)
# Override methods in the specific type of manager
tm = GtmManager(client)
tm = GtmManager(module=module, params=module.params)
tm.exists = Mock(side_effect=[False, True])
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=tm)
results = mm.exec_module()
@ -205,10 +203,9 @@ class TestManager(unittest.TestCase):
user='admin'
))
client = AnsibleF5Client(
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name,
mutually_exclusive=self.spec.mutually_exclusive,
)
@ -219,12 +216,12 @@ class TestManager(unittest.TestCase):
with patch(builtins_name + '.open', mock_open(read_data='this is my content'), create=True):
# Override methods in the specific type of manager
tm = GtmManager(client)
tm = GtmManager(module=module, params=module.params)
tm.exists = Mock(side_effect=[False, True])
tm.create_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(client)
mm = ModuleManager(module=module)
mm.get_manager = Mock(return_value=tm)
results = mm.exec_module()
@ -249,10 +246,9 @@ class TestManager(unittest.TestCase):
))
with patch('ansible.module_utils.basic.AnsibleModule.fail_json', unsafe=True) as mo:
AnsibleF5Client(
AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name,
mutually_exclusive=self.spec.mutually_exclusive,
)
mo.assert_called_once()