mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 12:44:22 -07:00
* Fix Issue #39598 Signed-off-by: Anas Badaha <anasb@mellanox.com> * Fix unit test for onyx_config Signed-off-by: Anas Badaha <anasb@mellanox.com> * Add comments for save running config Signed-off-by: Anas Badaha <anasb@mellanox.com> * Enhance onyx_config bug fix Signed-off-by: Anas Badaha <anasb@mellanox.com> * Fix result['changed'] = True comment Signed-off-by: Anas Badaha <anasb@mellanox.com>
This commit is contained in:
parent
6178a55afd
commit
d2446cbf0f
2 changed files with 11 additions and 13 deletions
|
@ -159,6 +159,7 @@ def run(module, result):
|
||||||
else:
|
else:
|
||||||
configobjs = candidate.items
|
configobjs = candidate.items
|
||||||
|
|
||||||
|
total_commands = []
|
||||||
if configobjs:
|
if configobjs:
|
||||||
commands = dumps(configobjs, 'commands').split('\n')
|
commands = dumps(configobjs, 'commands').split('\n')
|
||||||
|
|
||||||
|
@ -169,18 +170,15 @@ def run(module, result):
|
||||||
if module.params['after']:
|
if module.params['after']:
|
||||||
commands.extend(module.params['after'])
|
commands.extend(module.params['after'])
|
||||||
|
|
||||||
result['updates'] = commands
|
total_commands.extend(commands)
|
||||||
|
result['updates'] = total_commands
|
||||||
# send the configuration commands to the device and merge
|
|
||||||
# them with the current running config
|
|
||||||
if not module.check_mode:
|
|
||||||
load_config(module, commands)
|
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
if module.params['save']:
|
if module.params['save']:
|
||||||
if not module.check_mode:
|
total_commands.append('configuration write')
|
||||||
run_commands(module, 'configuration write')
|
if total_commands:
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
if not module.check_mode:
|
||||||
|
load_config(module, total_commands)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -71,12 +71,12 @@ class TestOnyxConfigModule(TestOnyxModule):
|
||||||
self.assertIn('__backup__', result)
|
self.assertIn('__backup__', result)
|
||||||
|
|
||||||
def test_onyx_config_save(self):
|
def test_onyx_config_save(self):
|
||||||
set_module_args(dict(save='yes'))
|
set_module_args(dict(lines=['hostname foo'], save='yes'))
|
||||||
self.execute_module(changed=True)
|
self.execute_module(changed=True)
|
||||||
self.assertEqual(self.run_commands.call_count, 1)
|
self.assertEqual(self.run_commands.call_count, 0)
|
||||||
self.assertEqual(self.get_config.call_count, 1)
|
self.assertEqual(self.get_config.call_count, 1)
|
||||||
self.assertEqual(self.load_config.call_count, 0)
|
self.assertEqual(self.load_config.call_count, 1)
|
||||||
args = self.run_commands.call_args[0][1]
|
args = self.load_config.call_args[0][1]
|
||||||
self.assertIn('configuration write', args)
|
self.assertIn('configuration write', args)
|
||||||
|
|
||||||
def test_onyx_config_lines_wo_parents(self):
|
def test_onyx_config_lines_wo_parents(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue