Bug 5306: Enable the SSL connection for ovs manager
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / OvsdbConnection.java
1 /*
2  * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
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 package org.opendaylight.ovsdb.lib;
9
10 import io.netty.channel.Channel;
11 import java.net.InetAddress;
12 import java.util.Collection;
13 import javax.net.ssl.SSLContext;
14
15 /**
16  * OvsDBConnection Interface provides OVSDB connection management APIs which includes
17  * both Active and Passive connections.
18  * From the Library perspective, Active OVSDB connections are those that are initiated from
19  * the Controller towards the ovsdb-manager.
20  * While Passive OVSDB connections are those that are initiated from the ovs towards
21  * the controller.
22  *
23  * <p>Applications that use OvsDBConnectionService can use the connect APIs to initiate Active
24  * connections and can listen to the asynchronous Passive connections via registerConnectionListener
25  * listener API.
26  */
27 public interface OvsdbConnection {
28
29     /**
30      * connect API can be used by the applications to initiate Active connection from
31      * the controller towards ovsdb-server.
32      * @param address IP Address of the remote server that hosts the ovsdb server.
33      * @param port Layer 4 port on which the remote ovsdb server is listening on.
34      * @return OvsDBClient The primary Client interface for the ovsdb connection.
35      */
36     OvsdbClient connect(final InetAddress address, final int port);
37
38     /**
39      * connect API can be used by the applications to initiate Active ssl
40      * connection from the controller towards ovsdb-server.
41      * @param address IP Address of the remote server that hosts the ovsdb server.
42      * @param port Layer 4 port on which the remote ovsdb server is listening on.
43      * @param sslContext Netty sslContext for channel configuration
44      * @return OvsDBClient The primary Client interface for the ovsdb connection.
45      */
46     OvsdbClient connectWithSsl(final InetAddress address, final int port,
47                                final SSLContext sslContext);
48
49     /**
50      * Method to disconnect an existing connection.
51      * @param client that represents the ovsdb connection.
52      */
53     void disconnect(OvsdbClient client);
54
55     /**
56      * Method to start ovsdb server for passive connection.
57      */
58     boolean startOvsdbManager(final int ovsdbListenPort);
59
60     /**
61      * Method to start ovsdb server for passive connection with SSL.
62      */
63     boolean startOvsdbManagerWithSsl(final int ovsdbListenPort,
64                                      final SSLContext sslContext, String[] protocols, String[] cipherSuites);
65
66     /**
67      * Method to register a Passive Connection Listener with the ConnectionService.
68      * @param listener Passive Connection listener interested in Passive OVSDB connection requests.
69      */
70     void registerConnectionListener(OvsdbConnectionListener listener);
71
72     /**
73      * Method to unregister a Passive Connection Listener with the ConnectionService.
74      */
75     void unregisterConnectionListener(OvsdbConnectionListener listener);
76
77     /**
78      * Returns a Collection of all the active OVSDB Connections.
79      *
80      * @return Collection of all the active OVSDB Connections
81      */
82     Collection<OvsdbClient> getConnections();
83
84     OvsdbClient getClient(Channel channel);
85 }