2 * [[ Authors will Fill in the Copyright header ]]
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
8 * Authors : Brent Salisbury, Hugo Trippaers
10 package org.opendaylight.ovsdb.plugin;
12 import java.io.IOException;
13 import java.util.HashMap;
15 import java.util.Properties;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.controller.sal.core.Node;
20 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
21 import org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl;
22 import org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl;
23 import org.opendaylight.ovsdb.plugin.internal.Encapsulation;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class BridgeDomainConfigPortTestCases extends PluginTestBase {
29 private static final Logger logger = LoggerFactory
30 .getLogger(BridgeDomainConfigPortTestCases.class);
31 private Properties props;
34 public void loadProps() throws IOException {
35 props = loadProperties();
40 * Create a Port and attach it to a Bridge
41 * Ex. ovs-vsctl add-port br0 vif0
45 public void addPort() throws Throwable{
46 TestObjects testObjects = getTestConnection();
47 ConnectionServiceImpl connectionService = testObjects.connectionService;
48 Node node = testObjects.node;
49 ConfigurationServiceImpl configurationService = testObjects.configurationService;
50 configurationService.addPort(node, BRIDGE_NAME, PORT_NAME, null);
54 * Create a Port with a user defined VLAN, and attach it to the specified bridge.
56 * Ex. ovs-vsctl add-port JUNIT_BRIDGE_TEST Jvlanvif0 tag=100
59 public void addPortVlan() throws Throwable{
60 TestObjects testObjects = getTestConnection();
61 ConnectionServiceImpl connectionService = testObjects.connectionService;
62 Node node = testObjects.node;
66 ConfigurationServiceImpl configurationService = testObjects.configurationService;
67 Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
68 configs.put(ConfigConstants.TYPE, "VLAN");
69 configs.put(ConfigConstants.VLAN, vlanid+"");
70 configurationService.addPort(node, BRIDGE_NAME, TAGGED_PORT_NAME, configs);
74 * Create an Encapsulated Tunnel Interface and destination Tunnel Endpoint
75 * tunnelendpoint IP address of the destination Tunnel Endpoint.
76 * tunencap is the tunnel encapsulation options being (CAPWAP, GRE, VXLAN).
78 * Ex. ovs-vsctl add-port br0 vxlan1 (cont)
79 * -- set interface vxlan1 type=vxlan options:remote_ip=192.168.1.11
83 public void addTunnel() throws Throwable{
84 TestObjects testObjects = getTestConnection();
85 Node node = testObjects.node;
87 Encapsulation encap = Encapsulation.VXLAN;
88 String tunencap = encap.toString();
89 String tunnelendpoint = FAKE_IP;
91 ConfigurationServiceImpl configurationService = testObjects.configurationService;
92 Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
93 configs.put(ConfigConstants.TYPE, "TUNNEL");
94 configs.put(ConfigConstants.TUNNEL_TYPE, tunencap);
95 configs.put(ConfigConstants.DEST_IP, tunnelendpoint);
97 configurationService.addPort(node, BRIDGE_NAME, TUNNEL_PORT_NAME, configs);
101 * Deletes an existing port from an existing bridge
102 * Ex. ovs-vsctl del-port ovsbr0 tap0
105 public void deletePort() throws Throwable{
106 TestObjects testObjects = getTestConnection();
107 ConnectionServiceImpl connectionService = testObjects.connectionService;
108 Node node = testObjects.node;
110 ConfigurationServiceImpl configurationService = testObjects.configurationService;
111 configurationService.deletePort(node, BRIDGE_NAME, PORT_NAME);