X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fcontainermanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcontainermanager%2FContainerConfig.java;h=99568dfcce886fb89de47fba5cc775b00a24530a;hp=89bf424e67a4465c885c82b2ec3206d559709064;hb=5c50c6fb1fa4bb426bd5f537d9e769613911b59d;hpb=9411770e514bb0c5a65f96dc9deb7a87a9ea86ad 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 89bf424e67..99568dfcce 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 @@ -35,11 +35,15 @@ import org.opendaylight.controller.sal.utils.StatusCode; * files through java serialization API when saving to/reading from Container * Manager startup configuration file. */ -@XmlRootElement(name = "container-config") +@XmlRootElement(name = "containerConfig") @XmlAccessorType(XmlAccessType.NONE) public class ContainerConfig 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" + : System.getProperty("container.profile"); + private static final String ADMIN_SUFFIX = "Admin"; + private static final String OPERATOR_SUFFIX = "Operator"; @XmlElement private String container; @@ -311,17 +315,6 @@ public class ContainerConfig implements Serializable { return status; } - /* Allow adding ports which are already present - if (!ports.isEmpty()) { - List intersection = new ArrayList(ports); - intersection.retainAll(ncList); - if (!intersection.isEmpty()) { - return new Status(StatusCode.CONFLICT, "The following node connectors are already part of this container: " - + intersection); - } - } - */ - // Add ports ports.addAll(ncList); return new Status(StatusCode.SUCCESS); @@ -415,36 +408,6 @@ public class ContainerConfig implements Serializable { } } - /* - * 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(); - for (int i = 0; i < size; i++) { - ContainerFlowConfig first = cFlowConfigs.get(i); - for (int j = i + 1; j < size; j++) { - ContainerFlowConfig second = cFlowConfigs.get(j); - if (first.overlap(second)) { - return new Status(StatusCode.BADREQUEST, String.format( - "Invalid Request: the proposed flow specs overlap: %s <-> %s", first.getName(), - second.getName())); - } - } - } - // Check if any of the proposed container flows overlap with the - // existing ones - for (ContainerFlowConfig current : cFlowConfigs) { - for (ContainerFlowConfig existing : this.containerFlows) { - if (current.overlap(existing)) { - return new Status(StatusCode.BADREQUEST, String.format( - "Invalid Request: the proposed flow specs overlap: %s <-> %s", current.getName(), - existing.getName())); - } - } - } - } - */ return new Status(StatusCode.SUCCESS); } @@ -652,4 +615,30 @@ public class ContainerConfig implements Serializable { } return list; } + + private String getContainerRole(boolean admin) { + return String.format("%s-%s-%s", containerProfile, container, (admin ? ADMIN_SUFFIX : OPERATOR_SUFFIX)); + } + + /** + * Return the well known administrator role for this container + * + * @return The administrator role for this container + */ + public String getContainerAdminRole() { + return getContainerRole(true); + } + + /** + * Return the well known operator role for this container + * + * @return The operator role for this container + */ + public String getContainerOperatorRole() { + return getContainerRole(false); + } + + public String getContainerGroupName() { + return String.format("%s-%s", containerProfile, container); + } }