@Override public List<ContainerFlow> getContainerFlows() { List<ContainerFlow> list = new ArrayList<ContainerFlow>(); ContainerData d = this.iContainerInternal.getContainerData(this.containerName); if (d != null) { list.addAll(d.getContainerFlowSpecs()); } return list; }
public List<String> psd() { List<String> result = new ArrayList<String>(); for (String containerName : containerData.keySet()) { ContainerData sd = containerData.get(containerName); for (Node sid : sd.getSwPorts().keySet()) { Set<NodeConnector> s = sd.getSwPorts().get(sid); result.add("\t" + sid + " : " + s); } for (ContainerFlow s : sd.getContainerFlowSpecs()) { result.add("\t" + s.toString()); } } return result; }
void setIContainerListener(IContainerListener s) { if (this.iContainerListener != null) { this.iContainerListener.add(s); /* * At boot with startup, containers are created before listeners have * joined. Replaying here the first container creation notification for * the joining listener when containers are already present. Also * replaying all the node connectors and container flows additions * to the existing containers. */ if (!this.containerData.isEmpty()) { s.containerModeUpdated(UpdateType.ADDED); } for (ConcurrentMap.Entry<NodeConnector, CopyOnWriteArrayList<String>> entry : nodeConnectorToContainers .entrySet()) { NodeConnector port = entry.getKey(); for (String container : entry.getValue()) { s.nodeConnectorUpdated(container, port, UpdateType.ADDED); } } for (Map.Entry<String, ContainerData> container : containerData.entrySet()) { for (ContainerFlow cFlow : container.getValue().getContainerFlowSpecs()) { s.containerFlowUpdated(container.getKey(), cFlow, cFlow, UpdateType.ADDED); } } } }
public void _psd(CommandInterpreter ci) { for (String containerName : containerData.keySet()) { ContainerData sd = containerData.get(containerName); for (Node sid : sd.getSwPorts().keySet()) { Set<NodeConnector> s = sd.getSwPorts().get(sid); ci.println("\t" + sid + " : " + s); } for (ContainerFlow s : sd.getContainerFlowSpecs()) { ci.println("\t" + s.toString()); } } }
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); }
/** * Checks if the passed list of node connectors can be safely applied to the * specified existing container in terms of port sharing with other containers. * * @param containerName * the name of the existing container * @param portList * the list of node connectors to be added to the container * @return the status object representing the result of the check */ private Status validatePortSharing(String containerName, List<NodeConnector> portList) { ContainerData container = this.getContainerByName(containerName); if (container == null) { String error = String .format("Cannot validate port sharing for container %s: (container does not exist)", containerName); logger.error(error); return new Status(StatusCode.BADREQUEST, error); } return validatePortSharingInternal(portList, container.getContainerFlowSpecs()); }
List<ContainerFlow> proposed = new ArrayList<ContainerFlow>(container.getContainerFlowSpecs()); proposed.add(cFlow); for (Map.Entry<String, ContainerData> entry : containerData.entrySet()) { Status status = checkCommonContainerFlow(otherContainer.getContainerFlowSpecs(), proposed); if (!status.isSuccess()) { return new Status(StatusCode.BADREQUEST, String.format(