2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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 package org.opendaylight.controller.sal.networkconfig.bridgedomain.internal;
10 import java.util.List;
12 import java.util.concurrent.ConcurrentHashMap;
13 import java.util.concurrent.ConcurrentMap;
15 import org.opendaylight.controller.sal.core.Node;
16 import org.opendaylight.controller.sal.core.NodeConnector;
17 import org.opendaylight.controller.sal.networkconfig.bridgedomain.BridgeDomainConfigServiceException;
18 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
19 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IBridgeDomainConfigService;
20 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
21 import org.opendaylight.controller.sal.utils.GlobalConstants;
22 import org.opendaylight.controller.sal.utils.Status;
23 import org.opendaylight.controller.sal.utils.StatusCode;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class BridgeDomainConfigService implements IBridgeDomainConfigService {
28 protected static final Logger logger = LoggerFactory
29 .getLogger(BridgeDomainConfigService.class);
30 private final ConcurrentMap<String, IPluginInBridgeDomainConfigService> pluginService =
31 new ConcurrentHashMap<String, IPluginInBridgeDomainConfigService>();
33 void setPluginInService (Map props, IPluginInBridgeDomainConfigService s) {
35 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
36 if (value instanceof String) {
37 type = (String) value;
40 logger.error("Received a PluginInConnectionService without any "
41 + "protocolPluginType provided");
43 this.pluginService.put(type, s);
47 void unsetPluginInService(Map props, IPluginInBridgeDomainConfigService s) {
50 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
51 if (value instanceof String) {
52 type = (String) value;
55 logger.error("Received a PluginInConnectionService without any "
56 + "protocolPluginType provided");
57 } else if (this.pluginService.get(type).equals(s)) {
58 this.pluginService.remove(type);
63 * Function called by the dependency manager when all the required
64 * dependencies are satisfied
71 * Function called by the dependency manager when at least one dependency
72 * become unsatisfied or when the component is shutting down because for
73 * example bundle is being stopped.
77 if (this.pluginService != null) {
78 this.pluginService.clear();
83 public Status createBridgeDomain(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params)
84 throws BridgeDomainConfigServiceException {
85 if (pluginService != null) {
86 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
88 return plugin.createBridgeDomain(node, bridgeIdentifier, params);
91 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
95 public Status deleteBridgeDomain(Node node, String bridgeIdentifier) {
96 if (pluginService != null) {
97 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
99 return plugin.deleteBridgeDomain(node, bridgeIdentifier);
102 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
106 public List<String> getBridgeDomains(Node node) {
107 if (pluginService != null) {
108 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
109 if (plugin != null) {
110 return plugin.getBridgeDomains(node);
117 public Status addBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
118 if (pluginService != null) {
119 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
120 if (plugin != null) {
121 return plugin.addBridgeDomainConfig(node, bridgeIdentifier, params);
124 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
128 public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
129 if (pluginService != null) {
130 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
131 if (plugin != null) {
132 return plugin.removeBridgeDomainConfig(node, bridgeIdentifier, params);
135 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
139 public Map<ConfigConstants, Object> getBridgeDomainConfigs(Node node, String bridgeIdentifier) {
140 if (pluginService != null) {
141 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
142 if (plugin != null) {
143 return plugin.getBridgeDomainConfigs(node, bridgeIdentifier);
150 public Node getBridgeDomainNode(Node configNode, String bridgeIdentifier) {
151 if (pluginService != null) {
152 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
153 if (plugin != null) {
154 return plugin.getBridgeDomainNode(configNode, bridgeIdentifier);
161 public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, Map<ConfigConstants, Object> params) {
162 if (pluginService != null) {
163 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
164 if (plugin != null) {
165 return plugin.addPort(node, bridgeIdentifier, portIdentifier, params);
168 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
172 public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier) {
173 if (pluginService != null) {
174 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
175 if (plugin != null) {
176 return plugin.deletePort(node, bridgeIdentifier, portIdentifier);
179 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
183 public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier,
184 Map<ConfigConstants, Object> params) {
185 if (pluginService != null) {
186 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
187 if (plugin != null) {
188 return plugin.addPortConfig(node, bridgeIdentifier, portIdentifier, params);
191 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
195 public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier,
196 Map<ConfigConstants, Object> params) {
197 if (pluginService != null) {
198 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
199 if (plugin != null) {
200 return plugin.removePortConfig(node, bridgeIdentifier, portIdentifier, params);
203 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
207 public Map<ConfigConstants, Object> getPortConfigs(Node node, String bridgeIdentifier, String portIdentifier) {
208 if (pluginService != null) {
209 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
210 if (plugin != null) {
211 return plugin.getPortConfigs(node, bridgeIdentifier, portIdentifier);
218 public NodeConnector getNodeConnector(Node configNode, String bridgeIdentifier, String portIdentifier) {
219 if (pluginService != null) {
220 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
221 if (plugin != null) {
222 return plugin.getNodeConnector(configNode, bridgeIdentifier, portIdentifier);