Added VLAN tagging support to port creations
[ovsdb.git] / ovsdb / src / test / java / org / opendaylight / ovsdb / OvsdbTestAddTunnel.java
1 package org.opendaylight.ovsdb;
2
3
4 import java.util.HashMap;
5 import java.util.Map;
6 import org.junit.Test;
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;
14
15 public class OvsdbTestAddTunnel {
16     private static final Logger logger = LoggerFactory
17             .getLogger(OvsdbTestAddTunnel.class);
18
19     @Test
20     public void addTunnel() throws Throwable{
21         Node.NodeIDType.registerIDType("OVS", String.class);
22         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
23
24         ConnectionService connectionService = new ConnectionService();
25         connectionService.init();
26
27         String identifier = "TEST";
28         /**
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;
36          */
37
38         Encapsulation encap = Encapsulation.VXLAN;
39         String tunencap = encap.toString();
40         String tunnelendpoint = "192.168.100.100";
41
42         Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
43         params.put(ConnectionConstants.ADDRESS, "172.16.58.170");
44
45         Node node = connectionService.connect(identifier, params);
46         if(node == null){
47             logger.error("Could not connect to ovsdb server");
48             return;
49         }
50         /**
51          * Create an Encapsulated Tunnel Interface and destination Tunnel Endpoint
52          *
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.
61          */
62         ConfigurationService configurationService = new ConfigurationService();
63         configurationService.setConnectionServiceInternal(connectionService);
64         configurationService.addTunnel(node, "JUNIT_BRIDGE_TEST",
65                 "Jtunnel0", tunnelendpoint, tunencap);
66
67     }
68 }