From 456fbf011e19eba599a57c6ac2a5741c8453707b Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Sun, 11 Sep 2016 23:30:51 -0400 Subject: [PATCH] cleans up load_config() in eos shared module cleans up the load_config() method --- lib/ansible/module_utils/eos.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py index 2f551b13ab..c678a960d3 100644 --- a/lib/ansible/module_utils/eos.py +++ b/lib/ansible/module_utils/eos.py @@ -60,20 +60,12 @@ class EosConfigMixin(object): cmd += ' all' return self.execute([cmd])[0] - def load_config(self, config, session=None, commit=False, replace=False, **kwargs): + def load_config(self, config, commit=False, replace=False): """ Loads the configuration into the remote device - - This method handles the actual loading of the config - commands into the remote EOS device. By default the - config specified is merged with the current running-config. - - :param config: ordered list of config commands to load - :param replace: replace current config when True otherwise merge - - :returns list: ordered set of responses from device """ - session = session or 'ansible_%s' % int(time.time()) + session = 'ansible_%s' % int(time.time()) commands = ['configure session %s' % session] + if replace: commands.append('rollback clean-config') @@ -87,6 +79,8 @@ class EosConfigMixin(object): diff = self.diff_config(session) if commit: self.commit_config(session) + else: + self.execute(['no configure session %s' % session]) except NetworkError: self.abort_config(session) diff = None @@ -108,8 +102,6 @@ class EosConfigMixin(object): else: response = self.execute(commands) - - return response[-2] def commit_config(self, session):