Fix for ONOS-251 - Can't create bandwidth constrained intents
The simple link resource store was not setting a default value
for the bandwidth on a link, so all requests for bandwidth
constrained paths were failing due to no available bandwidth.
Change-Id: Ibdeeae8ad22cfab443d694588d74fc2e910d72bf
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java
index 52f60af..a093fa5 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleLinkResourceStore.java
@@ -49,6 +49,7 @@
@Component(immediate = true)
@Service
public class SimpleLinkResourceStore implements LinkResourceStore {
+ private static final int DEFAULT_BANDWIDTH = 1_000;
private final Logger log = getLogger(getClass());
private Map<IntentId, LinkResourceAllocations> linkResourceAllocationsMap;
private Map<Link, Set<LinkResourceAllocations>> allocatedResources;
@@ -88,14 +89,14 @@
log.debug("No optical.wave annotation on link %s", link);
}
+ int bandwidth = DEFAULT_BANDWIDTH;
try {
- int bandwidth = Integer.parseInt(annotations.value(AnnotationKeys.BANDWIDTH));
- allocations.add(
- new BandwidthResourceAllocation(Bandwidth.valueOf(bandwidth)));
+ bandwidth = Integer.parseInt(annotations.value(AnnotationKeys.BANDWIDTH));
} catch (NumberFormatException e) {
log.debug("No bandwidth annotation on link %s", link);
}
-
+ allocations.add(
+ new BandwidthResourceAllocation(Bandwidth.valueOf(bandwidth)));
return allocations;
}