From: Alessandro Boch Date: Tue, 17 Sep 2013 20:06:49 +0000 (-0700) Subject: Add missing validation on ContainerFlowConfig objects X-Git-Tag: releasepom-0.1.0~71^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=35ad7fd59840898927b9a9c331b6a71f5808908c Add missing validation on ContainerFlowConfig objects - Some basic validation is missing when modifying the container flow configs in a container Change-Id: I4955a5a1ae9ef36a5564570bd5ae38801055c355 Signed-off-by: Alessandro Boch --- 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 a34746949e..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 @@ -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();