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;
* 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 {
+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"
+ : System.getProperty("container.profile");
+ private static final String ADMIN_SUFFIX = "Admin";
+ private static final String OPERATOR_SUFFIX = "Operator";
@XmlElement
private String 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");
}
}
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);
+ }
}