Committed by
Gerrit Code Review
Logging information about device not being driver programmable instead of throwing exception
Change-Id: I1d64e83ca0cabc9378bcaf19badddbba584128f8
Showing
3 changed files
with
18 additions
and
9 deletions
| ... | @@ -22,6 +22,7 @@ import com.google.common.collect.Multimap; | ... | @@ -22,6 +22,7 @@ import com.google.common.collect.Multimap; |
| 22 | import com.google.common.collect.Sets; | 22 | import com.google.common.collect.Sets; |
| 23 | import org.onosproject.core.ApplicationId; | 23 | import org.onosproject.core.ApplicationId; |
| 24 | import org.onosproject.mastership.MastershipService; | 24 | import org.onosproject.mastership.MastershipService; |
| 25 | +import org.onosproject.net.Device; | ||
| 25 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
| 26 | import org.onosproject.net.device.DeviceService; | 27 | import org.onosproject.net.device.DeviceService; |
| 27 | import org.onosproject.net.flow.CompletedBatchOperation; | 28 | import org.onosproject.net.flow.CompletedBatchOperation; |
| ... | @@ -154,11 +155,13 @@ class FlowRuleDriverProvider extends AbstractProvider implements FlowRuleProvide | ... | @@ -154,11 +155,13 @@ class FlowRuleDriverProvider extends AbstractProvider implements FlowRuleProvide |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | private FlowRuleProgrammable getFlowRuleProgrammable(DeviceId deviceId) { | 157 | private FlowRuleProgrammable getFlowRuleProgrammable(DeviceId deviceId) { |
| 157 | - FlowRuleProgrammable programmable = deviceService.getDevice(deviceId).as(FlowRuleProgrammable.class); | 158 | + Device device = deviceService.getDevice(deviceId); |
| 158 | - if (programmable == null) { | 159 | + if (device.is(FlowRuleProgrammable.class)) { |
| 160 | + return device.as(FlowRuleProgrammable.class); | ||
| 161 | + } else { | ||
| 159 | log.warn("Device {} is not flow rule programmable"); | 162 | log.warn("Device {} is not flow rule programmable"); |
| 163 | + return null; | ||
| 160 | } | 164 | } |
| 161 | - return programmable; | ||
| 162 | } | 165 | } |
| 163 | 166 | ||
| 164 | 167 | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.net.group.impl; | 17 | package org.onosproject.net.group.impl; |
| 18 | 18 | ||
| 19 | +import org.onosproject.net.Device; | ||
| 19 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.device.DeviceService; | 21 | import org.onosproject.net.device.DeviceService; |
| 21 | import org.onosproject.net.group.GroupOperations; | 22 | import org.onosproject.net.group.GroupOperations; |
| ... | @@ -60,10 +61,12 @@ public class GroupDriverProvider extends AbstractProvider implements GroupProvid | ... | @@ -60,10 +61,12 @@ public class GroupDriverProvider extends AbstractProvider implements GroupProvid |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | private GroupProgrammable getGroupProgrammable(DeviceId deviceId) { | 63 | private GroupProgrammable getGroupProgrammable(DeviceId deviceId) { |
| 63 | - GroupProgrammable programmable = deviceService.getDevice(deviceId).as(GroupProgrammable.class); | 64 | + Device device = deviceService.getDevice(deviceId); |
| 64 | - if (programmable == null) { | 65 | + if (device.is(GroupProgrammable.class)) { |
| 66 | + return device.as(GroupProgrammable.class); | ||
| 67 | + } else { | ||
| 65 | log.warn("Device {} is not group programmable"); | 68 | log.warn("Device {} is not group programmable"); |
| 69 | + return null; | ||
| 66 | } | 70 | } |
| 67 | - return programmable; | ||
| 68 | } | 71 | } |
| 69 | } | 72 | } | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.net.packet.impl; | 17 | package org.onosproject.net.packet.impl; |
| 18 | 18 | ||
| 19 | +import org.onosproject.net.Device; | ||
| 19 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.device.DeviceService; | 21 | import org.onosproject.net.device.DeviceService; |
| 21 | import org.onosproject.net.packet.OutboundPacket; | 22 | import org.onosproject.net.packet.OutboundPacket; |
| ... | @@ -60,10 +61,12 @@ public class PacketDriverProvider extends AbstractProvider implements PacketProv | ... | @@ -60,10 +61,12 @@ public class PacketDriverProvider extends AbstractProvider implements PacketProv |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | private PacketProgrammable getPacketProgrammable(DeviceId deviceId) { | 63 | private PacketProgrammable getPacketProgrammable(DeviceId deviceId) { |
| 63 | - PacketProgrammable programmable = deviceService.getDevice(deviceId).as(PacketProgrammable.class); | 64 | + Device device = deviceService.getDevice(deviceId); |
| 64 | - if (programmable == null) { | 65 | + if (device.is(PacketProgrammable.class)) { |
| 66 | + return device.as(PacketProgrammable.class); | ||
| 67 | + } else { | ||
| 65 | log.warn("Device {} is not packet programmable"); | 68 | log.warn("Device {} is not packet programmable"); |
| 69 | + return null; | ||
| 66 | } | 70 | } |
| 67 | - return programmable; | ||
| 68 | } | 71 | } |
| 69 | } | 72 | } | ... | ... |
-
Please register or login to post a comment