mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 06:11:26 -07:00
Merge pull request #17623 from dgjustice/nxos_fixes
Fixed transport issues when calling self.execute from Cli
This commit is contained in:
commit
79d1b51dfb
1 changed files with 14 additions and 4 deletions
|
@ -43,7 +43,10 @@ class NxapiConfigMixin(object):
|
||||||
|
|
||||||
def load_config(self, config):
|
def load_config(self, config):
|
||||||
checkpoint = 'ansible_%s' % int(time.time())
|
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:
|
try:
|
||||||
self.configure(config)
|
self.configure(config)
|
||||||
|
@ -51,14 +54,21 @@ class NxapiConfigMixin(object):
|
||||||
self.load_checkpoint(checkpoint)
|
self.load_checkpoint(checkpoint)
|
||||||
raise
|
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):
|
def save_config(self, **kwargs):
|
||||||
self.execute(['copy running-config startup-config'])
|
self.execute(['copy running-config startup-config'])
|
||||||
|
|
||||||
def load_checkpoint(self, checkpoint):
|
def load_checkpoint(self, checkpoint):
|
||||||
self.execute(['rollback running-config checkpoint %s' % checkpoint,
|
try:
|
||||||
'no checkpoint %s' % checkpoint], output='text')
|
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):
|
class Nxapi(NxapiConfigMixin):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue