Skip to content

Commit 248053f

Browse files
author
Laura
authored
Merge pull request #302 from laurapanzariello/develop
Update Cisco and Dell plugins
2 parents 2bddc8d + 72e6319 commit 248053f

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

networkapi/plugins/Cisco/NXOS/BGP/Cli.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class Generic(BasePlugin):
6060
WARNING_REGEX = 'config ignored|Warning'
6161
ERROR_REGEX = '[Ee][Rr][Rr][Oo][Rr]|[Ff]ail|\%|utility is occupied'
6262

63-
management_vrf = 'management'
63+
management_vrf = 'BEVrf'
6464
admin_privileges = 15
6565
VALID_TFTP_PUT_MESSAGE = 'bytes successfully copied'
66+
VALID_TFTP_PUT_MESSAGE_NXS6001 = 'Copy complete'
6667

6768
def _deploy_pre_req(self, neighbor):
6869
# Concatenate RouteMapEntries Lists
@@ -452,16 +453,18 @@ def _ensure_privilege_level(self, privilege_level=None):
452453
self.channel.send('\n')
453454
recv = self._wait_string('>|#')
454455
self.channel.send('show privilege\n')
455-
recv = self._wait_string('Current privilege level is')
456-
level = re.search(
457-
'Current privilege level is ([0-9]+).*', recv, re.DOTALL).group(1)
458-
459-
level = (level.split(' '))[-1]
460-
if int(level) < privilege_level:
461-
self.channel.send('enable\n')
462-
recv = self._wait_string('Password:')
463-
self.channel.send('%s\n' % self.equipment_access.enable_pass)
464-
recv = self._wait_string('#')
456+
if not self.waitString('Feature privilege: Disabled'):
457+
self.channel.send('show privilege\n')
458+
recv = self._wait_string('Current privilege level is')
459+
level = re.search(
460+
'Current privilege level is ([0-9]+).*', recv, re.DOTALL).group(1)
461+
462+
level = (level.split(' '))[-1]
463+
if int(level) < privilege_level:
464+
self.channel.send('enable\n')
465+
recv = self._wait_string('Password:')
466+
self.channel.send('%s\n' % self.equipment_access.enable_pass)
467+
recv = self._wait_string('#')
465468

466469
def _wait_string(self, wait_str_ok_regex='', wait_str_invalid_regex=None,
467470
wait_str_failed_regex=None):
@@ -512,5 +515,14 @@ def _wait_string(self, wait_str_ok_regex='', wait_str_invalid_regex=None,
512515
log.debug('Switch copied 0 bytes, need to try again.')
513516
raise plugin_exc.CurrentlyBusyErrorException()
514517
string_ok = 1
518+
elif re.search(self.VALID_TFTP_PUT_MESSAGE_NXS6001, output_line):
519+
520+
log.debug('Equipment output: %s' % output_line)
521+
522+
# test bug switch copying 0 bytes
523+
if output_line == 'Copy failed':
524+
log.debug('Switch copied 0 bytes, need to try again.')
525+
raise plugin_exc.CurrentlyBusyErrorException()
526+
string_ok = 1
515527

516528
return recv_string

networkapi/plugins/Dell/FTOS/BGP/Cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Generic(BasePlugin):
6363

6464
admin_privileges = 15
6565
VALID_TFTP_PUT_MESSAGE = 'bytes successfully copied'
66+
VALID_TFTP_PUT_MESSAGE_OS10 = 'Copy succeeded'
6667

6768
def _deploy_pre_req(self, neighbor):
6869
log.debug("_deploy_pre_req")
@@ -522,5 +523,14 @@ def _wait_string(self, wait_str_ok_regex='', wait_str_invalid_regex=None,
522523
log.debug('Switch copied 0 bytes, need to try again.')
523524
raise plugin_exc.CurrentlyBusyErrorException()
524525
string_ok = 1
526+
elif re.search(self.VALID_TFTP_PUT_MESSAGE_OS10, output_line):
527+
528+
log.debug('Equipment output: %s' % output_line)
529+
530+
# test bug switch copying 0 bytes
531+
if output_line == 'Copy failed':
532+
log.debug('Switch copied 0 bytes, need to try again.')
533+
raise plugin_exc.CurrentlyBusyErrorException()
534+
string_ok = 1
525535

526536
return recv_string

0 commit comments

Comments
 (0)