Skip to content

Commit 2c7650c

Browse files
committed
Enable retry for eos command
1 parent ef88a9c commit 2c7650c

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

tests/common/devices/eos.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __str__(self):
8383
def __repr__(self):
8484
return self.__str__()
8585

86+
@retry(RunAnsibleModuleFail, tries=3, delay=5)
8687
def shutdown(self, interface_name):
8788
out = self.eos_config(
8889
lines=['shutdown'],
@@ -215,20 +216,13 @@ def set_interface_lacp_rate_mode(self, interface_name, mode):
215216
logging.info("Set interface [%s] lacp rate to [%s]" % (interface_name, mode))
216217
return out
217218

218-
def is_multiagent(self):
219-
out = self.eos_command(commands=["show ip route summary | json"])
220-
model = out["stdout"][0]["protoModelStatus"]["operatingProtoModel"]
221-
return model == "multi-agent"
222-
223219
def kill_bgpd(self):
224-
agent = 'Bgp' if self.is_multiagent() else 'Rib'
225-
out = self.eos_config(lines=['agent {} shutdown'.format(agent)])
220+
out = self.eos_config(lines=['agent Rib shutdown'])
226221
return out
227222

228223
@retry(RunAnsibleModuleFail, tries=3, delay=5)
229224
def start_bgpd(self):
230-
agent = 'Bgp' if self.is_multiagent() else 'Rib'
231-
out = self.eos_config(lines=['no agent {} shutdown'.format(agent)])
225+
out = self.eos_config(lines=['no agent Rib shutdown'])
232226
return out
233227

234228
@retry(RunAnsibleModuleFail, tries=3, delay=5)
@@ -427,8 +421,7 @@ def get_supported_speeds(self, interface_name):
427421
'show interface {} hardware'.format(interface_name)]
428422
for command in commands:
429423
output = self.eos_command(commands=[command])
430-
# Ignore case as EOS 4.23 has format of "Speed/Duplex" whereas 4.25 is "Speed/duplex"
431-
found_txt = re.search("Speed/Duplex: (.+)", output['stdout'][0], flags=re.IGNORECASE)
424+
found_txt = re.search("Speed/Duplex: (.+)", output['stdout'][0])
432425
if found_txt is not None:
433426
break
434427

@@ -437,12 +430,7 @@ def get_supported_speeds(self, interface_name):
437430

438431
speed_list = found_txt.groups()[0]
439432
speed_list = speed_list.split(',')
440-
441-
try:
442-
speed_list.remove('auto')
443-
except ValueError:
444-
# auto may not be in speed options for certain versions
445-
pass
433+
speed_list.remove('auto')
446434

447435
def extract_speed_only(v):
448436
return re.match(r'\d+', v.strip()).group() + '000'
@@ -594,6 +582,3 @@ def no_lacp_time_multiplier(self, interface_name):
594582
parents=['interface {}'.format(interface_name)])
595583
logging.info('Reset lacp timer to default for interface [%s]' % interface_name)
596584
return out
597-
598-
def config(self, lines=None, parents=None, module_ignore_errors=False):
599-
return self.eos_config(lines=lines, parents=parents)

0 commit comments

Comments
 (0)