Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ansible/roles/test/files/ptftests/arista.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def connect(self):
self.do_cmd('enable')
self.do_cmd('terminal length 0')

version_output = self.do_cmd('show version')
self.veos_version = self.parse_version(version_output)

return self.shell

def get_arista_prompt(self, first_prompt):
Expand Down Expand Up @@ -373,7 +376,16 @@ def change_bgp_neigh_state(self, asn, is_up=True):
state = ['shut', 'no shut']
self.do_cmd('configure')
self.do_cmd('router bgp %s' % asn)
self.do_cmd('%s' % state[is_up])
if self.veos_version < 4.20:
self.do_cmd('%s' % state[is_up])
else:
if is_up == True:
self.do_cmd('%s' % state[is_up])
else:
# shutdown BGP will pop confirm message, the message is
# "You are attempting to shutdown BGP. Are you sure you want to shutdown? [confirm]"
self.do_cmd('%s' % state[is_up], prompt = '[confirm]')
self.do_cmd('y')
self.do_cmd('exit')
self.do_cmd('exit')

Expand Down Expand Up @@ -525,3 +537,10 @@ def check_change_time(self, output, entity, what):

# Note: the first item is a placeholder
return 0, change_count

def parse_version(self, output):
version = 0
for line in output.split('\n'):
if ('Software image version: ' in line):
version = float(re.search('([1-9]{1}\d*)(\.\d{0,2})', line).group())
return version