1 package org.opendaylight.controller.sal.networkconfig.bridgedomain.internal;
5 import java.util.concurrent.ConcurrentHashMap;
6 import java.util.concurrent.ConcurrentMap;
8 import org.opendaylight.controller.sal.core.Node;
9 import org.opendaylight.controller.sal.core.NodeConnector;
10 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
11 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IBridgeDomainConfigService;
12 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
13 import org.opendaylight.controller.sal.utils.GlobalConstants;
14 import org.opendaylight.controller.sal.utils.Status;
15 import org.opendaylight.controller.sal.utils.StatusCode;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class BridgeDomainConfigService implements IBridgeDomainConfigService {
20 protected static final Logger logger = LoggerFactory
21 .getLogger(BridgeDomainConfigService.class);
22 private ConcurrentMap<String, IPluginInBridgeDomainConfigService> pluginService =
23 new ConcurrentHashMap<String, IPluginInBridgeDomainConfigService>();
25 void setPluginInService (Map props, IPluginInBridgeDomainConfigService s) {
27 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
28 if (value instanceof String) {
29 type = (String) value;
32 logger.error("Received a PluginInConnectionService without any "
33 + "protocolPluginType provided");
35 this.pluginService.put(type, s);
39 void unsetPluginInService(Map props, IPluginInBridgeDomainConfigService s) {
42 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
43 if (value instanceof String) {
44 type = (String) value;
47 logger.error("Received a PluginInConnectionService without any "
48 + "protocolPluginType provided");
49 } else if (this.pluginService.get(type).equals(s)) {
50 this.pluginService.remove(type);
55 * Function called by the dependency manager when all the required
56 * dependencies are satisfied
63 * Function called by the dependency manager when at least one dependency
64 * become unsatisfied or when the component is shutting down because for
65 * example bundle is being stopped.
69 if (this.pluginService != null) {
70 this.pluginService.clear();
75 public Status createBridgeDomain(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params)
77 if (pluginService != null) {
78 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
80 return plugin.createBridgeDomain(node, bridgeIdentifier, params);
83 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
87 public Status deleteBridgeDomain(Node node, String bridgeIdentifier) {
88 if (pluginService != null) {
89 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
91 return plugin.deleteBridgeDomain(node, bridgeIdentifier);
94 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
98 public List<String> getBridgeDomains(Node node) {
99 if (pluginService != null) {
100 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
101 if (plugin != null) {
102 return plugin.getBridgeDomains(node);
109 public Status addBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
110 if (pluginService != null) {
111 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
112 if (plugin != null) {
113 return plugin.addBridgeDomainConfig(node, bridgeIdentifier, params);
116 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
120 public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
121 if (pluginService != null) {
122 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
123 if (plugin != null) {
124 return plugin.removeBridgeDomainConfig(node, bridgeIdentifier, params);
127 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
131 public Map<ConfigConstants, Object> getBridgeDomainConfigs(Node node, String bridgeIdentifier) {
132 if (pluginService != null) {
133 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
134 if (plugin != null) {
135 return plugin.getBridgeDomainConfigs(node, bridgeIdentifier);
142 public Node getBridgeDomainNode(Node configNode, String bridgeIdentifier) {
143 if (pluginService != null) {
144 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
145 if (plugin != null) {
146 return plugin.getBridgeDomainNode(configNode, bridgeIdentifier);
153 public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, Map<ConfigConstants, Object> params) {
154 if (pluginService != null) {
155 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
156 if (plugin != null) {
157 return plugin.addPort(node, bridgeIdentifier, portIdentifier, params);
160 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
164 public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier) {
165 if (pluginService != null) {
166 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
167 if (plugin != null) {
168 return plugin.deletePort(node, bridgeIdentifier, portIdentifier);
171 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
175 public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier,
176 Map<ConfigConstants, Object> params) {
177 if (pluginService != null) {
178 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
179 if (plugin != null) {
180 return plugin.addPortConfig(node, bridgeIdentifier, portIdentifier, params);
183 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
187 public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier,
188 Map<ConfigConstants, Object> params) {
189 if (pluginService != null) {
190 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
191 if (plugin != null) {
192 return plugin.removePortConfig(node, bridgeIdentifier, portIdentifier, params);
195 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
199 public Map<ConfigConstants, Object> getPortConfigs(Node node, String bridgeIdentifier, String portIdentifier) {
200 if (pluginService != null) {
201 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
202 if (plugin != null) {
203 return plugin.getPortConfigs(node, bridgeIdentifier, portIdentifier);
210 public NodeConnector getNodeConnector(Node configNode, String bridgeIdentifier, String portIdentifier) {
211 if (pluginService != null) {
212 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
213 if (plugin != null) {
214 return plugin.getNodeConnector(configNode, bridgeIdentifier, portIdentifier);