self._server = jsonrpclib.Server(self._eapi_host_url())
self.keystone_conf = cfg.CONF.keystone_authtoken
self.region = cfg.CONF.ml2_arista.region_name
+ self.sync_interval = cfg.CONF.ml2_arista.sync_interval
self._region_updated_time = None
# The cli_commands dict stores the mapping between the CLI command key
# and the actual CLI command.
'exit']
self._run_openstack_cmds(cmds)
+ def sync_start(self):
+ """Sends indication to EOS that ML2->EOS sync has started."""
+
+ sync_start_cmd = ['sync start']
+ self._run_openstack_cmds(sync_start_cmd)
+
+ def sync_end(self):
+ """Sends indication to EOS that ML2->EOS sync has completed."""
+
+ sync_end_cmd = ['sync end']
+ self._run_openstack_cmds(sync_end_cmd)
+
def create_network(self, tenant_id, network):
"""Creates a single network on Arista hardware
self.keystone_conf.admin_user,
'******',
self.keystone_conf.admin_tenant_name)]
+
+ sync_interval_cmd = 'sync interval %d' % self.sync_interval
+ cmds.append(sync_interval_cmd)
+ log_cmds.append(sync_interval_cmd)
+
self._run_openstack_cmds(cmds, commands_to_log=log_cmds)
def clear_region_updated_time(self):
class SyncService(object):
- """Synchronizatin of information between Neutron and EOS
+ """Synchronization of information between Neutron and EOS
Periodically (through configuration option), this service
ensures that Networks and VMs configured on EOS/Arista HW
self._ndb = neutron_db
self._force_sync = True
+ def do_synchronize(self):
+ try:
+ # Send trigger to EOS that the ML2->EOS sync has started.
+ self._rpc.sync_start()
+ LOG.info(_('Sync start trigger sent to EOS'))
+ except arista_exc.AristaRpcError:
+ LOG.warning(EOS_UNREACHABLE_MSG)
+ return
+
+ # Perform the sync
+ self.synchronize()
+
+ try:
+ # Send trigger to EOS that the ML2->EOS sync is Complete.
+ self._rpc.sync_end()
+ except arista_exc.AristaRpcError:
+ LOG.warning(EOS_UNREACHABLE_MSG)
+
def synchronize(self):
"""Sends data to EOS which differs from neutron DB."""
def _synchronization_thread(self):
with self.eos_sync_lock:
- self.eos.synchronize()
+ self.eos.do_synchronize()
self.timer = threading.Timer(self.sync_timeout,
self._synchronization_thread)
cfg.CONF.keystone_authtoken = fake_keystone_info_class()
cfg.CONF.set_override('eapi_host', value, "ml2_arista")
cfg.CONF.set_override('eapi_username', value, "ml2_arista")
+ cfg.CONF.set_override('sync_interval', 10, "ml2_arista")
def setup_valid_config():
def test_no_exception_on_correct_configuration(self):
self.assertIsNotNone(self.drv)
+ def test_sync_start(self):
+ self.drv.sync_start()
+ cmds = ['enable', 'configure', 'cvx', 'service openstack',
+ 'region RegionOne',
+ 'sync start',
+ 'exit', 'exit', 'exit']
+
+ self.drv._server.runCmds.assert_called_once_with(version=1, cmds=cmds)
+
+ def test_sync_end(self):
+ self.drv.sync_end()
+ cmds = ['enable', 'configure', 'cvx', 'service openstack',
+ 'region RegionOne',
+ 'sync end',
+ 'exit', 'exit', 'exit']
+
+ self.drv._server.runCmds.assert_called_once_with(version=1, cmds=cmds)
+
def test_plug_host_into_network(self):
tenant_id = 'ten-1'
vm_id = 'vm-1'
'service openstack',
'region %s' % self.region,
auth_cmd,
+ 'sync interval %d' % cfg.CONF.ml2_arista.sync_interval,
'exit',
'exit',
'exit',