X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fcontainermanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcontainermanager%2FContainerConfig.java;h=89bf424e67a4465c885c82b2ec3206d559709064;hb=9411770e514bb0c5a65f96dc9deb7a87a9ea86ad;hp=01715cc1bf1e98960266f1832460aec1b74942e2;hpb=56b0413f04a5bac58ce3448372c24d54736d7382;p=controller.git diff --git a/opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java b/opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java index 01715cc1bf..89bf424e67 100644 --- a/opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java +++ b/opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java @@ -223,7 +223,7 @@ public class ContainerConfig implements Serializable { */ private Status validateName() { // No Container configuration allowed to container default - return (container.matches(regexName) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ? + return ((container != null) && container.matches(regexName) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ? new Status(StatusCode.SUCCESS) : new Status(StatusCode.BADREQUEST, "Invalid container name"); } @@ -386,11 +386,38 @@ public class ContainerConfig implements Serializable { config.getName())); } } + } else { + // Check for conflicting names with existing cFlows + List conflicting = new ArrayList(existingNames); + conflicting.retainAll(proposedNames); + if (!conflicting.isEmpty()) { + return new Status(StatusCode.CONFLICT, + "Invalid Flow Spec configuration: flow spec name(s) conflict with existing flow specs: " + + conflicting.toString()); + } + + /* + * Check for conflicting flow spec match (we only check for strict + * equality). Remove this in case (*) is reintroduced + */ + if (this.containerFlows != null && !this.containerFlows.isEmpty()) { + Set existingMatches = new HashSet(); + for (ContainerFlowConfig existing : this.containerFlows) { + existingMatches.addAll(existing.getMatches()); + } + for (ContainerFlowConfig proposed : cFlowConfigs) { + if (existingMatches.removeAll(proposed.getMatches())) { + return new Status(StatusCode.CONFLICT, String.format( + "Invalid Flow Spec configuration: %s conflicts with existing flow spec", + proposed.getName())); + } + } + } } + /* * Revisit the following flow-spec confict validation later based on more testing. - */ - /* + * (*) if (!delete) { // Check for overlapping container flows in the request int size = cFlowConfigs.size();