From 3e84c05eab911975c9fefa97cd8cfa79af84cc63 Mon Sep 17 00:00:00 2001 From: Bobby Watson Date: Tue, 28 Nov 2017 13:18:11 -0500 Subject: [PATCH] Add support for detecting OPX device type. (#36) * Add support for detecting OPX device type. --- pylib/aeon/utils/__init__.py | 9 ++++++++- setup.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pylib/aeon/utils/__init__.py b/pylib/aeon/utils/__init__.py index 8f8c453..9a959f6 100644 --- a/pylib/aeon/utils/__init__.py +++ b/pylib/aeon/utils/__init__.py @@ -62,13 +62,20 @@ def get_device(target=None, user='admin', passwd='admin', nos_only=False): if i == 2 or i == 3: session.sendline('cat /proc/version') - i = session.expect(['cumulus', 'Ubuntu', 'Red Hat'], timeout=10) + i = session.expect(['cumulus', 'Ubuntu', 'Red Hat', pexpect.TIMEOUT], timeout=5) if i == 0: nos = 'cumulus' if i == 1: nos = 'ubuntu' if i == 2: nos = 'centos' + if i == 3: + session.sendline('[ -f /etc/opx/opx-environment.sh ] && echo "device is OPX" || echo "Not found"') + i = session.expect(['Not found', 'device is OPX', pexpect.TIMEOUT], timeout=5) + if i == 0 or i == 2: + raise TargetError('Unable to determine device type for %s' % target) + if i == 1: + nos = 'opx' if i == 4: raise TargetError('Unable to determine device type for %s' % target) diff --git a/setup.py b/setup.py index 86705a8..e14a513 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def requirements(filename): setup( name="aeon-venos", - version="0.9.7", + version="0.9.8", author="Jeremy Schulman", url='https://github.com/Apstra/aeon-venos', author_email="jeremy@apstra.com",