Skip to content

Commit

Permalink
Arista uses default_command_timeout (#235)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fbouliane authored and joseph2rs committed Nov 19, 2018
1 parent 247fc0e commit cfa439f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion netman/adapters/switches/arista.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pyeapi.eapilib import CommandError

from netman import regex
from netman.adapters.shell import default_command_timeout
from netman.adapters.switches.util import split_on_dedent
from netman.core.objects.exceptions import VlanAlreadyExist, UnknownVlan, BadVlanNumber, BadVlanName, \
IPAlreadySet, IPNotAvailable, UnknownIP, DhcpRelayServerAlreadyExists, UnknownDhcpRelayServer, UnknownInterface, \
Expand Down Expand Up @@ -48,7 +49,8 @@ def _connect(self):
password=self.switch_descriptor.password,
port=self.switch_descriptor.port,
transport=self.transport,
return_node=True)
return_node=True,
timeout=default_command_timeout)

def _disconnect(self):
self.node = None
Expand Down
26 changes: 25 additions & 1 deletion tests/adapters/switches/arista_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,8 @@ def test_arista_instance_with_proper_transport(self):
password="paw sword",
port=8888,
transport="trololo",
return_node=True) \
return_node=True,
timeout=300) \
.and_return(pyeapi_client_node)

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

assert_that(switch.node, is_(pyeapi_client_node))

def test_arista_uses_command_timeout(self):
arista.default_command_timeout = 500

pyeapi_client_node = mock.sentinel

flexmock(pyeapi).should_receive('connect').once() \
.with_args(host="1.2.3.4",
username=None,
password=None,
port=None,
transport="trololo",
return_node=True,
timeout=500) \
.and_return(pyeapi_client_node)

switch = Arista(
SwitchDescriptor(model='arista',
hostname="1.2.3.4"),
transport="trololo"
)

switch._connect()

@ignore_deprecation_warnings
def test_factory_transport_auto_detection_http(self):
switch_descriptor = SwitchDescriptor(model="arista", hostname='http://hostname')
Expand Down

0 comments on commit cfa439f

Please sign in to comment.