<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
@RunWith(PaxExam.class)
public class ConfigurationIT {
- private Logger logger = LoggerFactory
+ private final Logger logger = LoggerFactory
.getLogger(ConfigurationIT.class);
// get the OSGI bundle context
@Inject
mavenBundle("org.opendaylight.controller",
"containermanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "switchmanager",
- "0.4.0-SNAPSHOT"),
+ "0.5.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller",
"switchmanager.implementation", "0.4.0-SNAPSHOT"),
// needed bundles by configuration
<!-- SAL Extension bundles -->
<module>../../sal/connection/api</module>
<module>../../sal/connection/implementation</module>
+ <module>../../sal/networkconfiguration/api</module>
+ <module>../../sal/networkconfiguration/implementation</module>
<!-- Web bundles -->
<module>../../web/root</module>
</root>
<!-- Base log level -->
- <logger name="org.opendaylight.controller" level="INFO"/>
+ <logger name="org.opendaylight" level="INFO"/>
<!-- OSGi logging bridge -->
<logger name="org.opendaylight.controller.logging.bridge" level="WARN"/>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>switchmanager</artifactId>\r
- <version>0.4.0-SNAPSHOT</version>\r
+ <version>0.5.0-SNAPSHOT</version>\r
</dependency>\r
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>switchmanager</artifactId>\r
- <version>0.4.0-SNAPSHOT</version>\r
+ <version>0.5.0-SNAPSHOT</version>\r
</dependency>\r
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>switchmanager</artifactId>\r
- <version>0.4.0-SNAPSHOT</version>\r
+ <version>0.5.0-SNAPSHOT</version>\r
</dependency>\r
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
@RunWith(PaxExam.class)
public class NorthboundIT {
- private Logger log = LoggerFactory.getLogger(NorthboundIT.class);
+ private final Logger log = LoggerFactory.getLogger(NorthboundIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
private IInventoryListener invtoryListener = null;
private IListenTopoUpdates topoUpdates = null;
- private Boolean debugMsg = false;
+ private final Boolean debugMsg = false;
private String stateToString(int state) {
switch (state) {
mavenBundle("org.opendaylight.controller", "security", "0.4.0-SNAPSHOT").noStart(),
mavenBundle("org.opendaylight.controller", "sal", "0.5.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager", "0.5.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "switchmanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "forwardingrulesmanager.implementation", "0.4.0-SNAPSHOT"),
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
--- /dev/null
+package org.opendaylight.controller.sal.core;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * The class represents the forwarding mode property of a node.
+ */
+@XmlRootElement
+@SuppressWarnings("serial")
+public class ForwardingMode extends Property {
+ @XmlElement
+ private final int modeValue;
+ public static final int REACTIVE_FORWARDING = 0;
+ public static final int PROACTIVE_FORWARDING = 1;
+ public static final String name = "mode";
+
+ /*
+ * Private constructor used for JAXB mapping
+ */
+ private ForwardingMode() {
+ super(name);
+ this.modeValue = REACTIVE_FORWARDING;
+ }
+
+ public ForwardingMode(int mode) {
+ super(name);
+ this.modeValue = mode;
+ }
+
+ public int getValue() {
+ return this.modeValue;
+ }
+
+ public boolean isProactive() {
+ return (modeValue == ForwardingMode.PROACTIVE_FORWARDING);
+ }
+
+ public boolean isValid() {
+ return ((modeValue >= 0) && (modeValue <= 1));
+ }
+
+ @Override
+ public ForwardingMode clone() {
+ return new ForwardingMode(this.modeValue);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + modeValue;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ForwardingMode other = (ForwardingMode) obj;
+ if (modeValue != other.modeValue)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Mode[" + modeValue + "]";
+ }
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>commons.opendaylight</artifactId>\r
+ <version>1.4.0-SNAPSHOT</version>\r
+ <relativePath>../../../commons/opendaylight</relativePath>\r
+ </parent>\r
+\r
+ <artifactId>sal.networkconfiguration</artifactId>\r
+ <version>0.0.1-SNAPSHOT</version>\r
+ <packaging>bundle</packaging>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.felix</groupId>\r
+ <artifactId>maven-bundle-plugin</artifactId>\r
+ <version>2.3.6</version>\r
+ <extensions>true</extensions>\r
+ <configuration>\r
+ <instructions>\r
+ <Import-Package>\r
+ org.slf4j,\r
+ org.osgi.framework,\r
+ org.apache.felix.dm,\r
+ org.opendaylight.controller.sal.core,\r
+ org.opendaylight.controller.sal.utils\r
+ </Import-Package>\r
+ <Export-Package>\r
+ org.opendaylight.controller.sal.networkconfig.bridgedomain\r
+ </Export-Package>\r
+ </instructions>\r
+ <manifestLocation>${project.basedir}/META-INF</manifestLocation>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal</artifactId>\r
+ <version>0.5.0-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>\r
--- /dev/null
+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
--- /dev/null
+package org.opendaylight.controller.sal.networkconfig.bridgedomain;
+
+public interface IBridgeDomainConfigService extends IPluginInBridgeDomainConfigService {
+}
\ No newline at end of file
--- /dev/null
+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<ConfigConstants, Object> 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<String> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>commons.opendaylight</artifactId>\r
+ <version>1.4.0-SNAPSHOT</version>\r
+ <relativePath>../../../commons/opendaylight</relativePath>\r
+ </parent>\r
+\r
+ <artifactId>sal.networkconfiguration.implementation</artifactId>\r
+ <version>0.0.1-SNAPSHOT</version>\r
+ <packaging>bundle</packaging>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.felix</groupId>\r
+ <artifactId>maven-bundle-plugin</artifactId>\r
+ <version>2.3.6</version>\r
+ <extensions>true</extensions>\r
+ <configuration>\r
+ <instructions>\r
+ <Import-Package>\r
+ org.slf4j,\r
+ org.opendaylight.controller.sal.core,\r
+ org.opendaylight.controller.sal.utils,\r
+ org.opendaylight.controller.sal.networkconfig.bridgedomain,\r
+ org.apache.felix.dm,\r
+ org.osgi.framework\r
+ </Import-Package>\r
+ <Export-Package>\r
+ </Export-Package>\r
+ <Bundle-Activator>\r
+ org.opendaylight.controller.sal.networkconfig.internal.Activator\r
+ </Bundle-Activator>\r
+ </instructions>\r
+ <manifestLocation>${project.basedir}/META-INF</manifestLocation>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal</artifactId>\r
+ <version>0.5.0-SNAPSHOT</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal.networkconfiguration</artifactId>\r
+ <version>0.0.1-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
+</project>\r
--- /dev/null
+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<String, IPluginInBridgeDomainConfigService> pluginService =
+ new ConcurrentHashMap<String, IPluginInBridgeDomainConfigService>();
+
+ 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<ConfigConstants, Object> 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<String> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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<ConfigConstants, Object> 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
--- /dev/null
+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));
+ }
+ }
+}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
</parent>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<properties>
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.switchmanager.SpanConfig;
-import org.opendaylight.controller.switchmanager.Subnet;
-import org.opendaylight.controller.switchmanager.SubnetConfig;
-import org.opendaylight.controller.switchmanager.Switch;
-import org.opendaylight.controller.switchmanager.SwitchConfig;
-
/**
* Primary purpose of this interface is to provide methods for application to
* access various system resources and inventory data including nodes, node
* Update Switch specific configuration such as Switch Name and Tier
*
* @param cfgConfig refer to {@link Open Declaration org.opendaylight.controller.switchmanager.SwitchConfig}
+ *
+ * @deprecated replaced by updateNodeConfig(switchConfig)
*/
+ @Deprecated
public void updateSwitchConfig(SwitchConfig cfgObject);
+ /**
+ * Update Node specific configuration such as Node Name and Tier
+ *
+ * @param cfgConfig
+ * refer to {@link Open Declaration
+ * org.opendaylight.controller.switchmanager.SwitchConfig}
+ * @return "Success" or failure reason
+ */
+ public Status updateNodeConfig(SwitchConfig switchConfig);
+
+ /**
+ * Removes node properties configured by the user
+ *
+ * @param nodeId
+ * Node Identifier as specified by
+ * {@link org.opendaylight.controller.sal.core.Node}
+ * @return "Success" or failure reason
+ */
+ public Status removeNodeConfig(String nodeId);
+
/**
* Return the previously configured Switch Configuration given the node id
*
- * @param nodeId Node Identifier as specified by {@link org.opendaylight.controller.sal.core.Node}
- * @return {@link org.opendaylight.controller.switchmanager.SwitchConfig} resources
+ * @param nodeId
+ * Node Identifier as specified by
+ * {@link org.opendaylight.controller.sal.core.Node}
+ * @return {@link org.opendaylight.controller.switchmanager.SwitchConfig}
+ * resources
*/
public SwitchConfig getSwitchConfig(String nodeId);
* configured and the network node does not provide its description,
* an empty string is returned.
*/
+ @Deprecated
public String getNodeDescription(Node node);
}
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
package org.opendaylight.controller.switchmanager;
import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.ForwardingMode;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.Tier;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
/**
- * The class describes a switch configuration including node identifier, node
- * name, tier number and proactive/reactive mode.
+ * The class describes a switch configuration
*/
-public class SwitchConfig implements Serializable {
+public class SwitchConfig implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
- String nodeId;
- String description;
- String tier;
- String mode;
+ private final String nodeId;
+ private final Map<String, Property> nodeProperties;
+
+ public SwitchConfig(String nodeId, Map<String, Property> nodeProperties) {
+ this.nodeId = nodeId;
+ this.nodeProperties = (nodeProperties == null) ? new HashMap<String, Property>()
+ : new HashMap<String, Property>(nodeProperties);
+ }
+ @Deprecated
public SwitchConfig(String nodeId, String description, String tier, String mode) {
- super();
this.nodeId = nodeId;
- this.description = description;
- this.tier = tier;
- this.mode = mode;
+ this.nodeProperties = new HashMap<String, Property>();
+ Property desc = new Description(description);
+ this.nodeProperties.put(desc.getName(), desc);
+ Property nodeTier = new Tier(Integer.valueOf(tier));
+ this.nodeProperties.put(nodeTier.getName(), nodeTier);
+ Property forwardingMode = new ForwardingMode(Integer.valueOf(mode));
+ this.nodeProperties.put(forwardingMode.getName(), forwardingMode);
}
public String getNodeId() {
- return nodeId;
+ return this.nodeId;
+ }
+
+ public Map<String, Property> getNodeProperties() {
+ return new HashMap<String, Property>(this.nodeProperties);
+ }
+
+ public Property getProperty(String PropName) {
+ return nodeProperties.get(PropName);
}
+ /**
+ * This method returns the configured description of the node
+ *
+ * @return Configured description
+ *
+ * @deprecated replaced by getProperty(Description.propertyName)
+ */
+ @Deprecated
public String getNodeDescription() {
- return description;
+ Description description = (Description) getProperty(Description.propertyName);
+ return (description == null) ? null : description.getValue();
}
+ /**
+ * This method returns the configured Tier of a node
+ *
+ * @return Configured tier
+ *
+ * @deprecated replaced by getProperty(Tier.TierPropName)
+ */
+ @Deprecated
public String getTier() {
- return tier;
+ Tier tier = (Tier) getProperty(Tier.TierPropName);
+ return (tier == null) ? null : String.valueOf(tier.getValue());
}
+ /**
+ * This method returns the configured Forwarding Mode of a node
+ *
+ * @return Configured Forwarding Mode
+ *
+ * @deprecated replaced by getProperty(ForwardingMode.name)
+ */
+ @Deprecated
public String getMode() {
- return mode;
+ ForwardingMode forwardingMode = (ForwardingMode) getProperty(ForwardingMode.name);
+ return (forwardingMode == null) ? null : String.valueOf(forwardingMode.getValue());
}
+ /**
+ * This method returns true, if the configured forwarding mode is proactive,
+ * else false
+ *
+ * @return true, if the configured forwarding mode is proactive, else false
+ *
+ * @deprecated replaced by isProactive() API of ForwardingMode property
+ */
+ @Deprecated
public boolean isProactive() {
- return Integer.parseInt(mode) != 0;
+ return Integer.parseInt(getMode()) == ForwardingMode.PROACTIVE_FORWARDING;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
+ public Status validate() {
+ Status validCheck = validateNodeId();
+ if (validCheck.isSuccess()) {
+ validCheck = validateNodeProperties();
+ }
+ return validCheck;
+ }
+
+ private Status validateNodeId() {
+ if (nodeId == null || nodeId.isEmpty()) {
+ return new Status(StatusCode.BADREQUEST, "NodeId cannot be empty");
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
+ private Status validateNodeProperties() {
+ if (nodeProperties == null) {
+ return new Status(StatusCode.BADREQUEST, "nodeProperties cannot be null");
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result
- + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((mode == null) ? 0 : mode.hashCode());
result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
- result = prime * result + ((tier == null) ? 0 : tier.hashCode());
+ result = prime * result + ((nodeProperties == null) ? 0 : nodeProperties.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
SwitchConfig other = (SwitchConfig) obj;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (mode == null) {
- if (other.mode != null)
- return false;
- } else if (!mode.equals(other.mode))
- return false;
if (nodeId == null) {
- if (other.nodeId != null)
+ if (other.nodeId != null) {
return false;
- } else if (!nodeId.equals(other.nodeId))
+ }
+ } else if (!nodeId.equals(other.nodeId)) {
return false;
- if (tier == null) {
- if (other.tier != null)
+ }
+ if (nodeProperties == null) {
+ if (other.nodeProperties != null) {
return false;
- } else if (!tier.equals(other.tier))
+ }
+ } else if (!nodeProperties.equals(other.nodeProperties)) {
return false;
+ }
return true;
}
@Override
public String toString() {
- return ("SwitchConfig [Node=" + nodeId + ", Description=" + description +
- ", Tier=" + tier + ", Mode=" + mode + "]");
+ return ("SwitchConfig [Node=" + nodeId + ", Properties=" + nodeProperties + "]");
}
+
+ /**
+ * Implement clonable interface
+ */
+ @Override
+ public SwitchConfig clone() {
+ Map<String, Property> nodeProperties = (this.nodeProperties == null) ? null : new HashMap<String, Property>(
+ this.nodeProperties);
+ return new SwitchConfig(this.nodeId, nodeProperties);
+ }
+
}
import static org.junit.Assert.fail;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.ForwardingMode;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.Tier;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
public class SwitchTest {
@Test
public void testSwitchConfig(){
- SwitchConfig sc = new SwitchConfig(null, null, null, null);
- SwitchConfig sc2 = new SwitchConfig(null, null, null, null);
- Assert.assertTrue(sc.equals(sc2));
-
- Assert.assertNull(sc.getMode());
- Assert.assertNull(sc.getNodeId());
- Assert.assertNull(sc.getTier());
- Assert.assertNull(sc.getNodeDescription());
-
- SwitchConfig sc3 = new SwitchConfig("123", "name", "tier", "mode");
- SwitchConfig sc4 = new SwitchConfig("123", "name", "tier", "mode");
- Assert.assertFalse(sc.equals(sc3));
- Assert.assertTrue(sc3.equals(sc4));
-
- Assert.assertTrue(sc3.getNodeId().equals("123"));
- Assert.assertTrue(sc3.getNodeDescription().equals("name"));
- Assert.assertTrue(sc3.getTier().equals("tier"));
- Assert.assertTrue(sc3.getMode().equals("mode"));
+ Map<String, Property> prop = new HashMap<String, Property>();
+ Property desc = new Description("swicth1");
+ prop.put(desc.getName(), desc);
+ Property tier = new Tier(1);
+ prop.put(tier.getName(), tier);
+ SwitchConfig sc1 = new SwitchConfig("123", prop);
+ SwitchConfig sc2 = new SwitchConfig("123", prop);
+ Property mode = new ForwardingMode(1);
+ prop.put(mode.getName(), mode);
+ SwitchConfig sc3 = new SwitchConfig("123", prop);
+ Assert.assertTrue(sc1.equals(sc2));
+ Assert.assertEquals(tier, sc1.getProperty(Tier.TierPropName));
+ Assert.assertFalse(sc1.equals(sc3));
+ Assert.assertTrue(sc1.hashCode() == sc2.hashCode());
+ Assert.assertTrue(sc1.getNodeProperties().equals(sc2.getNodeProperties()));
}
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
import org.opendaylight.controller.sal.core.Config;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.ForwardingMode;
import org.opendaylight.controller.sal.core.MacAddress;
import org.opendaylight.controller.sal.core.Name;
import org.opendaylight.controller.sal.core.Node;
if (propMapCurr == null) {
return;
}
- Map<String, Property> propMap = new HashMap<String, Property>();
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
Property desc = new Description(cfgObject.getNodeDescription());
propMap.put(desc.getName(), desc);
Property tier = new Tier(Integer.parseInt(cfgObject.getTier()));
}
}
+ @Override
+ public Status updateNodeConfig(SwitchConfig switchConfig) {
+ Status status = switchConfig.validate();
+ if (!status.isSuccess()) {
+ return status;
+ }
+
+ Map<String, Property> updateProperties = switchConfig.getNodeProperties();
+ String nodeId = switchConfig.getNodeId();
+ ForwardingMode mode = (ForwardingMode) updateProperties.get(ForwardingMode.name);
+ if (mode != null) {
+ if (isDefaultContainer) {
+ if (!mode.isValid()) {
+ return new Status(StatusCode.NOTACCEPTABLE, "Invalid Forwarding Mode Value.");
+ }
+ } else {
+ return new Status(StatusCode.NOTACCEPTABLE,
+ "Forwarding Mode modification is allowed only in default container");
+ }
+ }
+ boolean modeChange = false;
+ SwitchConfig sc = nodeConfigList.get(nodeId);
+ Map<String, Property> prevNodeProperties = new HashMap<String, Property>();
+ if (sc == null) {
+ if ((mode != null) && mode.isProactive()) {
+ modeChange = true;
+ }
+ if (!updateProperties.isEmpty()) {
+ if (nodeConfigList.putIfAbsent(nodeId, switchConfig) != null) {
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration");
+ }
+ }
+ } else {
+ prevNodeProperties = new HashMap<String, Property>(sc.getNodeProperties());
+ ForwardingMode prevMode = (ForwardingMode) sc.getProperty(ForwardingMode.name);
+ if (mode == null) {
+ if ((prevMode != null) && (prevMode.isProactive())) {
+ modeChange = true;
+ }
+ } else {
+ if (((prevMode != null) && (prevMode.getValue() != mode.getValue()))
+ || (prevMode == null && mode.isProactive())) {
+ modeChange = true;
+ }
+ }
+ if (updateProperties.isEmpty()) {
+ nodeConfigList.remove(nodeId);
+ } else {
+ if (!nodeConfigList.replace(nodeId, sc, switchConfig)) {
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration");
+ }
+ }
+ }
+ Node node = Node.fromString(nodeId);
+ Map<String, Property> propMapCurr = nodeProps.get(node);
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
+ if (propMapCurr == null) {
+ return new Status(StatusCode.SUCCESS);
+ }
+ if (!prevNodeProperties.isEmpty()) {
+ for (String prop : prevNodeProperties.keySet()) {
+ if (!updateProperties.containsKey(prop)) {
+ if (prop.equals(Description.propertyName)) {
+ Map<Node, Map<String, Property>> nodeProp = this.inventoryService.getNodeProps();
+ if (nodeProp.get(node) != null) {
+ propMap.put(Description.propertyName, nodeProp.get(node).get(Description.propertyName));
+ continue;
+ }
+ }
+ propMap.remove(prop);
+ }
+ }
+ }
+ propMap.putAll(updateProperties);
+ if (!nodeProps.replace(node, propMapCurr, propMap)) {
+ // TODO rollback using Transactionality
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration.");
+ }
+ if (modeChange) {
+ notifyModeChange(node, (mode == null) ? false : mode.isProactive());
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
+ @Override
+ public Status removeNodeConfig(String nodeId) {
+ if ((nodeId == null) || (nodeId.isEmpty())) {
+ return new Status(StatusCode.BADREQUEST, "nodeId cannot be empty.");
+ }
+ Map<String, Property> nodeProperties = getSwitchConfig(nodeId).getNodeProperties();
+ Node node = Node.fromString(nodeId);
+ Map<String, Property> propMapCurr = nodeProps.get(node);
+ if ((propMapCurr != null) && (nodeProperties != null) && (!nodeProperties.isEmpty())) {
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
+ for (String prop : nodeProperties.keySet()) {
+ if (prop.equals(Description.propertyName)) {
+ Map<Node, Map<String, Property>> nodeProp = this.inventoryService.getNodeProps();
+ if (nodeProp.get(node) != null) {
+ propMap.put(Description.propertyName, nodeProp.get(node).get(Description.propertyName));
+ continue;
+ }
+ }
+ propMap.remove(prop);
+ }
+ if (!nodeProps.replace(node, propMapCurr, propMap)) {
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration.");
+ }
+ }
+ if (nodeConfigList != null) {
+ nodeConfigList.remove(nodeId);
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
@Override
public Status saveSwitchConfig() {
// Publish the save config event to the cluster nodes
}
Map<String, Property> propMapCurr = nodeProps.get(node);
- Map<String, Property> propMap = new HashMap<String, Property>();
- if (propMapCurr != null) {
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
- }
+ Map<String, Property> propMap = (propMapCurr == null) ? new HashMap<String, Property>()
+ : new HashMap<String, Property>(propMapCurr);
// copy node properties from plugin
if (props != null) {
boolean proactiveForwarding = false;
if (nodeConfigList != null) {
String nodeId = node.toString();
- for (SwitchConfig conf : nodeConfigList.values()) {
- if (conf.getNodeId().equals(nodeId)) {
- Property description = new Description(conf.getNodeDescription());
- propMap.put(description.getName(), description);
- Property tier = new Tier(Integer.parseInt(conf.getTier()));
- propMap.put(tier.getName(), tier);
- proactiveForwarding = conf.isProactive();
- break;
+ SwitchConfig conf = nodeConfigList.get(nodeId);
+ if (conf != null && (conf.getNodeProperties() != null)) {
+ Map<String, Property> nodeProperties = conf.getNodeProperties();
+ propMap.putAll(nodeProperties);
+ if (nodeProperties.get(ForwardingMode.name) != null) {
+ ForwardingMode mode = (ForwardingMode) nodeProperties.get(ForwardingMode.name);
+ proactiveForwarding = mode.isProactive();
}
}
}
}
if (!result) {
- log.debug(
- "Cluster conflict: Conflict while adding the node properties. Node: {} Properties: {}",
+ log.debug("Cluster conflict: Conflict while adding the node properties. Node: {} Properties: {}",
node.getID(), props);
addNodeProps(node, propMap);
}
}
Map<String, Property> propMapCurr = nodeProps.get(node);
- Map<String, Property> propMap = new HashMap<String, Property>();
- if (propMapCurr != null) {
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
- }
+ Map<String, Property> propMap = (propMapCurr == null) ? new HashMap<String, Property>()
+ : new HashMap<String, Property>(propMapCurr);
// copy node properties from plugin
for (Property prop : props) {
return;
}
- Map<String, Property> propMap = new HashMap<String, Property>();
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
-
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
propMap.put(prop.getName(), prop);
if (nodeProps.replace(node, propMapCurr, propMap)) {
if (!propMapCurr.containsKey(propName)) {
return new Status(StatusCode.SUCCESS);
}
- Map<String, Property> propMap = new HashMap<String, Property>();
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
-
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
propMap.remove(propName);
if (nodeProps.replace(node, propMapCurr, propMap)) {
return new Status(StatusCode.SUCCESS);
public Status addNodeConnectorProp(NodeConnector nodeConnector,
Property prop) {
Map<String, Property> propMapCurr = getNodeConnectorProps(nodeConnector);
- Map<String, Property> propMap = new HashMap<String, Property>();
-
- if (propMapCurr != null) {
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
- }
+ Map<String, Property> propMap = (propMapCurr == null) ? new HashMap<String, Property>()
+ : new HashMap<String, Property>(propMapCurr);
String msg = "Cluster conflict: Unable to add NodeConnector Property.";
// Just add the nodeConnector if prop is not available (in a non-default
return new Status(StatusCode.SUCCESS);
}
- Map<String, Property> propMap = new HashMap<String, Property>();
-
- for (String s : propMapCurr.keySet()) {
- propMap.put(s, propMapCurr.get(s).clone());
- }
-
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
propMap.remove(propName);
boolean result = nodeConnectorProps.replace(nodeConnector, propMapCurr, propMap);
String msg = "Cluster conflict: Unable to remove NodeConnector property.";
for (Node node : getNodes()) {
SwitchConfig sc = getSwitchConfig(node.toString());
if ((sc != null) && isDefaultContainer) {
- service.modeChangeNotify(node, sc.isProactive());
+ ForwardingMode mode = (ForwardingMode) sc.getProperty(ForwardingMode.name);
+ service.modeChangeNotify(node, (mode == null) ? false : mode.isProactive());
}
}
}
} else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) {
long bw = Long.parseLong(propValue);
return new Bandwidth(bw);
+ } else if (propName.equalsIgnoreCase(ForwardingMode.name)) {
+ int mode = Integer.parseInt(propValue);
+ return new ForwardingMode(mode);
} else {
log.debug("Not able to create {} property", propName);
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
org.opendaylight.controller.sal.core,
org.opendaylight.controller.sal.packet,
org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.switchmanager,
org.opendaylight.controller.containermanager,
org.slf4j,
org.eclipse.osgi.framework.console,
</plugins>
</build>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>containermanager</artifactId>
org.opendaylight.controller.sal.core,
org.opendaylight.controller.sal.packet,
org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.switchmanager,
org.opendaylight.controller.containermanager,
org.slf4j,
org.eclipse.osgi.framework.console,
<artifactId>usermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>containermanager</artifactId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.authorization.UserLevel;
import org.opendaylight.controller.sal.core.Config;
+import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.ForwardingMode;
import org.opendaylight.controller.sal.core.Name;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.State;
import org.opendaylight.controller.sal.core.Tier;
import org.opendaylight.controller.sal.utils.GlobalConstants;
String userName = request.getUserPrincipal().getName();
Privilege privilege = DaylightWebUtil.getContainerPrivilege(userName, containerName, this);
- ISwitchManager switchManager = (ISwitchManager) ServiceHelper
- .getInstance(ISwitchManager.class, containerName, this);
+ ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName,
+ this);
List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
if (switchManager != null && privilege != Privilege.NONE) {
for (Switch device : switchManager.getNetworkDevices()) {
HashMap<String, String> nodeDatum = new HashMap<String, String>();
Node node = device.getNode();
- Tier tier = (Tier) switchManager.getNodeProp(node,
- Tier.TierPropName);
-
+ Tier tier = (Tier) switchManager.getNodeProp(node, Tier.TierPropName);
nodeDatum.put("containerName", containerName);
- nodeDatum.put("nodeName",
- switchManager.getNodeDescription(node));
+ Description description = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ String desc = (description == null) ? "" : description.getValue();
+ nodeDatum.put("nodeName", desc);
nodeDatum.put("nodeId", node.toString());
- int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
- : tier.getValue();
- nodeDatum.put("tierName", TierHelper.getTierName(tierNumber)
- + " (Tier-" + tierNumber + ")");
+ int tierNumber = (tier == null) ? TierHelper.unknownTierNumber : tier.getValue();
+ nodeDatum.put("tierName", TierHelper.getTierName(tierNumber) + " (Tier-" + tierNumber + ")");
nodeDatum.put("tier", tierNumber + "");
- SwitchConfig sc = switchManager.getSwitchConfig(device
- .getNode().toString());
- String modeStr = (sc != null) ? sc.getMode() : "0";
+ String modeStr = "0";
+ ForwardingMode mode = (ForwardingMode) switchManager.getNodeProp(node, ForwardingMode.name);
+ if (mode != null) {
+ modeStr = String.valueOf(mode.getValue());
+ }
nodeDatum.put("mode", modeStr);
nodeDatum.put("json", gson.toJson(nodeDatum));
- nodeDatum.put("mac", HexEncode.bytesToHexString(device
- .getDataLayerAddress()));
+ nodeDatum.put("mac", HexEncode.bytesToHexString(device.getDataLayerAddress()));
StringBuffer sb1 = new StringBuffer();
- Set<NodeConnector> nodeConnectorSet = device
- .getNodeConnectors();
+ Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
Map<Short, String> portList = new HashMap<Short, String>();
List<String> intfList = new ArrayList<String>();
for (NodeConnector nodeConnector : nodeConnectorSet) {
- String nodeConnectorNumberToStr = nodeConnector.getID()
- .toString();
- Name ncName = ((Name) switchManager
- .getNodeConnectorProp(nodeConnector,
- Name.NamePropName));
+ String nodeConnectorNumberToStr = nodeConnector.getID().toString();
+ Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, Name.NamePropName));
Config portStatus = ((Config) switchManager
.getNodeConnectorProp(nodeConnector,
Config.ConfigPropName));
try {
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
- SwitchConfig cfg = new SwitchConfig(nodeId, nodeName, tier,
- operationMode);
- switchManager.updateSwitchConfig(cfg);
- resultBean.setStatus(true);
- resultBean.setMessage("Updated node information successfully");
+ Map<String, Property> nodeProperties = new HashMap<String, Property>();
+ Property desc = new Description(nodeName);
+ nodeProperties.put(desc.getName(), desc);
+ Property nodeTier = new Tier(Integer.parseInt(tier));
+ nodeProperties.put(nodeTier.getName(), nodeTier);
+ Property mode = new ForwardingMode(Integer.parseInt(operationMode));
+ nodeProperties.put(mode.getName(), mode);
+ SwitchConfig cfg = new SwitchConfig(nodeId, nodeProperties);
+ Status result = switchManager.updateNodeConfig(cfg);
+ if (!result.isSuccess()) {
+ resultBean.setStatus(false);
+ resultBean.setMessage(result.getDescription());
+ } else {
+ resultBean.setStatus(true);
+ resultBean.setMessage("Updated node information successfully");
+ }
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage("Error updating node information. "
.getInstance(ISwitchManager.class, containerName, this);
String description = "";
if (switchManager != null) {
- description = switchManager.getNodeDescription(Node
- .fromString(nodeId));
+ Description desc = (Description) switchManager.getNodeProp(Node.fromString(nodeId), Description.propertyName);
+ if(desc != null) {
+ description = desc.getValue();
+ }
}
return (description.isEmpty() || description.equalsIgnoreCase("none")) ? nodeId
: description;
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.authorization.UserLevel;
+import org.opendaylight.controller.sal.core.Description;
import org.opendaylight.controller.sal.core.Name;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
entry.put("flow", flowConfig);
entry.put("name", flowConfig.getName());
Node node = flowConfig.getNode();
- String description = switchManager.getNodeDescription(node);
- entry.put("node", (description.isEmpty() || description
- .equalsIgnoreCase("none")) ? node.toString() : description);
+ entry.put("node", getNodeDesc(node, switchManager));
entry.put("nodeId", node.toString());
flowSet.add(entry);
}
entry.put("ports", port);
// add name
- String description = switchManager.getNodeDescription(node
- .getNode());
- entry.put("name", (description.isEmpty() || description
- .equalsIgnoreCase("none")) ? node.getNode().toString()
- : description);
+ entry.put("name", getNodeDesc(node.getNode(), switchManager));
// add to the node
nodes.put(node.getNode().toString(), entry);
String nodeDesc = node.toString();
SwitchConfig config = switchManager.getSwitchConfig(node
.toString());
- if (config != null) {
- nodeDesc = config.getNodeDescription();
+ if ((config != null) && (config.getProperty(Description.propertyName) != null)) {
+ nodeDesc = ((Description) config.getProperty(Description.propertyName)).getValue();
}
nodes.put(nodeDesc, flows.size());
return (result.isSuccess()) ? StatusCode.SUCCESS.toString() : result
.getDescription();
}
+
+ private String getNodeDesc(Node node, ISwitchManager switchManager) {
+ Description desc = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ String description = (desc == null) ? "" : desc.getValue();
+ return (description.isEmpty() || description.equalsIgnoreCase("none")) ? node.toString() : description;
+ }
+
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.opendaylight.controller.configuration.IConfigurationAware;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.core.Bandwidth;
+import org.opendaylight.controller.sal.core.Description;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Host;
import org.opendaylight.controller.sal.core.Name;
for (Map.Entry<Node, Set<Edge>> e : nodeEdges.entrySet()) {
Node n = e.getKey();
- String description = switchManager.getNodeDescription(n);
+ String description = getNodeDesc(n, switchManager);
+
NodeBean node = createNodeBean(description, n);
// skip production node
private String getNodeConnectorDescription(NodeConnector nodeConnector, ISwitchManager switchManager) {
Node node = nodeConnector.getNode();
- String description = switchManager.getNodeDescription(node);
- String name = this.getDescription(description, node);
+ String name = this.getDescription(getNodeDesc(node, switchManager), node);
return name;
}
continue;
}
- String description = switchManager.getNodeDescription(n);
+ String description = getNodeDesc(n, switchManager);
if ((stagedNodes.containsKey(n.toString()) && metaCache.get(containerName).containsKey(n.toString())) || newNodes.containsKey(n.toString())) {
continue;
// Perform the class deserialization locally, from inside the package where the class is defined
return ois.readObject();
}
+
+ private String getNodeDesc(Node node, ISwitchManager switchManager) {
+ Description desc = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ return (desc == null) ? "" : desc.getValue();
+ }
+
}
\ No newline at end of file
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.opendaylight.controller.sal.action.SetVlanId;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.authorization.UserLevel;
+import org.opendaylight.controller.sal.core.Description;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.TimeStamp;
if (nodeSet != null) {
for (Node node : nodeSet) {
Map<String, String> device = new HashMap<String, String>();
- device.put("nodeName", switchManager.getNodeDescription(node));
+ device.put("nodeName", getNodeDesc(node, switchManager));
device.put("nodeId", node.toString());
lines.add(device);
}
if (nodeSet != null) {
for (Node node : nodeSet) {
Map<String, String> device = new HashMap<String, String>();
- device.put("nodeName", switchManager.getNodeDescription(node));
+ device.put("nodeName", getNodeDesc(node, switchManager));
device.put("nodeId", node.toString());
TimeStamp timeStamp = (TimeStamp) switchManager.getNodeProp(
node, TimeStamp.TimeStampPropName);
Match match = flow.getMatch();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
- String desc = (switchManager == null)?
- "" : switchManager.getNodeDescription(node);
- desc = (desc.isEmpty() || desc.equalsIgnoreCase("none"))?
- node.toString(): desc;
+ String desc = getNodeDesc(node, switchManager);
+ desc = (desc == null || desc.isEmpty() || desc.equalsIgnoreCase("none"))?
+ node.toString() : desc;
row.put("nodeName", desc);
if (match.isPresent(MatchType.IN_PORT)) {
row.put(MatchType.IN_PORT.id(), ((NodeConnector) flow.getMatch()
return row;
}
+ private String getNodeDesc(Node node, ISwitchManager switchManager) {
+ if (switchManager == null) {
+ return null;
+ }
+ Description desc = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ return (desc == null) ? "" : desc.getValue();
+ }
}