Fixed transport issues when calling self.execute from Cli
This commit is contained in:
parent
e07b854505
commit
d34f7c24d9
1 changed files with 14 additions and 4 deletions
|
@ -43,7 +43,10 @@ class NxapiConfigMixin(object):
|
|||
|
||||
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)
|
||||
|
@ -51,14 +54,21 @@ class NxapiConfigMixin(object):
|
|||
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):
|
||||
|
|
Loading…
Reference in a new issue