dana-i2cat/opennaas — pull request #969 by isartcanyameres (2014-11-11 11:16:47+00:00)
Title: Fix/allow routes repeating networkelement

This patch allow using multiple times the same network element in a route.
Previously, routes having that particularity where not correctly allocated. Only one flow per network element was allocated, the latest one in the route.

The route is now allocated following the order its network connections are returned.
All network connections internal to a device are allocated, the rest is assumed to be provided by the mere fact a cable exists between the two devices.

Following you should find a diff (without spaces) for class AllocateCircuitAction where the patch is applied.

```java
@@ -72,11 +72,16 @@ public class AllocateCircuitAction extends Action {
List circuitImplementationsIds = new ArrayList();

try {
-	// create the NetworkElement - NetworkConnection map and iterate over it, allocating
-	Map networkConnectionsMap = CircuitTopologyHelper.networkElementNetworkConnectionMap(route, topology);

-	for (NetworkElement networkElement : networkConnectionsMap.keySet()) {
-	NetworkConnection networkConnection = networkConnectionsMap.get(networkElement);
+	for (NetworkConnection networkConnection : route.getNetworkConnections()) {
+	NetworkElement networkElement = CircuitTopologyHelper.getNetworkElementWithPorts(topology.getNetworkElements(),
+	networkConnection.getSource(), networkConnection.getDestination());
+
+	if (networkElement != null) {
+	// There is a network element having both ports in the network connection
+	// Must configure the network connection there
+	log.debug("Allocating network connection " + networkConnection.getName() + " in element " + networkElement.getId());
+
if (networkElement instanceof Domain) {
// domain Id must be the same than the Generic Network ID that represents
IResource domainResource = TopologyHelper.getResourceFromNetworkElementId(networkElement.getId(),
@@ -115,7 +120,12 @@ public class AllocateCircuitAction extends Action {
throw new ActionException("This generic network can only manage Domains and Switches. It contains " + networkElement.getClass()
.getSimpleName() + " with ID = " + networkElement.getId());
}
+
+	} else {
+	log.debug("Assuming there's nothing to configure for network connection " + networkConnection.getName());
+	}
}
+
```