mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),\r
mavenBundle("org.opendaylight.controller",\r
"sal.implementation").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),\r
mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),\r
mavenBundle("org.opendaylight.controller",\r
"containermanager.it.implementation").versionAsInProject(),\r
assertNotNull(bc);\r
boolean debugit = false;\r
Bundle b[] = bc.getBundles();\r
- for (int i = 0; i < b.length; i++) {\r
- int state = b[i].getState();\r
+ for (Bundle element : b) {\r
+ int state = element.getState();\r
if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {\r
- log.debug("Bundle:" + b[i].getSymbolicName() + " state:"\r
+ log.debug("Bundle:" + element.getSymbolicName() + " state:"\r
+ stateToString(state));\r
debugit = true;\r
}\r
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.configuration;
+
+import java.io.Serializable;
+
+public abstract class ConfigurationObject implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static final String DEFAULT_REGEX = "^[\\w-\\+\\*\\/\\.\\(\\)\\[\\]\\@]{1,256}$";
+ private static final String REGEX_PROP_NAME = "resourceNameRegularExpression";
+ private static String regex;
+
+ static {
+ String customRegex = System.getProperty(REGEX_PROP_NAME);
+ regex = (customRegex != null) ? customRegex : DEFAULT_REGEX;
+ }
+
+ /**
+ * Checks if the provided resource name matches the controller resource name
+ * regular expression
+ *
+ * @param name
+ * The resource name to test
+ * @return true if the resource name is not null and matches the controller
+ * resource name regular expression, false otherwise
+ */
+ protected boolean isValidResourceName(String name) {
+ return (name != null) ? name.matches(regex) : false;
+ }
+
+ /**
+ * Return the regular expression currently in use for testing the controller
+ * resource names
+ *
+ * @return The regular expression
+ */
+ public static String getRegularExpression() {
+ return regex;
+ }
+}
<configuration>
<instructions>
<Import-Package>
+ org.opendaylight.controller.configuration,
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.sal.utils,
org.opendaylight.controller.sal.core,
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ </dependency>
</dependencies>
</project>
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.sal.core.ContainerFlow;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.match.Match;
*/
@XmlRootElement(name = "containerConfig")
@XmlAccessorType(XmlAccessType.NONE)
-public class ContainerConfig implements Serializable {
+public class ContainerConfig extends ConfigurationObject implements Serializable {
private static final long serialVersionUID = 2L;
private static final String regexName = "^\\w+$";
private static final String containerProfile = System.getProperty("container.profile") == null ? "Container"
*/
private Status validateName() {
// No Container configuration allowed to container default
- return ((container != null) && container.matches(regexName) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ?
+ return (isValidResourceName(container) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ?
new Status(StatusCode.SUCCESS) : new Status(StatusCode.BADREQUEST, "Invalid container name");
}
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.sal.match.Match;
import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.controller.sal.packet.BitBufferHelper;
*/
@XmlRootElement (name = "flow-spec-config")
@XmlAccessorType(XmlAccessType.NONE)
-public class ContainerFlowConfig implements Serializable {
+public class ContainerFlowConfig extends ConfigurationObject implements Serializable {
private static Logger log = LoggerFactory.getLogger(ContainerFlowConfig.class);
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** The Constant regexName. */
- private static final String regexName = "^[\\w-+.@]+$";
-
/** Flow Spec name. */
@XmlElement
private String name;
* @return true, if is valid
*/
public Status validate() {
- if (!hasValidName()) {
+ if (!isValidResourceName(name)) {
return new Status(StatusCode.BADREQUEST, "Invalid name");
}
Status status = validateVlan();
return new Status(StatusCode.SUCCESS);
}
- /**
- * Checks if this flow specification configuration has a valid name.
- *
- * @return true, if successful
- */
- private boolean hasValidName() {
- return (name != null && !name.isEmpty() && name.matches(regexName));
- }
-
/**
* Validates the vlan number
*
import java.util.List;
import java.util.Map;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.sal.utils.GUIField;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
/**
* This class defines all the necessary configuration information for a static route.
*/
-public class StaticRouteConfig implements Serializable {
+public class StaticRouteConfig extends ConfigurationObject implements Serializable {
private static final long serialVersionUID = 1L;
private static final String regexSubnet = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+ "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
* @return SUCCESS if the config is valid
*/
public Status isValid() {
- if ((name == null) || (name.trim().length() < 1)) {
+ if (!isValidResourceName(name)) {
return new Status(StatusCode.BADREQUEST,
"Invalid Static Route name");
}
if (getNextHopType().equalsIgnoreCase(
StaticRoute.NextHopType.SWITCHPORT.toString())) {
String pieces[] = nextHop.split("/");
- if (pieces.length < 2)
+ if (pieces.length < 2) {
return false;
+ }
return isValidSwitchId(pieces[0]);
}
return false;
}
StaticRouteConfig other = (StaticRouteConfig) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
if (nextHop == null) {
- if (other.nextHop != null)
+ if (other.nextHop != null) {
return false;
- } else if (!nextHop.equals(other.nextHop))
+ }
+ } else if (!nextHop.equals(other.nextHop)) {
return false;
+ }
if (staticRoute == null) {
- if (other.staticRoute != null)
+ if (other.staticRoute != null) {
return false;
- } else if (!staticRoute.equals(other.staticRoute))
+ }
+ } else if (!staticRoute.equals(other.staticRoute)) {
return false;
+ }
return true;
}
package org.opendaylight.controller.forwardingrulesmanager;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.sal.action.Action;
import org.opendaylight.controller.sal.action.ActionType;
import org.opendaylight.controller.sal.action.Controller;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class FlowConfig implements Serializable {
+public class FlowConfig extends ConfigurationObject implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(FlowConfig.class);
- private static final String NAMEREGEX = "^[a-zA-Z0-9]+$";
public static final String STATICFLOWGROUP = "__StaticFlows__";
public static final String INTERNALSTATICFLOWGROUP = "__InternalStaticFlows__";
public static final String INTERNALSTATICFLOWBEGIN = "__";
Switch sw = null;
try {
- if (name == null || name.trim().isEmpty() || !name.matches(FlowConfig.NAMEREGEX)) {
+ // Flow name cannot be internal flow signature
+ if (!isValidResourceName(name) || isInternalFlow()) {
return new Status(StatusCode.BADREQUEST, "Invalid name");
}
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.packet.BitBufferHelper;
import org.opendaylight.controller.sal.utils.GUIField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class SubnetConfig implements Cloneable, Serializable {
+public class SubnetConfig extends ConfigurationObject implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
private static final String prettyFields[] = { GUIField.NAME.toString(), GUIField.GATEWAYIP.toString(),
GUIField.NODEPORTS.toString() };
}
private Status validateName() {
- if (name == null || name.trim().isEmpty()) {
+ if (!isValidResourceName(name)) {
return new Status(StatusCode.BADREQUEST, "Invalid name");
}
return new Status(StatusCode.SUCCESS);