private void loadContainerConfig() { for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, CONTAINERS_FILE_NAME)) { addContainer((ContainerConfig) conf); } }
@Override public Status removeContainer(ContainerConfig containerConf) { return addRemoveContainer(containerConf, true); }
@Override public Status addContainerEntry(String containerName, List<String> nodeConnectors) { return addRemoveContainerEntries(containerName, nodeConnectors, false); }
public void start() { // Get caches from cluster manager allocateCaches(); retrieveCaches(); // Allocates default groups and association to default roles createDefaultAuthorizationGroups(); // Read startup configuration and create local database loadContainerConfig(); }
public List<String> addContainerFlow(String arg1, String arg2, String arg3) { List<String> result = new ArrayList<String>(); String containerName = arg1; if (containerName == null) { result.add("Container Name not specified"); return result; } String cflowName = arg2; if (cflowName == null) { result.add("cflowName not specified"); return result; } String unidirectional = arg3; boolean boolUnidirectional = Boolean.parseBoolean(unidirectional); List<ContainerFlowConfig> list = new ArrayList<ContainerFlowConfig>(); list.add(createSampleContainerFlowConfig(cflowName, boolUnidirectional)); result.add((this.addRemoveContainerFlow(containerName, list, false)).toString()); return result; }
public List<String> createContainer(String arg1, String arg2) { List<String> result = new ArrayList<String>(); String containerName = arg1; if (containerName == null) { result.add("Container Name not specified"); return result; } String staticVlan = arg2; if (staticVlan == null) { result.add("Static Vlan not specified"); return result; } List<String> ports = new ArrayList<String>(); for (long l = 1L; l < 10L; l++) { ports.add(NodeConnectorCreator.createOFNodeConnector((short) 1, NodeCreator.createOFNode(l)).toString()); } List<ContainerFlowConfig> cFlowList = new ArrayList<ContainerFlowConfig>(); cFlowList.add(this.createSampleContainerFlowConfig("tcp", true)); ContainerConfig containerConfig = new ContainerConfig(containerName, staticVlan, ports, cFlowList); result.add((this.addRemoveContainer(containerConfig, false)).toString()); return result; }
ContainerData container = this.getContainerByName(containerName); if (container == null) { String error = String.format("Cannot validate flow specs for container %s: (Container does not exist)", containerName); Status status = checkCommonContainerFlow(otherContainer.getContainerFlowSpecs(), proposed); if (!status.isSuccess()) { return new Status(StatusCode.BADREQUEST, String.format(
@Override public Status removeContainerFlows(String containerName, List<ContainerFlowConfig> fSpecConf) { return addRemoveContainerFlow(containerName, fSpecConf, true); }
public List<String> containermgrGetUserResources(String arg1) { List<String> result = new ArrayList<String>(); String userName = arg1; if (userName == null || userName.trim().isEmpty()) { result.add("Invalid argument"); result.add("containermgrGetUserResources <user_name>"); return result; } result.add("User " + userName + " owns the following resources: "); Set<Resource> resources = this.getAllResourcesforUser(userName); for (Resource resource : resources) { result.add(resource.toString()); } return result; } public List<String> saveConfig() {
public List<String> containermgrGetAuthorizedGroups(String arg1) { List<String> result = new ArrayList<String>(); String roleName = arg1; if (roleName == null || roleName.trim().isEmpty()) { result.add("Invalid argument"); result.add("mmGetAuthorizedGroups <role_name>"); return result; } result.add("Resource Groups associated to role " + roleName + ":"); List<ResourceGroup> list = this.getAuthorizedGroups(roleName); for (ResourceGroup group : list) { result.add(group.toString()); } return result; } public List<String> containermgrGetAuthorizedResources(String arg1) {
private Status validatePortSharingInternal(List<NodeConnector> portList, List<ContainerFlow> flowSpecList) { for (NodeConnector port : portList) { List<String> slist = nodeConnectorToContainers.get(port); if (slist != null && !slist.isEmpty()) { for (String otherContainerName : slist) { String msg = null; ContainerData other = containerData.get(otherContainerName); if (flowSpecList.isEmpty()) { 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 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); } if (msg != null) { logger.debug(msg); return new Status(StatusCode.BADREQUEST, msg); } } } } return new Status(StatusCode.SUCCESS); }
public void _addContainerFlow(CommandInterpreter ci) { String containerName = ci.nextArgument(); if (containerName == null) { ci.print("Container Name not specified"); return; } String cflowName = ci.nextArgument(); if (cflowName == null) { ci.print("cflowName not specified"); return; } String unidirectional = ci.nextArgument(); boolean boolUnidirectional = Boolean.parseBoolean(unidirectional); List<ContainerFlowConfig> list = new ArrayList<ContainerFlowConfig>(); list.add(createSampleContainerFlowConfig(cflowName, boolUnidirectional)); ci.println(this.addRemoveContainerFlow(containerName, list, false)); }
public void _createContainer(CommandInterpreter ci) { String containerName = ci.nextArgument(); if (containerName == null) { ci.print("Container Name not specified"); return; } String staticVlan = ci.nextArgument(); if (staticVlan == null) { ci.print("Static Vlan not specified"); return; } List<String> ports = new ArrayList<String>(); for (long l = 1L; l < 10L; l++) { ports.add(NodeConnectorCreator.createOFNodeConnector((short) 1, NodeCreator.createOFNode(l)).toString()); } List<ContainerFlowConfig> cFlowList = new ArrayList<ContainerFlowConfig>(); cFlowList.add(this.createSampleContainerFlowConfig("tcp", true)); ContainerConfig containerConfig = new ContainerConfig(containerName, staticVlan, ports, cFlowList); ci.println(this.addRemoveContainer(containerConfig, false)); }
@Override public Status addContainerFlows(String containerName, List<ContainerFlowConfig> fSpecConf) { return addRemoveContainerFlow(containerName, fSpecConf, false); }
public void _containermgrGetUserResources(CommandInterpreter ci) { String userName = ci.nextArgument(); if (userName == null || userName.trim().isEmpty()) { ci.println("Invalid argument"); ci.println("containermgrGetUserResources <user_name>"); return; } ci.println("User " + userName + " owns the following resources: "); Set<Resource> resources = this.getAllResourcesforUser(userName); for (Resource resource : resources) { ci.println(resource.toString()); } }
public void _containermgrGetAuthorizedGroups(CommandInterpreter ci) { String roleName = ci.nextArgument(); if (roleName == null || roleName.trim().isEmpty()) { ci.println("Invalid argument"); ci.println("mmGetAuthorizedGroups <role_name>"); return; } ci.println("Resource Groups associated to role " + roleName + ":"); List<ResourceGroup> list = this.getAuthorizedGroups(roleName); for (ResourceGroup group : list) { ci.println(group.toString()); } }
@Override public Status addContainer(ContainerConfig containerConf) { return addRemoveContainer(containerConf, false); }
@Override public Status removeContainerEntry(String containerName, List<String> nodeConnectors) { return addRemoveContainerEntries(containerName, nodeConnectors, true); }
@Override public Status removeContainerFlows(String containerName, Set<String> names) { // Construct action message String action = String.format("Flow spec(s) removal from container %s: %s", containerName, names); // Presence check ContainerConfig sc = containerConfigs.get(containerName); if (sc == null) { String msg = String.format("Container not found: %s", containerName); String error = String.format("Failed to apply %s: (%s)", action, msg); logger.warn(error); return new Status(StatusCode.NOTFOUND, msg); } List<ContainerFlowConfig> list = sc.getContainerFlowConfigs(names); if (list.isEmpty() || list.size() != names.size()) { String msg = String.format("Cannot find all the specified flow specs"); String error = String.format("Failed to apply %s: (%s)", action, msg); logger.warn(error); return new Status(StatusCode.BADREQUEST, msg); } return addRemoveContainerFlow(containerName, list, true); }
@Override public Status removeContainer(String containerName) { // Construct action message String action = String.format("Container removal: %s", containerName); ContainerConfig containerConf = containerConfigs.get(containerName); if (containerConf == null) { String msg = String.format("Container not found"); String error = String.format("Failed to apply %s: (%s)", action, msg); logger.warn(error); return new Status(StatusCode.NOTFOUND, msg); } return addRemoveContainer(containerConf, true); }