1 package org.opendaylight.ovsdb;
4 import java.util.HashMap;
7 import org.opendaylight.controller.sal.core.Node;
8 import org.opendaylight.controller.sal.core.NodeConnector;
9 import org.opendaylight.ovsdb.internal.*;
10 import org.opendaylight.ovsdb.sal.connection.ConnectionConstants;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import org.opendaylight.ovsdb.internal.Encapsulation;
15 public class OvsdbTestAddTunnel {
16 private static final Logger logger = LoggerFactory
17 .getLogger(OvsdbTestAddTunnel.class);
20 public void addTunnel() throws Throwable{
21 Node.NodeIDType.registerIDType("OVS", String.class);
22 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
24 ConnectionService connectionService = new ConnectionService();
25 connectionService.init();
27 String identifier = "TEST";
29 * tunnelendpoint IP address of the
30 * destination Tunnel Endpoint.
31 * tunencap is the tunnel encapsulation
32 * options being (CAPWAP, GRE, VXLAN).
33 * Use the following lines to test GRE and CAPWAP
34 * Encapsulation encap = Encapsulation.GRE;
35 * Encapsulation encap = Encapsulation.CAPWAP;
38 Encapsulation encap = Encapsulation.VXLAN;
39 String tunencap = encap.toString();
40 String tunnelendpoint = "192.168.100.100";
42 Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
43 params.put(ConnectionConstants.ADDRESS, "172.16.58.170");
45 Node node = connectionService.connect(identifier, params);
47 logger.error("Could not connect to ovsdb server");
51 * Create an Encapsulated Tunnel Interface and destination Tunnel Endpoint
53 * Ex. ovs-vsctl add-port br0 vxlan1 (cont)
54 * -- set interface vxlan1 type=vxlan options:remote_ip=192.168.1.11
55 * @param node Node serving this configuration service
56 * @param bridgeDomainIdentifier String representation of a Bridge Domain
57 * @param portIdentifier String representation of a user defined Port Name
58 * @param tunnelendpoint IP address of the destination Tunnel Endpoint
59 * @param tunencap is the tunnel encapsulation options being CAPWAP, GRE or VXLAN
60 * The Bridge must already be defined before calling addTunnel.
62 ConfigurationService configurationService = new ConfigurationService();
63 configurationService.setConnectionServiceInternal(connectionService);
64 configurationService.addTunnel(node, "JUNIT_BRIDGE_TEST",
65 "Jtunnel0", tunnelendpoint, tunencap);