From 35ad7fd59840898927b9a9c331b6a71f5808908c Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Tue, 17 Sep 2013 13:06:49 -0700 Subject: [PATCH] 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 --- .../containermanager/ContainerConfig.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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(); -- 2.36.6