VOL-4053: Fix Reenable of OLT following disable OLT and adapter restart.
- If the PON port is already disabled (could happen if a duplicate
disable command arrives at OLT), return success
- Add unit test cases
Change-Id: I7e35ff81eb80d47743ab94e35655306fc313884d
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index a987540..a4e902f 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -427,6 +427,7 @@
Status status;
int failedCount = 0;
+ OPENOLT_LOG(INFO, openolt_log_id, "Received disable OLT\n");
for (int i = 0; i < NumPonIf_(); i++) {
status = DisablePonIf_(i);
if (!status.ok()) {
@@ -1057,6 +1058,19 @@
bcmolt_pon_interface_set_pon_interface_state pon_interface_set_state;
BCMOLT_CFG_INIT(&interface_obj, pon_interface, intf_key);
+ BCMOLT_MSG_FIELD_GET(&interface_obj, state);
+
+ err = bcmolt_cfg_get(dev_id, &interface_obj.hdr);
+ if (err != BCM_ERR_OK) {
+ OPENOLT_LOG(ERROR, openolt_log_id, "Failed to fetch pon port status, PON interface %d, err %d err_text=%s \n", intf_id, err, interface_obj.hdr.hdr.err_text);
+ return bcm_to_grpc_err(err, "Failed to fetch pon port state");
+ }
+ if (interface_obj.data.state == BCMOLT_INTERFACE_STATE_INACTIVE) {
+ OPENOLT_LOG(INFO, openolt_log_id, "PON Interface already inactive, PON interface %d\n", intf_id);
+ return Status::OK;
+ }
+
+ BCMOLT_CFG_INIT(&interface_obj, pon_interface, intf_key);
BCMOLT_OPER_INIT(&pon_interface_set_state, pon_interface, set_pon_interface_state, intf_key);
BCMOLT_MSG_FIELD_SET(&interface_obj, discovery.control, BCMOLT_CONTROL_STATE_DISABLE);