Don't throw unneeded tracebacks when 'show version' doesn't show us what
we expect, instead gracefully fail.
"Get equipment information from 'show version'."
output = self.vtysh_cmd('show version').split('\n')[0]
columns = topotest.normalize_text(output).split(' ')
- return {
- 'type': columns[0],
- 'version': columns[1],
- }
+ try:
+ return {
+ 'type': columns[0],
+ 'version': columns[1],
+ }
+ except IndexError:
+ return {
+ 'type': None,
+ 'version': None,
+ }
def has_version(self, cmpop, version):
"""
Usage example: router.has_version('>', '1.0')
"""
rversion = self.version_info()['version']
+ if rversion is None:
+ return False
+
result = topotest.version_cmp(rversion, version)
if cmpop == '>=':
return result >= 0