fixes issue with pushing config to versions that do not support sessions (#5236)

earlier versions of eos do not support configuration sessions.  this change
will now check if sessions are supported and if not will fallback to
not using config sessions

fixes #4909
This commit is contained in:
Peter Sprygada 2016-10-12 20:16:34 -04:00 committed by Matt Clay
parent bca8bbe7c2
commit 25d00838a9

View file

@ -223,6 +223,11 @@ def check_args(module, warnings):
'match=none instead. This argument will be '
'removed in the future')
if not module.connection.supports_sessions():
warnings.append('The current version of EOS on the remote device does '
'not support configuration sessions. The commit '
'argument will be ignored')
def get_candidate(module):
candidate = NetworkConfig(indent=3)
if module.params['src']:
@ -245,9 +250,11 @@ def load_config(module, commands, result):
diff = module.config.load_config(commands, replace=replace, commit=commit)
if diff:
if diff and module.connection.supports_sessions():
result['diff'] = dict(prepared=diff)
result['changed'] = True
elif diff:
result['changed'] = True
def run(module, result):
match = module.params['match']
@ -273,6 +280,7 @@ def run(module, result):
result['updates'] = commands
module.log('commands: %s' % commands)
load_config(module, commands, result)
if module.params['save']:
@ -314,7 +322,6 @@ def main():
('replace', 'config', ['src'])]
module = NetworkModule(argument_spec=argument_spec,
connect_on_load=False,
mutually_exclusive=mutually_exclusive,
required_if=required_if,
supports_check_mode=True)