dd5925862f276fc6f63f885a8f9af693c209512c
[ovsdb.git] / ovsdb / src / test / java / org / opendaylight / ovsdb / plugin / OvsdbTestDeletePortIT.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 import org.junit.Test;
13 import org.opendaylight.controller.sal.core.Node;
14 import org.opendaylight.controller.sal.core.NodeConnector;
15 import org.opendaylight.controller.sal.connection.ConnectionConstants;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 public class OvsdbTestDeletePortIT {
23     private static final Logger logger = LoggerFactory
24             .getLogger(OvsdbTestAddPortIT.class);
25
26     @Test
27     public void deletePort() throws Throwable{
28         Node.NodeIDType.registerIDType("OVS", String.class);
29         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
30
31         ConnectionService connectionService = new ConnectionService();
32         connectionService.init();
33         String identifier = "TEST";
34         Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
35         params.put(ConnectionConstants.ADDRESS, "10.12.0.78");
36         params.put(ConnectionConstants.PORT, "6634");
37
38         Node node = connectionService.connect(identifier, params);
39         if(node == null){
40             logger.error("Could not connect to ovsdb server");
41             return;
42         }
43         /**
44          * Deletes an existing port from an existing bridge
45          * Ex. ovs-vsctl del-port ovsbr0 tap0
46          * @param node Node serving this configuration service
47          * @param bridgeDomainIdentifier String representation of a Bridge Domain
48          * @param portIdentifier String representation of a user defined Port Name
49          */
50         ConfigurationService configurationService = new ConfigurationService();
51         configurationService.setConnectionServiceInternal(connectionService);
52         configurationService.deletePort(node, "ovsbr0", "tap2");
53     }
54 }