Adds aggregate functionality to the module (#51639)

This commit is contained in:
Wojciech Wypior 2019-02-02 02:03:45 +00:00 committed by Tim Rupp
parent a5c630a81f
commit 803bf79dce
2 changed files with 460 additions and 100 deletions

View file

@ -84,11 +84,6 @@ class TestParameters(unittest.TestCase):
partition='Common',
fqdn_auto_populate=False,
reuse_nodes=False,
# Deprecated params
# TODO(Remove in 2.7)
session_state='disabled',
monitor_state='disabled',
)
p = ModuleParameters(params=args)
@ -109,20 +104,24 @@ class TestManager(unittest.TestCase):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='my-name',
fqdn='foo.bar.com',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
password='password',
server='localhost',
user='admin'
provider=dict(
password='password',
server='localhost',
user='admin'
)
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_fqdn.json'))
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)
@ -142,20 +141,24 @@ class TestManager(unittest.TestCase):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='7.3.67.8',
address='7.3.67.8',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
password='password',
server='localhost',
user='admin'
provider=dict(
password='password',
server='localhost',
user='admin'
)
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_ipv4_address.json'))
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)
@ -175,21 +178,25 @@ class TestManager(unittest.TestCase):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='my-name',
fqdn='foo.bar.com',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
fqdn_auto_populate=False,
password='password',
server='localhost',
user='admin'
provider=dict(
password='password',
server='localhost',
user='admin'
)
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_fqdn.json'))
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)
@ -204,3 +211,48 @@ class TestManager(unittest.TestCase):
assert results['fqdn_auto_populate'] is True
assert results['fqdn'] == 'foo.bar.com'
assert results['state'] == 'present'
def test_create_aggregate_pool_members(self, *args):
set_module_args(dict(
pool='fake_pool',
aggregate=[
dict(
name='my-name',
host="1.1.1.1",
port=1234,
state='present',
partition='Common',
reuse_nodes=True,
fqdn_auto_populate=False,
),
dict(
name='my-name2',
fqdn='google.com',
port=2423,
state='present',
partition='Common',
fqdn_auto_populate=True,
reuse_nodes=True,
)
],
provider=dict(
password='password',
server='localhost',
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