Merge remote-tracking branch 'origin/master' into merge-branch
[netvirt.git] / plugin / src / test / java / org / opendaylight / ovsdb / plugin / OvsdbTestAddTunnelIT.java
1 /*
2  * [[ Authors will Fill in the Copyright header ]]
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Brent Salisbury, Hugo Trippaers
9  */
10 package org.opendaylight.ovsdb.plugin;
11
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import org.junit.Test;
17 import org.opendaylight.controller.sal.core.Node;
18 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class OvsdbTestAddTunnelIT extends OvsdbTestBase {
23     private static final Logger logger = LoggerFactory
24             .getLogger(OvsdbTestAddTunnelIT.class);
25
26     @Test
27     public void addTunnel() throws Throwable{
28         TestObjects testObjects = getTestConnection();
29         ConnectionService connectionService = testObjects.connectionService;
30         Node node = testObjects.node;
31
32         /**
33          * tunnelendpoint IP address of the
34          * destination Tunnel Endpoint.
35          * tunencap is the tunnel encapsulation
36          * options being (CAPWAP, GRE, VXLAN).
37          * Use the following lines to test GRE and CAPWAP
38          * Encapsulation encap = Encapsulation.GRE;
39          * Encapsulation encap = Encapsulation.CAPWAP;
40          */
41
42         Encapsulation encap = Encapsulation.VXLAN;
43         String tunencap = encap.toString();
44         String tunnelendpoint = FAKE_IP;
45
46         /**
47          * Create an Encapsulated Tunnel Interface and destination Tunnel Endpoint
48          *
49          * Ex. ovs-vsctl add-port br0 vxlan1 (cont)
50          * -- set interface vxlan1 type=vxlan options:remote_ip=192.168.1.11
51          * @param node Node serving this configuration service
52          * @param bridgeDomainIdentifier String representation of a Bridge Domain
53          * @param portIdentifier String representation of a user defined Port Name
54          * @param tunnelendpoint IP address of the destination Tunnel Endpoint
55          * @param tunencap is the tunnel encapsulation options being CAPWAP, GRE or VXLAN
56          * The Bridge must already be defined before calling addTunnel.
57          */
58         ConfigurationService configurationService = new ConfigurationService();
59         configurationService.setConnectionServiceInternal(connectionService);
60         Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
61         configs.put(ConfigConstants.TYPE, "TUNNEL");
62         configs.put(ConfigConstants.TUNNEL_TYPE, tunencap);
63         configs.put(ConfigConstants.DEST_IP, tunnelendpoint);
64
65         configurationService.addPort(node, BRIDGE_NAME, TUNNEL_PORT_NAME, configs);
66
67     }
68 }