Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed transport issues when calling self.execute from Cli #17623

Merged
merged 3 commits into from
Sep 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/ansible/module_utils/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,32 @@ def get_config(self, include_defaults=False, **kwargs):

def load_config(self, config):
checkpoint = 'ansible_%s' % int(time.time())
self.execute(['checkpoint %s' % checkpoint], output='text')
try:
self.execute(['checkpoint %s' % checkpoint], output='text')
except TypeError:
self.execute(['checkpoint %s' % checkpoint])

try:
self.configure(config)
except NetworkError:
self.load_checkpoint(checkpoint)
raise

self.execute(['no checkpoint %s' % checkpoint], output='text')
try:
self.execute(['no checkpoint %s' % checkpoint], output='text')
except TypeError:
self.execute(['no checkpoint %s' % checkpoint])

def save_config(self, **kwargs):
self.execute(['copy running-config startup-config'])

def load_checkpoint(self, checkpoint):
self.execute(['rollback running-config checkpoint %s' % checkpoint,
'no checkpoint %s' % checkpoint], output='text')
try:
self.execute(['rollback running-config checkpoint %s' % checkpoint,
'no checkpoint %s' % checkpoint], output='text')
except TypeError:
self.execute(['rollback running-config checkpoint %s' % checkpoint,
'no checkpoint %s' % checkpoint])


class Nxapi(NxapiConfigMixin):
Expand Down