Refactor iosxr_config to make use of network_connection plugin

This commit is contained in:
Ricardo Carrillo Cruz 2017-01-23 10:44:13 +01:00
commit a8cfe4a5d7
5 changed files with 257 additions and 49 deletions

View file

@ -55,7 +55,7 @@ def run_commands(module, commands, check_rc=True):
responses.append(out)
return responses
def load_config(module, commands, commit=False, replace=False):
def load_config(module, commands, commit=False, replace=False, comment=None):
assert isinstance(commands, list), 'commands must be a list'
rc, out, err = module.exec_command('configure terminal')
@ -79,8 +79,11 @@ def load_config(module, commands, commit=False, replace=False):
rc, diff, err = module.exec_command('show commit changes diff')
if commit:
cmd = 'commit'
if comment:
cmd += ' comment {0}'.format(comment)
else:
cmd = 'abort'
diff = None
module.exec_command(cmd)
return {'diff': diff}
return diff