VOL-2535 : Update the PON-ports on Disable olt,
Openolt agent doesn't disable the NNI port on disble olt device.
Hence NNI operstatus is not updating to UNKNOWN on Disble olt.
Change-Id: I172a1c2c0f3f27567d0740504b1fb5ece614a00d
diff --git a/VERSION b/VERSION
index 4074260..f90b1af 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.2-dev
+2.3.2
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index e373523..6be5be7 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -548,7 +548,7 @@
return err
}
dh.populateActivePorts(device)
- if err := dh.updatePortAdminState(device); err != nil {
+ if err := dh.disableAdminDownPorts(device); err != nil {
log.Errorw("Error-on-updating-port-status", log.Fields{"device": device})
return err
}
@@ -1197,10 +1197,14 @@
go dh.notifyChildDevices("unreachable")
cloned := proto.Clone(device).(*voltha.Device)
- // Update the all ports state on that device to disable
- if err := dh.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
- log.Errorw("updating-ports-failed", log.Fields{"deviceID": device.Id, "error": err})
- return err
+ // Update the all pon ports state on that device to disable and NNI remains active as NNI remains active in openolt agent.
+ for _, port := range cloned.Ports {
+ if port.GetType() == voltha.Port_PON_OLT {
+ if err := dh.coreProxy.PortStateUpdate(context.TODO(), cloned.Id,
+ voltha.Port_PON_OLT, port.GetPortNo(), voltha.OperStatus_UNKNOWN); err != nil {
+ return err
+ }
+ }
}
log.Debugw("disable-device-end", log.Fields{"deviceID": device.Id})
@@ -1255,7 +1259,7 @@
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to enable
- if err := dh.updatePortAdminState(device); err != nil {
+ if err := dh.disableAdminDownPorts(device); err != nil {
log.Errorw("Error-on-updating-port-status-after-reenabling-olt", log.Fields{"device": device})
return err
}
@@ -1606,18 +1610,19 @@
// EnablePort to enable Pon interface
func (dh *DeviceHandler) EnablePort(port *voltha.Port) error {
log.Debugw("enable-port", log.Fields{"Device": dh.device, "port": port})
- return dh.invokeDisableorEnablePort(port, true)
+ return dh.modifyPhyPort(port, true)
}
// DisablePort to disable pon interface
func (dh *DeviceHandler) DisablePort(port *voltha.Port) error {
log.Debugw("disable-port", log.Fields{"Device": dh.device, "port": port})
- return dh.invokeDisableorEnablePort(port, false)
+ return dh.modifyPhyPort(port, false)
}
-func (dh *DeviceHandler) invokeDisableorEnablePort(port *voltha.Port, enablePort bool) error {
+//modifyPhyPort is common function to enable and disable the port. parm :enablePort, true to enablePort and false to disablePort.
+func (dh *DeviceHandler) modifyPhyPort(port *voltha.Port, enablePort bool) error {
ctx := context.Background()
- log.Infow("invokeDisableorEnablePort", log.Fields{"port": port, "Enable": enablePort})
+ log.Infow("modifyPhyPort", log.Fields{"port": port, "Enable": enablePort})
if port.GetType() == voltha.Port_ETHERNET_NNI {
// Bug is opened for VOL-2505 to support NNI disable feature.
log.Infow("voltha-supports-single-nni-hence-disable-of-nni-not-allowed",
@@ -1657,14 +1662,14 @@
return nil
}
-//updatePortAdminState update the ports on reboot and re-enable device.
-func (dh *DeviceHandler) updatePortAdminState(device *voltha.Device) error {
+//disableAdminDownPorts disables the ports, if the corresponding port Adminstate is disabled on reboot and Renable device.
+func (dh *DeviceHandler) disableAdminDownPorts(device *voltha.Device) error {
cloned := proto.Clone(device).(*voltha.Device)
// Disable the port and update the oper_port_status to core
// if the Admin state of the port is disabled on reboot and re-enable device.
for _, port := range cloned.Ports {
if port.AdminState == common.AdminState_DISABLED {
- if err := dh.invokeDisableorEnablePort(port, false); err != nil {
+ if err := dh.DisablePort(port); err != nil {
log.Errorw("error-occurred-while-disabling-port", log.Fields{"DeviceId": dh.deviceID, "port": port, "error": err})
return err
}
diff --git a/adaptercore/device_handler_test.go b/adaptercore/device_handler_test.go
index dcb1f17..aacc930 100644
--- a/adaptercore/device_handler_test.go
+++ b/adaptercore/device_handler_test.go
@@ -136,8 +136,8 @@
Root: true,
ParentId: "logical_device",
Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "nni"},
+ {PortNo: 1, Label: "pon", Type: voltha.Port_PON_OLT},
+ {PortNo: 2, Label: "nni", Type: voltha.Port_ETHERNET_NNI},
},
ProxyAddress: &voltha.Device_ProxyAddress{
DeviceId: "olt",
diff --git a/mocks/mockCoreProxy.go b/mocks/mockCoreProxy.go
index 2c3a81c..9c99599 100644
--- a/mocks/mockCoreProxy.go
+++ b/mocks/mockCoreProxy.go
@@ -210,5 +210,8 @@
// PortStateUpdate implements mock PortStateUpdate
func (mcp *MockCoreProxy) PortStateUpdate(ctx context.Context, deviceID string, pType voltha.Port_PortType, portNo uint32,
operStatus voltha.OperStatus_Types) error {
+ if deviceID == "" {
+ return errors.New("no Device")
+ }
return nil
}