mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Adds aggregate functionality to the module (#51638)
This commit is contained in:
committed by
Tim Rupp
parent
803bf79dce
commit
cccb681c0a
@@ -132,14 +132,18 @@ class TestManager(unittest.TestCase):
|
||||
partition='Common',
|
||||
slow_ramp_time=10,
|
||||
reselect_tries=1,
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -162,14 +166,18 @@ class TestManager(unittest.TestCase):
|
||||
lb_method='round-robin',
|
||||
partition='Common',
|
||||
monitors=['/Common/tcp', '/Common/http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -189,14 +197,18 @@ class TestManager(unittest.TestCase):
|
||||
lb_method='round-robin',
|
||||
partition='Common',
|
||||
monitor_type='and_list',
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -217,14 +229,18 @@ class TestManager(unittest.TestCase):
|
||||
partition='Common',
|
||||
monitor_type='m_of_n',
|
||||
monitors=['/Common/tcp', '/Common/http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -243,14 +259,18 @@ class TestManager(unittest.TestCase):
|
||||
partition='Common',
|
||||
monitor_type='and_list',
|
||||
monitors=['/Common/tcp', '/Common/http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -271,14 +291,18 @@ class TestManager(unittest.TestCase):
|
||||
monitor_type='m_of_n',
|
||||
quorum=1,
|
||||
monitors=['/Common/tcp', '/Common/http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -298,15 +322,20 @@ class TestManager(unittest.TestCase):
|
||||
partition='Common',
|
||||
monitor_type='and_list',
|
||||
monitors=['/Common/http', '/Common/tcp'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_ltm_pool.json'))
|
||||
@@ -325,14 +354,18 @@ class TestManager(unittest.TestCase):
|
||||
pool='fake_pool',
|
||||
monitor_type='and_list',
|
||||
monitors=['tcp', 'http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -352,14 +385,18 @@ class TestManager(unittest.TestCase):
|
||||
monitor_type='m_of_n',
|
||||
quorum=1,
|
||||
monitors=['tcp', 'http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -379,14 +416,18 @@ class TestManager(unittest.TestCase):
|
||||
partition='Testing',
|
||||
monitor_type='and_list',
|
||||
monitors=['tcp', 'http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -407,14 +448,18 @@ class TestManager(unittest.TestCase):
|
||||
monitor_type='m_of_n',
|
||||
quorum=1,
|
||||
monitors=['tcp', 'http'],
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -432,14 +477,18 @@ class TestManager(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
pool='fake_pool',
|
||||
metadata=dict(ansible='2.4'),
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
@@ -453,3 +502,47 @@ class TestManager(unittest.TestCase):
|
||||
assert 'metadata' in results
|
||||
assert 'ansible' in results['metadata']
|
||||
assert results['metadata']['ansible'] == '2.4'
|
||||
|
||||
def test_create_aggregate_pools(self, *args):
|
||||
set_module_args(dict(
|
||||
aggregate=[
|
||||
dict(
|
||||
pool='fake_pool',
|
||||
description='fakepool',
|
||||
service_down_action='drop',
|
||||
lb_method='round-robin',
|
||||
partition='Common',
|
||||
slow_ramp_time=10,
|
||||
reselect_tries=1,
|
||||
),
|
||||
dict(
|
||||
pool='fake_pool2',
|
||||
description='fakepool2',
|
||||
service_down_action='drop',
|
||||
lb_method='predictive-node',
|
||||
partition='Common',
|
||||
slow_ramp_time=110,
|
||||
reselect_tries=2,
|
||||
)
|
||||
],
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive,
|
||||
required_one_of=self.spec.required_one_of
|
||||
)
|
||||
|
||||
mm = ModuleManager(module=module)
|
||||
mm.create_on_device = Mock(return_value=True)
|
||||
mm.exists = Mock(return_value=False)
|
||||
|
||||
results = mm.exec_module()
|
||||
|
||||
assert results['changed'] is True
|
||||
|
||||
Reference in New Issue
Block a user