1 package org.opendaylight.ovsdb.internal;
3 import java.net.InetAddress;
6 import org.opendaylight.ovsdb.sal.configuration.IPluginInNetworkConfigurationService;
7 import org.opendaylight.controller.sal.core.Node;
8 import org.opendaylight.controller.sal.core.NodeConnector;
9 import org.opendaylight.ovsdb.database.Uuid;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
13 public class ConfigurationService implements IPluginInNetworkConfigurationService
15 private static final Logger logger = LoggerFactory
16 .getLogger(ConfigurationService.class);
18 IConnectionServiceInternal connectionService;
24 * Function called by the dependency manager when at least one dependency
25 * become unsatisfied or when the component is shutting down because for
26 * example bundle is being stopped.
33 * Function called by dependency manager after "init ()" is called and after
34 * the services provided by the class are registered in the service registry
41 * Function called by the dependency manager before the services exported by
42 * the component are unregistered, this will be followed by a "destroy ()"
49 public void setConnectionServiceInternal(IConnectionServiceInternal connectionService) {
50 this.connectionService = connectionService;
53 public void unsetConnectionServiceInternal(IConnectionServiceInternal connectionService) {
54 if (this.connectionService == connectionService) {
55 this.connectionService = null;
60 public boolean createBridgeDomain(Node node, String bridgeIdentifier){
61 if (connectionService == null) {
62 logger.error("Couldnt refer to the ConnectionService");
65 Connection connection = connectionService.getConnection(node);
66 String identifier = "TEST";
68 if (connection != null) {
69 String newBridge = "new_bridge";
70 String newInterface = "new_interface";
71 String newPort = "new_port";
72 String newSwitch = "new_switch";
74 Map<String, Object> bridgeRow = new HashMap<String, Object>();
75 bridgeRow.put("name", "br1");
76 ArrayList<String> ports = new ArrayList<String>();
77 ports.add("named-uuid");
79 bridgeRow.put("ports", ports);
80 InsertRequest addBridgeRequest = new InsertRequest("insert", "Bridge", newBridge, bridgeRow);
82 Map<String, Object> portRow = new HashMap<String, Object>();
83 portRow.put("name", "br1");
84 ArrayList<String> interfaces = new ArrayList<String>();
85 interfaces.add("named-uuid");
86 interfaces.add(newInterface);
87 portRow.put("interfaces", interfaces);
88 InsertRequest addPortRequest = new InsertRequest("insert", "Port", newPort, portRow);
90 Map<String, Object> interfaceRow = new HashMap<String, Object>();
91 interfaceRow.put("name", "br1");
92 interfaceRow.put("type", "internal");
93 InsertRequest addIntfRequest = new InsertRequest("insert", "Interface", newInterface, interfaceRow);
95 Map<String, Object> vswitchRow = new HashMap<String, Object>();
96 ArrayList<String> bridges = new ArrayList<String>();
97 bridges.add("named-uuid");
98 bridges.add(newBridge);
99 vswitchRow.put("bridges", bridges);
100 InsertRequest addSwitchRequest = new InsertRequest("insert", "Open_vSwitch", newSwitch, vswitchRow);
102 Object[] params = {"Open_vSwitch", addSwitchRequest, addIntfRequest, addPortRequest, addBridgeRequest};
103 OvsdbMessage msg = new OvsdbMessage("transact", params);
105 connection.sendMessage(msg);
106 connection.readResponse(Uuid[].class);
107 } catch (Exception e) {
108 // TODO Auto-generated catch block
111 } catch (Throwable e) {
112 // TODO Auto-generated catch block
121 public boolean deleteBridgeDomain(Node node, String bridgeIdentifier) {
122 // TODO Auto-generated method stub
127 public List<String> getBridgeDomains(Node node) {
128 // TODO Auto-generated method stub
133 public boolean addBridgeDomainConfig(Node node, String bridgeIdentifier, Map<String, String> config) {
134 // TODO Auto-generated method stub
139 public boolean removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map<String, String> config) {
140 // TODO Auto-generated method stub
145 public Map<String, String> getBridgeDomainConfigs(Node node, String bridgeIdentifier) {
146 // TODO Auto-generated method stub
151 public boolean createBridgeConnector(Node node, String bridgeConnectorIdentifier) {
152 // TODO Auto-generated method stub
157 public boolean deleteBridgeConnector(Node node, String bridgeConnectorIdentifier) {
158 // TODO Auto-generated method stub
163 public boolean associateBridgeConnector(Node node, String bridgeIdentifier, String bridgeConnectorIdentifier) {
164 // TODO Auto-generated method stub
169 public boolean disassociateBridgeConnector(Node node, String bridgeIdentifier, String bridgeConnectorIdentifier) {
170 // TODO Auto-generated method stub
175 public boolean addBridgeConnectorConfig(Node node, String bridgeConnectorIdentifier, Map<String, String> config) {
176 // TODO Auto-generated method stub
181 public boolean removeBridgeConnectorConfig(Node node, String bridgeConnectorIdentifier, Map<String, String> config) {
182 // TODO Auto-generated method stub
187 public Map<String, String> getBridgeConnectorConfigs(Node node, String bridgeConnectorIdentifier) {
188 // TODO Auto-generated method stub
193 public Object genericConfigurationEvent(Node node, Map<String, String> config) {
194 // TODO Auto-generated method stub