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.ConfigConstants;
18 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IBridgeDomainConfigService;
19 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
20 import org.opendaylight.controller.sal.utils.GlobalConstants;
21 import org.opendaylight.controller.sal.utils.Status;
22 import org.opendaylight.controller.sal.utils.StatusCode;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class BridgeDomainConfigService implements IBridgeDomainConfigService {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(BridgeDomainConfigService.class);
29 private ConcurrentMap<String, IPluginInBridgeDomainConfigService> pluginService =
30 new ConcurrentHashMap<String, IPluginInBridgeDomainConfigService>();
32 void setPluginInService (Map props, IPluginInBridgeDomainConfigService s) {
34 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
35 if (value instanceof String) {
36 type = (String) value;
39 logger.error("Received a PluginInConnectionService without any "
40 + "protocolPluginType provided");
42 this.pluginService.put(type, s);
46 void unsetPluginInService(Map props, IPluginInBridgeDomainConfigService s) {
49 Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
50 if (value instanceof String) {
51 type = (String) value;
54 logger.error("Received a PluginInConnectionService without any "
55 + "protocolPluginType provided");
56 } else if (this.pluginService.get(type).equals(s)) {
57 this.pluginService.remove(type);
62 * Function called by the dependency manager when all the required
63 * dependencies are satisfied
70 * Function called by the dependency manager when at least one dependency
71 * become unsatisfied or when the component is shutting down because for
72 * example bundle is being stopped.
76 if (this.pluginService != null) {
77 this.pluginService.clear();
82 public Status createBridgeDomain(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params)
84 if (pluginService != null) {
85 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
87 return plugin.createBridgeDomain(node, bridgeIdentifier, params);
90 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
94 public Status deleteBridgeDomain(Node node, String bridgeIdentifier) {
95 if (pluginService != null) {
96 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
98 return plugin.deleteBridgeDomain(node, bridgeIdentifier);
101 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
105 public List<String> getBridgeDomains(Node node) {
106 if (pluginService != null) {
107 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
108 if (plugin != null) {
109 return plugin.getBridgeDomains(node);
116 public Status addBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
117 if (pluginService != null) {
118 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
119 if (plugin != null) {
120 return plugin.addBridgeDomainConfig(node, bridgeIdentifier, params);
123 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
127 public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map<ConfigConstants, Object> params) {
128 if (pluginService != null) {
129 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
130 if (plugin != null) {
131 return plugin.removeBridgeDomainConfig(node, bridgeIdentifier, params);
134 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
138 public Map<ConfigConstants, Object> getBridgeDomainConfigs(Node node, String bridgeIdentifier) {
139 if (pluginService != null) {
140 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
141 if (plugin != null) {
142 return plugin.getBridgeDomainConfigs(node, bridgeIdentifier);
149 public Node getBridgeDomainNode(Node configNode, String bridgeIdentifier) {
150 if (pluginService != null) {
151 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
152 if (plugin != null) {
153 return plugin.getBridgeDomainNode(configNode, bridgeIdentifier);
160 public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, Map<ConfigConstants, Object> params) {
161 if (pluginService != null) {
162 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
163 if (plugin != null) {
164 return plugin.addPort(node, bridgeIdentifier, portIdentifier, params);
167 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
171 public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier) {
172 if (pluginService != null) {
173 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
174 if (plugin != null) {
175 return plugin.deletePort(node, bridgeIdentifier, portIdentifier);
178 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
182 public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier,
183 Map<ConfigConstants, Object> params) {
184 if (pluginService != null) {
185 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
186 if (plugin != null) {
187 return plugin.addPortConfig(node, bridgeIdentifier, portIdentifier, params);
190 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
194 public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier,
195 Map<ConfigConstants, Object> params) {
196 if (pluginService != null) {
197 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
198 if (plugin != null) {
199 return plugin.removePortConfig(node, bridgeIdentifier, portIdentifier, params);
202 return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available");
206 public Map<ConfigConstants, Object> getPortConfigs(Node node, String bridgeIdentifier, String portIdentifier) {
207 if (pluginService != null) {
208 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType());
209 if (plugin != null) {
210 return plugin.getPortConfigs(node, bridgeIdentifier, portIdentifier);
217 public NodeConnector getNodeConnector(Node configNode, String bridgeIdentifier, String portIdentifier) {
218 if (pluginService != null) {
219 IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType());
220 if (plugin != null) {
221 return plugin.getNodeConnector(configNode, bridgeIdentifier, portIdentifier);