def test_add_tunnel_endpoints(self): tun_1 = ovs_db_v2.add_tunnel_endpoint('192.168.0.1') tun_2 = ovs_db_v2.add_tunnel_endpoint('192.168.0.2') self.assertEqual(1, tun_1.id) self.assertEqual('192.168.0.1', tun_1.ip_address) self.assertEqual(2, tun_2.id) self.assertEqual('192.168.0.2', tun_2.ip_address)
def test_add_tunnel_endpoint_handle_duplicate_error(self): with mock.patch.object(session.Session, 'query') as query_mock: error = db_exc.DBDuplicateEntry(['id']) query_mock.side_effect = error with testtools.ExpectedException(n_exc.NeutronException): ovs_db_v2.add_tunnel_endpoint('10.0.0.1', 5) self.assertEqual(query_mock.call_count, 5)
def test_add_tunnel_endpoint_retrieve_an_existing_endpoint(self): addr = '10.0.0.1' self.session.add(ovs_models.TunnelEndpoint(ip_address=addr, id=1)) self.session.flush() tunnel = ovs_db_v2.add_tunnel_endpoint(addr) self.assertEqual(tunnel.id, 1) self.assertEqual(tunnel.ip_address, addr)
def tunnel_sync(self, rpc_context, **kwargs): """Update new tunnel. Updates the datbase with the tunnel IP. All listening agents will also be notified about the new tunnel IP. """ tunnel_ip = kwargs.get("tunnel_ip") # Update the database with the IP tunnel = ovs_db_v2.add_tunnel_endpoint(tunnel_ip) tunnels = ovs_db_v2.get_tunnel_endpoints() entry = dict() entry["tunnels"] = tunnels # Notify all other listening agents self.notifier.tunnel_update(rpc_context, tunnel.ip_address, tunnel.id, self.tunnel_type) # Return the list of tunnels IP's to the agent return entry
def tunnel_sync(self, rpc_context, **kwargs): """Update new tunnel. Updates the datbase with the tunnel IP. All listening agents will also be notified about the new tunnel IP. """ tunnel_ip = kwargs.get('tunnel_ip') # Update the database with the IP tunnel = ovs_db_v2.add_tunnel_endpoint(tunnel_ip) tunnels = ovs_db_v2.get_tunnel_endpoints() entry = dict() entry['tunnels'] = tunnels # Notify all other listening agents self.notifier.tunnel_update(rpc_context, tunnel.ip_address, tunnel.id, self.tunnel_type) # Return the list of tunnels IP's to the agent return entry
def test_add_tunnel_endpoint_create_new_endpoint(self): addr = '10.0.0.1' ovs_db_v2.add_tunnel_endpoint(addr) self.assertIsNotNone(self.session.query(ovs_models.TunnelEndpoint). filter_by(ip_address=addr).first())