[CORD-313] Handles uncaught exceptions when device is not configured
Includes following minor changes
- Move DeviceConfiguration and DeviceProperties to config package
- Create DeviceConfigNotFoundException
Change-Id: I32455d88c712bb65cd7f71dab9472ae003303de2
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java
index e47a662..5514207 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java
@@ -24,8 +24,11 @@
import java.util.Iterator;
import java.util.List;
+import org.onlab.packet.MacAddress;
import org.onlab.packet.MplsLabel;
import org.onosproject.core.ApplicationId;
+import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
+import org.onosproject.segmentrouting.config.DeviceProperties;
import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.net.DeviceId;
@@ -105,11 +108,19 @@
PolicyGroupIdentifier(id,
Collections.singletonList(param),
Collections.singletonList(bucketId));
+ MacAddress neighborEthDst;
+ try {
+ neighborEthDst = deviceConfig.getDeviceMac(neighbor);
+ } catch (DeviceConfigNotFoundException e) {
+ log.warn(e.getMessage()
+ + " Skipping createPolicyGroupChain for this label.");
+ continue;
+ }
+
TrafficTreatment.Builder tBuilder =
DefaultTrafficTreatment.builder();
tBuilder.setOutput(sp)
- .setEthDst(deviceConfig.
- getDeviceMac(neighbor))
+ .setEthDst(neighborEthDst)
.setEthSrc(nodeMacAddr)
.pushMpls()
.setMpls(MplsLabel.mplsLabel(label));
@@ -168,14 +179,23 @@
if (fullyResolved) {
List<GroupBucket> outBuckets = new ArrayList<>();
- for (GroupBucketIdentifier bucketId:bucketIds) {
+ for (GroupBucketIdentifier bucketId : bucketIds) {
DeviceId neighbor = portDeviceMap.
get(bucketId.outPort());
+
+ MacAddress neighborEthDst;
+ try {
+ neighborEthDst = deviceConfig.getDeviceMac(neighbor);
+ } catch (DeviceConfigNotFoundException e) {
+ log.warn(e.getMessage()
+ + " Skipping createPolicyGroupChain for this bucketId.");
+ continue;
+ }
+
TrafficTreatment.Builder tBuilder =
DefaultTrafficTreatment.builder();
tBuilder.setOutput(bucketId.outPort())
- .setEthDst(deviceConfig.
- getDeviceMac(neighbor))
+ .setEthDst(neighborEthDst)
.setEthSrc(nodeMacAddr);
if (bucketId.label() != NeighborSet.NO_EDGE_LABEL) {
tBuilder.pushMpls()