VOL-1190 Filter out unreachable device before reporting to ONOS
calling ListReachableLogicalDevices instead of ListLogicalDevices. The filtering is done in the voltha core
Change-Id: I517f963423b83c49bce1469ebb016af1eb72a4a9
diff --git a/ofagent/connection_mgr.py b/ofagent/connection_mgr.py
index 2496dd5..f90c9f7 100644
--- a/ofagent/connection_mgr.py
+++ b/ofagent/connection_mgr.py
@@ -201,14 +201,17 @@
log.debug('stop-monitor-vcore-grpc-channel')
@inlineCallbacks
- def get_list_of_logical_devices_from_voltha(self):
+ def get_list_of_reachable_logical_devices_from_voltha(self):
while self.running:
log.info('retrieve-logical-device-list')
try:
- devices = yield self.grpc_client.list_logical_devices()
+ devices = yield \
+ self.grpc_client.list_reachable_logical_devices()
+
for device in devices:
- log.info("logical-device-entry", id=device.id, datapath_id=device.datapath_id)
+ log.info("reachable-logical-device-entry", id=device.id,
+ datapath_id=device.datapath_id)
returnValue(devices)
@@ -292,10 +295,11 @@
if self.channel is not None and self.grpc_client is not None and \
self.subscription is not None:
# get current list from Voltha
- devices = yield self.get_list_of_logical_devices_from_voltha()
+ reachable_devices = yield \
+ self.get_list_of_reachable_logical_devices_from_voltha()
# update agent list and mapping tables as needed
- self.refresh_agent_connections(devices)
+ self.refresh_agent_connections(reachable_devices)
else:
log.info('vcore-communication-unavailable')
diff --git a/ofagent/grpc_client.py b/ofagent/grpc_client.py
index 56af949..ab9417b 100644
--- a/ofagent/grpc_client.py
+++ b/ofagent/grpc_client.py
@@ -241,6 +241,13 @@
returnValue(res.items)
@inlineCallbacks
+ def list_reachable_logical_devices(self):
+ res = yield threads.deferToThread(
+ self.local_stub.ListReachableLogicalDevices, empty_pb2.Empty(),
+ timeout=self.grpc_timeout)
+ returnValue(res.items)
+
+ @inlineCallbacks
def subscribe(self, subscriber):
res = yield threads.deferToThread(
self.local_stub.Subscribe, subscriber, timeout=self.grpc_timeout)