Skip to content

Commit cfa439f

Browse files
fboulianejoseph2rs
authored andcommitted
Arista uses default_command_timeout (#235)
Some arista takes long to reply, get_vlans can take a little more than 57s to render the configuration. The current timeout for arista is 60s. to make sure we don't bust this timeout, we use the default_command_timeout present in the shell, this allow us to wait longer for command reply.
1 parent 247fc0e commit cfa439f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

netman/adapters/switches/arista.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pyeapi.eapilib import CommandError
88

99
from netman import regex
10+
from netman.adapters.shell import default_command_timeout
1011
from netman.adapters.switches.util import split_on_dedent
1112
from netman.core.objects.exceptions import VlanAlreadyExist, UnknownVlan, BadVlanNumber, BadVlanName, \
1213
IPAlreadySet, IPNotAvailable, UnknownIP, DhcpRelayServerAlreadyExists, UnknownDhcpRelayServer, UnknownInterface, \
@@ -48,7 +49,8 @@ def _connect(self):
4849
password=self.switch_descriptor.password,
4950
port=self.switch_descriptor.port,
5051
transport=self.transport,
51-
return_node=True)
52+
return_node=True,
53+
timeout=default_command_timeout)
5254

5355
def _disconnect(self):
5456
self.node = None

tests/adapters/switches/arista_test.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,8 @@ def test_arista_instance_with_proper_transport(self):
948948
password="paw sword",
949949
port=8888,
950950
transport="trololo",
951-
return_node=True) \
951+
return_node=True,
952+
timeout=300) \
952953
.and_return(pyeapi_client_node)
953954

954955
switch = Arista(
@@ -964,6 +965,29 @@ def test_arista_instance_with_proper_transport(self):
964965

965966
assert_that(switch.node, is_(pyeapi_client_node))
966967

968+
def test_arista_uses_command_timeout(self):
969+
arista.default_command_timeout = 500
970+
971+
pyeapi_client_node = mock.sentinel
972+
973+
flexmock(pyeapi).should_receive('connect').once() \
974+
.with_args(host="1.2.3.4",
975+
username=None,
976+
password=None,
977+
port=None,
978+
transport="trololo",
979+
return_node=True,
980+
timeout=500) \
981+
.and_return(pyeapi_client_node)
982+
983+
switch = Arista(
984+
SwitchDescriptor(model='arista',
985+
hostname="1.2.3.4"),
986+
transport="trololo"
987+
)
988+
989+
switch._connect()
990+
967991
@ignore_deprecation_warnings
968992
def test_factory_transport_auto_detection_http(self):
969993
switch_descriptor = SwitchDescriptor(model="arista", hostname='http://hostname')

0 commit comments

Comments
 (0)