Andrea Campanella
Committed by Gerrit Code Review

Logging information about device not being driver programmable instead of throwing exception

Change-Id: I1d64e83ca0cabc9378bcaf19badddbba584128f8
......@@ -22,6 +22,7 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.onosproject.core.ApplicationId;
import org.onosproject.mastership.MastershipService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.CompletedBatchOperation;
......@@ -154,11 +155,13 @@ class FlowRuleDriverProvider extends AbstractProvider implements FlowRuleProvide
}
private FlowRuleProgrammable getFlowRuleProgrammable(DeviceId deviceId) {
FlowRuleProgrammable programmable = deviceService.getDevice(deviceId).as(FlowRuleProgrammable.class);
if (programmable == null) {
Device device = deviceService.getDevice(deviceId);
if (device.is(FlowRuleProgrammable.class)) {
return device.as(FlowRuleProgrammable.class);
} else {
log.warn("Device {} is not flow rule programmable");
return null;
}
return programmable;
}
......
......@@ -16,6 +16,7 @@
package org.onosproject.net.group.impl;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.group.GroupOperations;
......@@ -60,10 +61,12 @@ public class GroupDriverProvider extends AbstractProvider implements GroupProvid
}
private GroupProgrammable getGroupProgrammable(DeviceId deviceId) {
GroupProgrammable programmable = deviceService.getDevice(deviceId).as(GroupProgrammable.class);
if (programmable == null) {
Device device = deviceService.getDevice(deviceId);
if (device.is(GroupProgrammable.class)) {
return device.as(GroupProgrammable.class);
} else {
log.warn("Device {} is not group programmable");
return null;
}
return programmable;
}
}
......
......@@ -16,6 +16,7 @@
package org.onosproject.net.packet.impl;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.packet.OutboundPacket;
......@@ -60,10 +61,12 @@ public class PacketDriverProvider extends AbstractProvider implements PacketProv
}
private PacketProgrammable getPacketProgrammable(DeviceId deviceId) {
PacketProgrammable programmable = deviceService.getDevice(deviceId).as(PacketProgrammable.class);
if (programmable == null) {
Device device = deviceService.getDevice(deviceId);
if (device.is(PacketProgrammable.class)) {
return device.as(PacketProgrammable.class);
} else {
log.warn("Device {} is not packet programmable");
return null;
}
return programmable;
}
}
......