From: Giovanni Meo Date: Thu, 1 Aug 2013 20:31:06 +0000 (+0000) Subject: Merge "NetworkConfiguration -> BridgeDomain Configuration Service" X-Git-Tag: releasepom-0.1.0~245 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=aa1542461e6a76e5ad8171fa993a5d65522b0491;hp=970fb91c60c15a9b57e078f81aab7dde903addb9 Merge "NetworkConfiguration -> BridgeDomain Configuration Service" --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index e6871afa77..807dea52e3 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -75,6 +75,8 @@ ../../sal/connection/api ../../sal/connection/implementation + ../../sal/networkconfiguration/api + ../../sal/networkconfiguration/implementation ../../web/root diff --git a/opendaylight/sal/networkconfiguration/api/pom.xml b/opendaylight/sal/networkconfiguration/api/pom.xml new file mode 100644 index 0000000000..579c96358f --- /dev/null +++ b/opendaylight/sal/networkconfiguration/api/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../../commons/opendaylight + + + sal.networkconfiguration + 0.0.1-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + org.slf4j, + org.osgi.framework, + org.apache.felix.dm, + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils + + + org.opendaylight.controller.sal.networkconfig.bridgedomain + + + ${project.basedir}/META-INF + + + + + + + org.opendaylight.controller + sal + 0.5.0-SNAPSHOT + + + diff --git a/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/ConfigConstants.java b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/ConfigConstants.java new file mode 100644 index 0000000000..27240e8f99 --- /dev/null +++ b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/ConfigConstants.java @@ -0,0 +1,33 @@ +package org.opendaylight.controller.sal.networkconfig.bridgedomain; + +/** + * Enum constant that is used as a key for the configuration parameters for BridgeDomains and Ports. + * The main intention of having a constant type is to avoid fragmentation and find common grounds for + * applications to rely on. + * + * This is set to expand based on various capabilities south-bound protocol might expose. + * Not all of them be supported by all the plugins. But this gives a consolidated view of + * all the supported feature configs and avoid config fragmentation. + */ +public enum ConfigConstants { + TYPE("type"), + VLAN("Vlan"), + VLAN_MODE("vlan_mode"), + TUNNEL_TYPE("Tunnel Type"), + SOURCE_IP("Source IP"), + DEST_IP("Destination IP"), + MACADDRESS("MAC Address"), + INTERFACE_IDENTIFIER("Interface Identifier"), + MGMT("Management"), + CUSTOM("Custom Configurations"); + + private ConfigConstants(String name) { + this.name = name; + } + + private String name; + + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IBridgeDomainConfigService.java b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IBridgeDomainConfigService.java new file mode 100644 index 0000000000..04dd59ef3a --- /dev/null +++ b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IBridgeDomainConfigService.java @@ -0,0 +1,4 @@ +package org.opendaylight.controller.sal.networkconfig.bridgedomain; + +public interface IBridgeDomainConfigService extends IPluginInBridgeDomainConfigService { +} \ No newline at end of file diff --git a/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IPluginInBridgeDomainConfigService.java b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IPluginInBridgeDomainConfigService.java new file mode 100644 index 0000000000..20562b80e7 --- /dev/null +++ b/opendaylight/sal/networkconfiguration/api/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/IPluginInBridgeDomainConfigService.java @@ -0,0 +1,157 @@ +package org.opendaylight.controller.sal.networkconfig.bridgedomain; + +import java.util.List; +import java.util.Map; + +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.utils.Status; + +/** + * @file IPluginInConfigurationService.java + * + */ +public interface IPluginInBridgeDomainConfigService { + /** + * Create a Bridge Domain + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param params Map representation of config name (ConfigConstants) and Parameter value (represented as Object). + * @return Status.StatusCode.SUCCESS if bridge domain is created successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status createBridgeDomain(Node node, String bridgeIdentifier, Map params) throws Throwable; + + /** + * Delete a Bridge Domain + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @return Status.StatusCode.SUCCESS if bridge domain is deleted successfully. Failure Status otherwise. + */ + public Status deleteBridgeDomain(Node node, String bridgeIdentifier); + + /** + * Returns the configured Bridge Domains + * + * @param node Node serving this configuration service + * @return List of Bridge Domain Identifiers + */ + public List getBridgeDomains(Node node); + + /** + * add Bridge Domain Configuration + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param params Map representation of config Name (ConfigConstants) and config value(represented as Object). + * @return Status.StatusCode.SUCCESS if bridge domain configuration is added successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status addBridgeDomainConfig(Node node, String bridgeIdentifier, Map params); + + /** + * Delete Bridge Domain Configuration + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param params Map representation of config name (ConfigConstants) and Parameter value (represented as Object). + * @return Status.StatusCode.SUCCESS if bridge domain configuration is deleted successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map params); + + /** + * Returns Bridge Domain Configurations + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @return Map representation of config Name (ConfigConstants) and config value(represented as Object). + */ + + public Map getBridgeDomainConfigs(Node node, String bridgeIdentifier); + + /** + * Returns a Node dedicated to a Bridge Domain (if available) that is created using createBridgeDomain. + * @param configNode Node serving this configuration service. + * @param bridgeIdentifier Name of the bridge domain that would map to a dedicated Node + * @return Node dedicated to a bridge domain that is created using createBridgeDomain. + * returns null if there is no such dedicated node is available or represented. + */ + public Node getBridgeDomainNode(Node configNode, String bridgeIdentifier); + + /** + * Add a port to a bridge domain + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param portIdentifier String representation of a Port. + * @param params Map representation of config name (ConfigConstants) and Parameter value (represented as Object). + * @return Status.StatusCode.SUCCESS if a port is added successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, + Map params); + + /** + * Delete a Port from a bridge domain + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param portIdentifier String representation of a Port. + * @return Status.StatusCode.SUCCESS if a port is added successfully. Failure Status otherwise. + */ + public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier); + + /** + * add Port Configuration + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param portIdentifier String representation of a Port. + * @param params Map representation of config name (ConfigConstants) and Parameter value (represented as Object). + * @return Status.StatusCode.SUCCESS if a port configuration is added successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier, + Map params); + + /** + * Delete Port Configuration + * + * @param node Node serving this configuration service + * @param portIdentifier String representation of a Port. + * @param config Map representation of ConfigName and Configuration Value in Strings. + * @return Status.StatusCode.SUCCESS if a port configuration is removed successfully. Failure Status otherwise. + * @note This method will return false if one or more of the supplied params is not supported by the + * protocol plugin that serves the Node. + */ + public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier, Map params); + + /** + * Returns Port Configurations + * + * @param node Node serving this configuration service + * @param bridgeIdentifier String representation of a Bridge Domain + * @param portIdentifier String representation of a Port. + * @return Map representation of Configuration Name (ConfigConstants) and Configuration value (represented as Object). + */ + public Map getPortConfigs(Node node, String bridgeIdentifier, String portIdentifier); + + + /** + * Returns a NodeConnector mapped to a Port (if available) that is created using addPort. + * @param configNode Node serving this configuration service. + * @param bridgeIdentifier Name of the bridge domain that would map to a dedicated Node + * @param portIdentifier String representation of a Port. + * @return NodeConnector that is mapped to a port created using addPort. + * returns null if there is no such nodeConnector is available or mapped. + */ + public NodeConnector getNodeConnector(Node configNode, String bridgeIdentifier, String portIdentifier); +} \ No newline at end of file diff --git a/opendaylight/sal/networkconfiguration/implementation/pom.xml b/opendaylight/sal/networkconfiguration/implementation/pom.xml new file mode 100644 index 0000000000..7a9505792d --- /dev/null +++ b/opendaylight/sal/networkconfiguration/implementation/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../../commons/opendaylight + + + sal.networkconfiguration.implementation + 0.0.1-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + org.slf4j, + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.networkconfig.bridgedomain, + org.apache.felix.dm, + org.osgi.framework + + + + + org.opendaylight.controller.sal.networkconfig.internal.Activator + + + ${project.basedir}/META-INF + + + + + + + org.opendaylight.controller + sal + 0.5.0-SNAPSHOT + + + org.opendaylight.controller + sal.networkconfiguration + 0.0.1-SNAPSHOT + + + diff --git a/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/internal/BridgeDomainConfigService.java b/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/internal/BridgeDomainConfigService.java new file mode 100644 index 0000000000..1c9ca573bd --- /dev/null +++ b/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/bridgedomain/internal/BridgeDomainConfigService.java @@ -0,0 +1,219 @@ +package org.opendaylight.controller.sal.networkconfig.bridgedomain.internal; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.IBridgeDomainConfigService; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService; +import org.opendaylight.controller.sal.utils.GlobalConstants; +import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.sal.utils.StatusCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BridgeDomainConfigService implements IBridgeDomainConfigService { + protected static final Logger logger = LoggerFactory + .getLogger(BridgeDomainConfigService.class); + private ConcurrentMap pluginService = + new ConcurrentHashMap(); + + void setPluginInService (Map props, IPluginInBridgeDomainConfigService s) { + String type = null; + Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); + if (value instanceof String) { + type = (String) value; + } + if (type == null) { + logger.error("Received a PluginInConnectionService without any " + + "protocolPluginType provided"); + } else { + this.pluginService.put(type, s); + } + } + + void unsetPluginInService(Map props, IPluginInBridgeDomainConfigService s) { + String type = null; + + Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); + if (value instanceof String) { + type = (String) value; + } + if (type == null) { + logger.error("Received a PluginInConnectionService without any " + + "protocolPluginType provided"); + } else if (this.pluginService.get(type).equals(s)) { + this.pluginService.remove(type); + } + } + + /** + * Function called by the dependency manager when all the required + * dependencies are satisfied + * + */ + void init() { + } + + /** + * Function called by the dependency manager when at least one dependency + * become unsatisfied or when the component is shutting down because for + * example bundle is being stopped. + * + */ + void destroy() { + if (this.pluginService != null) { + this.pluginService.clear(); + } + } + + @Override + public Status createBridgeDomain(Node node, String bridgeIdentifier, Map params) + throws Throwable { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.createBridgeDomain(node, bridgeIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Status deleteBridgeDomain(Node node, String bridgeIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.deleteBridgeDomain(node, bridgeIdentifier); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public List getBridgeDomains(Node node) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.getBridgeDomains(node); + } + } + return null; + } + + @Override + public Status addBridgeDomainConfig(Node node, String bridgeIdentifier, Map params) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.addBridgeDomainConfig(node, bridgeIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier, Map params) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.removeBridgeDomainConfig(node, bridgeIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Map getBridgeDomainConfigs(Node node, String bridgeIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.getBridgeDomainConfigs(node, bridgeIdentifier); + } + } + return null; + } + + @Override + public Node getBridgeDomainNode(Node configNode, String bridgeIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType()); + if (plugin != null) { + return plugin.getBridgeDomainNode(configNode, bridgeIdentifier); + } + } + return null; + } + + @Override + public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, Map params) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.addPort(node, bridgeIdentifier, portIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.deletePort(node, bridgeIdentifier, portIdentifier); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier, + Map params) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.addPortConfig(node, bridgeIdentifier, portIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier, + Map params) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.removePortConfig(node, bridgeIdentifier, portIdentifier, params); + } + } + return new Status(StatusCode.NOSERVICE, "Requested Plugin Service Not available"); + } + + @Override + public Map getPortConfigs(Node node, String bridgeIdentifier, String portIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(node.getType()); + if (plugin != null) { + return plugin.getPortConfigs(node, bridgeIdentifier, portIdentifier); + } + } + return null; + } + + @Override + public NodeConnector getNodeConnector(Node configNode, String bridgeIdentifier, String portIdentifier) { + if (pluginService != null) { + IPluginInBridgeDomainConfigService plugin = this.pluginService.get(configNode.getType()); + if (plugin != null) { + return plugin.getNodeConnector(configNode, bridgeIdentifier, portIdentifier); + } + } + return null; + } +} \ No newline at end of file diff --git a/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/internal/Activator.java b/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/internal/Activator.java new file mode 100644 index 0000000000..d647faab07 --- /dev/null +++ b/opendaylight/sal/networkconfiguration/implementation/src/main/java/org/opendaylight/controller/sal/networkconfig/internal/Activator.java @@ -0,0 +1,71 @@ +package org.opendaylight.controller.sal.networkconfig.internal; + +import org.apache.felix.dm.Component; +import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.IBridgeDomainConfigService; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService; +import org.opendaylight.controller.sal.networkconfig.bridgedomain.internal.BridgeDomainConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Activator extends ComponentActivatorAbstractBase { + protected static final Logger logger = LoggerFactory + .getLogger(Activator.class); + + /** + * Function called when the activator starts just after some initializations + * are done by the ComponentActivatorAbstractBase. + * + */ + @Override + public void init() { + + } + + /** + * Function called when the activator stops just before the cleanup done by + * ComponentActivatorAbstractBase + * + */ + @Override + public void destroy() { + + } + + /** + * Function that is used to communicate to dependency manager the list of + * known Global implementations + * + * + * @return An array containing all the CLASS objects that will be + * instantiated in order to get an fully working implementation + * Object + */ + public Object[] getGlobalImplementations() { + Object[] res = { BridgeDomainConfigService.class}; + return res; + } + + /** + * Function that is called when configuration of the dependencies is required. + * + * @param c + * dependency manager Component object, used for configuring the + * dependencies exported and imported + * @param imp + * Implementation class that is being configured, needed as long + * as the same routine can configure multiple implementations + */ + public void configureGlobalInstance(Component c, Object imp) { + if (imp.equals(BridgeDomainConfigService.class)) { + c.setInterface( + new String[] { IBridgeDomainConfigService.class.getName()}, + null); + + c.add(createServiceDependency() + .setService(IPluginInBridgeDomainConfigService.class) + .setCallbacks("setPluginInService", "unsetPluginInService") + .setRequired(false)); + } + } +}