Fixes for resource-related test CLI commands:

- Tweak to assumptions in base command for ConnectivityIntents
- Check before casting between port types

Change-Id: I5db84ec435029f2de84abb0f3f5ddc726035bf1b
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index 74ec8f7..af9a07e 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -24,6 +24,7 @@
 import org.onlab.util.PositionalParameterStringFormatter;
 import org.onosproject.net.Link;
 import org.onosproject.net.LinkKey;
+import org.onosproject.net.Port;
 import org.onosproject.net.intent.IntentId;
 import org.onosproject.net.link.LinkService;
 import org.onosproject.net.resource.link.BandwidthResource;
@@ -140,14 +141,15 @@
 
     private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) {
         Set<LambdaResourceAllocation> allocations = new HashSet<>();
+        Port port = deviceService.getPort(link.src().deviceId(), link.src().port());
+        if (port instanceof OmsPort) {
+            OmsPort omsPort = (OmsPort) port;
 
-        OmsPort port = (OmsPort) deviceService.getPort(link.src().deviceId(), link.src().port());
-
-        // Assume fixed grid for now
-        for (int i = 0; i < port.totalChannels(); i++) {
-            allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
+            // Assume fixed grid for now
+            for (int i = 0; i < omsPort.totalChannels(); i++) {
+                allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
+            }
         }
-
         return allocations;
     }