Browse Source

Use show version to validate vrf support

Updated the code to use show version to check which vrf creation command
the switch supports. This will eliminate extra entries in syslog

Change-Id: Id3c3e42d2fc7165e5ea3c20bec3343c559f6465f
tags/2018.1.12^0
Alin Iorga 4 months ago
parent
commit
12cfba4cea
3 changed files with 18 additions and 11 deletions
  1. +16
    -10
      networking_arista/l3Plugin/arista_l3_driver.py
  2. +0
    -1
      networking_arista/l3Plugin/l3_arista.py
  3. +2
    -0
      networking_arista/tests/unit/utils.py

+ 16
- 10
networking_arista/l3Plugin/arista_l3_driver.py View File

@@ -251,24 +251,30 @@ class AristaL3Driver(object):
timeout=cfg.CONF.l3_arista.conn_timeout
)

def _supports_vrf_instance(self, version):
ver_tokens = version.split('.')
if len(ver_tokens) < 2 or int(ver_tokens[0]) < 4:
return False
if int(ver_tokens[0]) == 4 and int(ver_tokens[1]) < 22:
return False
return True

def _check_vrf_syntax_v2_support(self, host, keep_alive=True):
cmds = ['vrf instance _tmp_openstack_vrf',
'no vrf instance _tmp_openstack_vrf']
cmds = ['show version']
result = None
try:
self._run_config_cmds(cmds, host, log_exception=False,
keep_alive=keep_alive,
update_vrf_commands=False)
except arista_exc.AristaServicePluginInvalidCommand:
msg = _('Switch does not support vrf instance command')
LOG.info(msg)
return False
result = self._run_eos_cmds(cmds, host, log_exception=False,
keep_alive=keep_alive,
update_vrf_commands=False)
LOG.info('show version result %s' % result)
except Exception:
# We don't know what exception we got return None
# At this moment we don't know what command we support for vrf
# creation
return None

return True
return result and self._supports_vrf_instance(result[0].get('version',
''))

def _update_vrf_commands(self, keep_alive=True):
# This assumes all switches run the same version. This needs to be


+ 0
- 1
networking_arista/l3Plugin/l3_arista.py View File

@@ -115,7 +115,6 @@ class AristaL3SyncWorker(worker.BaseWorker):
same commands can be repeated.
"""
LOG.info(_LI('Syncing Neutron Router DB <-> EOS'))
# Update vrf creation command support if needed
try:
if self._use_vrf:
self.driver._update_vrf_commands()


+ 2
- 0
networking_arista/tests/unit/utils.py View File

@@ -141,6 +141,8 @@ class MockSwitch(object):
vrfs['vrfs'][vrf_name] = {'interfaces': vrf['svis'],
'routeDistinguisher': vrf['rd']}
ret.append(vrfs)
elif command == 'show version':
ret.append({'version': '4.22.0F'})
elif command == 'enable':
ret.append({})
elif 'show' in command:


Loading…
Cancel
Save