1 package org.opendaylight.ovsdb;
4 import java.util.HashMap;
8 import org.opendaylight.controller.sal.core.Node;
9 import org.opendaylight.controller.sal.core.NodeConnector;
10 import org.opendaylight.ovsdb.internal.*;
11 import org.opendaylight.ovsdb.sal.connection.ConnectionConstants;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14 import org.opendaylight.ovsdb.internal.Encapsulation;
16 public class OvsdbTestAddTunnel {
17 private static final Logger logger = LoggerFactory
18 .getLogger(OvsdbTestAddTunnel.class);
21 public void addTunnel() throws Throwable{
22 Node.NodeIDType.registerIDType("OVS", String.class);
23 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
25 ConnectionService connectionService = new ConnectionService();
26 connectionService.init();
28 String identifier = "TEST";
30 * tunnelendpoint IP address of the
31 * destination Tunnel Endpoint.
32 * tunencap is the tunnel encapsulation
33 * options being (CAPWAP, GRE, VXLAN).
35 Encapsulation encap = Encapsulation.VXLAN;
36 String tunencap = encap.toString();
37 String tunnelendpoint = "192.168.100.100";
39 Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
40 params.put(ConnectionConstants.ADDRESS, "172.16.58.170");
42 Node node = connectionService.connect(identifier, params);
44 logger.error("Could not connect to ovsdb server");
48 * Create an Encapsulated Tunnel Interface and destination Tunnel Endpoint
49 * @param node Node serving this configuration service
50 * @param bridgeDomainIdentifier String representation of a Bridge Domain
51 * @param portIdentifier String representation of a user defined Port Name
52 * @param tunnelendpoint IP address of the destination Tunnel Endpoint
53 * @param tunencap is the tunnel encapsulation options being CAPWAP, GRE or VXLAN
54 * The Bridge must already be defined before calling addTunnel.
56 ConfigurationService configurationService = new ConfigurationService();
57 configurationService.setConnectionServiceInternal(connectionService);
58 configurationService.addTunnel(node, "JunitBridge",
59 "tunnel0", tunnelendpoint, tunencap);