* 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:
|
||||
configobjs = candidate.items
|
||||
|
||||
total_commands = []
|
||||
if configobjs:
|
||||
commands = dumps(configobjs, 'commands').split('\n')
|
||||
|
||||
|
@ -169,18 +170,15 @@ def run(module, result):
|
|||
if module.params['after']:
|
||||
commands.extend(module.params['after'])
|
||||
|
||||
result['updates'] = 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
|
||||
total_commands.extend(commands)
|
||||
result['updates'] = total_commands
|
||||
|
||||
if module.params['save']:
|
||||
if not module.check_mode:
|
||||
run_commands(module, 'configuration write')
|
||||
total_commands.append('configuration write')
|
||||
if total_commands:
|
||||
result['changed'] = True
|
||||
if not module.check_mode:
|
||||
load_config(module, total_commands)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -71,12 +71,12 @@ class TestOnyxConfigModule(TestOnyxModule):
|
|||
self.assertIn('__backup__', result)
|
||||
|
||||
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.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.load_config.call_count, 0)
|
||||
args = self.run_commands.call_args[0][1]
|
||||
self.assertEqual(self.load_config.call_count, 1)
|
||||
args = self.load_config.call_args[0][1]
|
||||
self.assertIn('configuration write', args)
|
||||
|
||||
def test_onyx_config_lines_wo_parents(self):
|
||||
|
|
Loading…
Reference in a new issue