diff options
author | Peter Sprygada <psprygada@ansible.com> | 2016-08-26 13:16:18 -0400 |
---|---|---|
committer | Peter Sprygada <psprygada@ansible.com> | 2016-08-26 13:16:18 -0400 |
commit | eac7caefd80bcddfe22a2fe3ddfcf50453d11466 (patch) | |
tree | e72055dd5971e3d0a63ae14867366772f51996f3 | |
parent | fb9b98a5435cc3506e2dfaf75c1d8998582f99df (diff) | |
download | ansible-eac7caefd80bcddfe22a2fe3ddfcf50453d11466.tar.gz |
add commit keyword arg to load_config method
this adds a new keyword arg to the load_config method that will control
whether or not a loaded configuration is committed on the device
-rw-r--r-- | lib/ansible/module_utils/iosxr.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/ansible/module_utils/iosxr.py b/lib/ansible/module_utils/iosxr.py index c3f50370df..4b54446fff 100644 --- a/lib/ansible/module_utils/iosxr.py +++ b/lib/ansible/module_utils/iosxr.py @@ -64,7 +64,7 @@ class Cli(CliBase): responses = self.execute(cmds) return responses - ### immplementation of netcfg.Config ### + ### implementation of netcfg.Config ### def configure(self, commands, **kwargs): cmds = ['configure terminal'] @@ -81,7 +81,7 @@ class Cli(CliBase): cmd += ' %s' % flags return self.execute([cmd])[0] - def load_config(self, config, replace=False, commit=False, **kwargs): + def load_config(self, config, commit=False, replace=False, comment=None): commands = ['configure terminal'] commands.extend(config) @@ -94,19 +94,22 @@ class Cli(CliBase): if commit: if replace: prompt = re.compile(r'\[no\]:\s$') - cmd = Command('commit replace', prompt=prompt, - response='yes') + commit = 'commit replace' + if comment: + commit += ' comment %s' % comment + cmd = Command(commit, prompt=prompt, response='yes') self.execute([cmd, 'end']) else: - self.execute(['commit', 'end']) + commit = 'commit' + if comment: + commit += ' comment %s' % comment + self.execute([commit, 'end']) + else: + self.execute(['abort']) except NetworkError: self.execute(['abort']) diff = None raise return diff[0] - def save_config(self): - raise NotImplementedError - - Cli = register_transport('cli', default=True)(Cli) |