X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fcontainermanager%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcontainermanager%2Finternal%2FContainerManager.java;h=d9e941ef784348eaf0254691c9cee464cea371da;hp=c2610732350fdb027bf7fc8458343081c3db05fa;hb=b29204146ca6957b5f968e07d9e7e2052ba70ef1;hpb=95aaa263a3331dcb0b9268f9df9993b507ea40ad diff --git a/opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java b/opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java index c261073235..d9e941ef78 100644 --- a/opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java +++ b/opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java @@ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; +import org.opendaylight.controller.appauth.authorization.Authorization; import org.opendaylight.controller.clustering.services.CacheConfigException; import org.opendaylight.controller.clustering.services.CacheExistException; import org.opendaylight.controller.clustering.services.ICacheUpdateAware; @@ -37,8 +38,14 @@ import org.opendaylight.controller.clustering.services.IClusterGlobalServices; import org.opendaylight.controller.clustering.services.IClusterServices; import org.opendaylight.controller.configuration.IConfigurationAware; import org.opendaylight.controller.configuration.IConfigurationService; +import org.opendaylight.controller.containermanager.ContainerChangeEvent; +import org.opendaylight.controller.containermanager.ContainerConfig; +import org.opendaylight.controller.containermanager.ContainerData; +import org.opendaylight.controller.containermanager.ContainerFlowChangeEvent; +import org.opendaylight.controller.containermanager.ContainerFlowConfig; import org.opendaylight.controller.containermanager.IContainerAuthorization; import org.opendaylight.controller.containermanager.IContainerManager; +import org.opendaylight.controller.containermanager.NodeConnectorsChangeEvent; import org.opendaylight.controller.sal.authorization.AppRoleLevel; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.authorization.Resource; @@ -65,14 +72,6 @@ import org.opendaylight.controller.topologymanager.ITopologyManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.opendaylight.controller.appauth.authorization.Authorization; -import org.opendaylight.controller.containermanager.ContainerFlowChangeEvent; -import org.opendaylight.controller.containermanager.ContainerFlowConfig; -import org.opendaylight.controller.containermanager.NodeConnectorsChangeEvent; -import org.opendaylight.controller.containermanager.ContainerChangeEvent; -import org.opendaylight.controller.containermanager.ContainerConfig; -import org.opendaylight.controller.containermanager.ContainerData; - public class ContainerManager extends Authorization implements IContainerManager, IObjectReader, CommandProvider, ICacheUpdateAware, IContainerInternal, IContainerAuthorization, IConfigurationAware { @@ -621,9 +620,9 @@ public class ContainerManager extends Authorization implements IContaine String msg = null; ContainerData other = containerData.get(otherContainerName); if (flowSpecList.isEmpty()) { - msg = String.format("Port %s is shared and flow spec is emtpy for this container", port); + msg = String.format("Port %s is shared and flow spec is empty for this container", port); } else if (other.isFlowSpecEmpty()) { - msg = String.format("Port %s is shared and flow spec is emtpy for the other container", port); + msg = String.format("Port %s is shared and flow spec is empty for the other container", port); } else if (!checkCommonContainerFlow(flowSpecList, other.getContainerFlowSpecs()).isSuccess()) { msg = String.format("Port %s is shared and other container has common flow spec", port); } @@ -734,7 +733,7 @@ public class ContainerManager extends Authorization implements IContaine * Read containers, container flows and finally containers' entries from file * and program the database accordingly */ - if (containerConfigs.isEmpty()) { + if ((clusterServices != null) && (clusterServices.amICoordinator())) { loadContainerConfig(); } } @@ -761,7 +760,7 @@ public class ContainerManager extends Authorization implements IContaine File directory = new File(startupLocation); String[] fileList = directory.list(); - logger.trace("Deleteing startup configuration files for container {}", containerName); + logger.trace("Deleting startup configuration files for container {}", containerName); if (fileList != null) { for (String fileName : fileList) { if (fileName.contains(containerPrint)) { @@ -826,15 +825,12 @@ public class ContainerManager extends Authorization implements IContaine * @param containerName * @param delete */ - private void updateResourceGroups(String containerName, boolean delete) { - String containerProfile = System.getProperty("container.profile"); - if (containerProfile == null) { - containerProfile = "Container"; - } + private void updateResourceGroups(ContainerConfig containerConf, boolean delete) { // Container Roles and Container Resource Group - String groupName = containerProfile+"-" + containerName; - String containerAdminRole = containerProfile+"-" + containerName + "-Admin"; - String containerOperatorRole = containerProfile+"-" + containerName + "-Operator"; + String containerName = containerConf.getContainer(); + String groupName = containerConf.getContainerGroupName(); + String containerAdminRole = containerConf.getContainerAdminRole(); + String containerOperatorRole = containerConf.getContainerOperatorRole(); Set allContainerSet = resourceGroups.get(allResourcesGroupName); if (delete) { resourceGroups.remove(groupName); @@ -932,7 +928,7 @@ public class ContainerManager extends Authorization implements IContaine private Status addRemoveContainerEntries(String containerName, List nodeConnectorsString, boolean delete) { // Construct action message - String action = String.format("Node conenctor(s) %s container %s: %s", delete ? "removal from" : "addition to", + String action = String.format("Node connector(s) %s container %s: %s", delete ? "removal from" : "addition to", containerName, nodeConnectorsString); // Validity Check @@ -1019,6 +1015,19 @@ public class ContainerManager extends Authorization implements IContaine notifyContainerModeChange(delete, notifyLocal); // Notify listeners notifyContainerAwareListeners(container, delete); + + /* + * This is a quick fix until configuration service becomes the + * centralized configuration management place. Here container manager + * will remove the startup files for all the bundles that are present in + * the container being deleted. Do the cleanup here in Container manger + * as do not want to put this temporary code in Configuration manager + * yet which is ODL. + */ + if (delete) { + // TODO: remove when Config Mgr takes over + removeComponentsStartUpfiles(containerName); + } } private void notifyContainerEntryChangeInternal(String containerName, List ncList, UpdateType update, boolean notifyLocal) { @@ -1194,19 +1203,6 @@ public class ContainerManager extends Authorization implements IContaine return status; } - /* - * This is a quick fix until configuration service becomes the - * centralized configuration management place. Here container manager will - * remove the startup files for all the bundles that are present in the - * container being deleted. Do the cleanup here in Container manger as do not - * want to put this temporary code in Configuration manager yet which is - * ODL. - */ - if (delete) { - // TODO: remove when Config Mgr takes over - removeComponentsStartUpfiles(containerName); - } - /* * Update Configuration: This will trigger the notifications on cache * update callback locally and on the other cluster nodes @@ -1218,7 +1214,7 @@ public class ContainerManager extends Authorization implements IContaine } // Automatically create and populate user and resource groups - updateResourceGroups(containerName, delete); + updateResourceGroups(containerConf, delete); // Notify global and local listeners UpdateType update = (delete) ? UpdateType.REMOVED : UpdateType.ADDED;