VOL-1166 VOL-1167 Openolt - Check reachability before sending flows or OMCI
Change-Id: I3eb8ffc3239fb3e21801c45d9bb81ecdf7b8d391
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 25beae4..366b900 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -661,7 +661,9 @@
onu_id=omci_indication.onu_id)
onu_device = self.adapter_agent.get_child_device(
- self.device_id, onu_id=omci_indication.onu_id)
+ self.device_id, onu_id=omci_indication.onu_id,
+ parent_port_no=platform.intf_id_to_port_no(
+ omci_indication.intf_id, Port.PON_OLT),)
self.adapter_agent.receive_proxied_message(onu_device.proxy_address,
omci_indication.pkt)
@@ -737,6 +739,16 @@
port_type=egress_port_type)
def send_proxied_message(self, proxy_address, msg):
+ onu_device = self.adapter_agent.get_child_device(self.device_id,
+ onu_id=proxy_address.onu_id,
+ parent_port_no=platform.intf_id_to_port_no(
+ proxy_address.channel_id, Port.PON_OLT))
+ if onu_device.connect_status != ConnectStatus.REACHABLE:
+ self.log.debug('ONU is not reachable, cannot send OMCI',
+ serial_number=onu_device.serial_number,
+ intf_id=onu_device.proxy_address.channel_id,
+ onu_id=onu_device.proxy_address.onu_id)
+ return
omci = openolt_pb2.OmciMsg(intf_id=proxy_address.channel_id,
onu_id=proxy_address.onu_id, pkt=str(msg))
self.stub.OmciMsgOut(omci)
@@ -878,6 +890,12 @@
def update_logical_flows(self, flows_to_add, flows_to_remove,
device_rules_map):
+ if not self.is_state_up():
+ self.log.info('The OLT is not up, we cannot update flows',
+ flows_to_add=[f.id for f in flows_to_add],
+ flows_to_remove=[f.id for f in flows_to_remove])
+ return
+
self.log.debug('logical flows update', flows_to_add=flows_to_add,
flows_to_remove=flows_to_remove)
diff --git a/voltha/adapters/openolt/openolt_flow_mgr.py b/voltha/adapters/openolt/openolt_flow_mgr.py
index e72c929..54d77e9 100644
--- a/voltha/adapters/openolt/openolt_flow_mgr.py
+++ b/voltha/adapters/openolt/openolt_flow_mgr.py
@@ -15,6 +15,7 @@
#
import copy
from twisted.internet import reactor
+import grpc
from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, \
ofp_flow_stats, ofp_match, OFPMT_OXM, Flows, FlowGroups, OFPXMT_OFB_IN_PORT
@@ -176,7 +177,15 @@
for f in device_flows_to_remove:
(id, direction) = self.decode_stored_id(f.id)
flow_to_remove = openolt_pb2.Flow(flow_id=id, flow_type=direction)
- self.stub.FlowRemove(flow_to_remove)
+ try:
+ self.stub.FlowRemove(flow_to_remove)
+ except grpc.RpcError as grpc_e:
+ if grpc_e.code() == grpc.StatusCode.NOT_FOUND:
+ self.log.debug('This flow does not exist on the switch, '
+ 'normal after an OLT reboot', flow=flow_to_remove)
+ else:
+ raise grpc_e
+
self.log.debug('flow removed from device', flow=f,
flow_key=flow_to_remove)