summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/providers/ovsdb/device
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/providers/ovsdb/device')
-rw-r--r--framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
index 10e745e3..d573458e 100644
--- a/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
+++ b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.ChassisId;
+import org.onlab.packet.IpAddress;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
@@ -40,6 +41,7 @@ import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
import org.onosproject.ovsdb.controller.OvsdbController;
import org.onosproject.ovsdb.controller.OvsdbNodeId;
import org.onosproject.ovsdb.controller.OvsdbNodeListener;
@@ -87,8 +89,14 @@ public class OvsdbDeviceProvider extends AbstractProvider
@Override
public void triggerProbe(DeviceId deviceId) {
- // TODO: This will be implemented later.
log.info("Triggering probe on device {}", deviceId);
+ if (!isReachable(deviceId)) {
+ log.error("Failed to probe device {}", deviceId);
+ providerService.deviceDisconnected(deviceId);
+ return;
+ } else {
+ log.trace("Confirmed device {} connection", deviceId);
+ }
}
@Override
@@ -98,7 +106,8 @@ public class OvsdbDeviceProvider extends AbstractProvider
@Override
public boolean isReachable(DeviceId deviceId) {
- return true;
+ OvsdbClientService ovsdbClient = controller.getOvsdbClient(changeDeviceIdToNodeId(deviceId));
+ return !(ovsdbClient == null || !ovsdbClient.isConnected());
}
private class InnerOvsdbNodeListener implements OvsdbNodeListener {
@@ -131,4 +140,12 @@ public class OvsdbDeviceProvider extends AbstractProvider
}
}
+
+ private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
+ String[] strings = deviceId.toString().split(":");
+ if (strings.length < 1) {
+ return null;
+ }
+ return new OvsdbNodeId(IpAddress.valueOf(strings[1]), 0);
+ }
}