[VOL-1754] :changes to handle device states on olt disable/re-enable
Change-Id: Iafcebc16cb739e7d17d8e42a4c4dbe66027dc27d
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 103f37f..5b6a7f9 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -18,6 +18,10 @@
import (
"context"
"fmt"
+ "reflect"
+ "sync"
+ "time"
+
"github.com/gogo/protobuf/proto"
coreutils "github.com/opencord/voltha-go/rw_core/utils"
"github.com/opencord/voltha-lib-go/v2/pkg/db/model"
@@ -28,9 +32,6 @@
"github.com/opencord/voltha-protos/v2/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "reflect"
- "sync"
- "time"
)
type DeviceAgent struct {
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index 1c198a6..845542f 100755
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -1073,19 +1073,6 @@
return nil
}
-func (dMgr *DeviceManager) MarkChildDevicesAsUnReachable(device *voltha.Device) error {
- log.Info("MarkChildDevicesAsUnReachable")
- // Set the connection status to unreachable
- connStatus := voltha.ConnectStatus_UNREACHABLE
- // Do not set the operational status. Setting it to -1 will do the trick
- operStatus := voltha.OperStatus_OperStatus(-1)
- if err := dMgr.updateChildrenStatus(device.Id, operStatus, connStatus); err != nil {
- log.Warnw("deleteLogical-ports-error", log.Fields{"deviceId": device.Id})
- return err
- }
- return nil
-}
-
func (dMgr *DeviceManager) getParentDevice(childDevice *voltha.Device) *voltha.Device {
// Sanity check
if childDevice.Root {
diff --git a/rw_core/core/device_state_transitions.go b/rw_core/core/device_state_transitions.go
index 998e073..a48346a 100644
--- a/rw_core/core/device_state_transitions.go
+++ b/rw_core/core/device_state_transitions.go
@@ -73,12 +73,6 @@
handlers: []TransitionHandler{dMgr.SetupUNILogicalPorts}})
transitionMap.transitions = append(transitionMap.transitions,
Transition{
- deviceType: parent,
- previousState: DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
- currentState: DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
- handlers: []TransitionHandler{dMgr.MarkChildDevicesAsUnReachable}})
- transitionMap.transitions = append(transitionMap.transitions,
- Transition{
deviceType: any,
previousState: DeviceState{Admin: voltha.AdminState_PREPROVISIONED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
currentState: DeviceState{Admin: voltha.AdminState_DELETED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
diff --git a/rw_core/core/device_state_transitions_test.go b/rw_core/core/device_state_transitions_test.go
index 265cc08..33171ee 100644
--- a/rw_core/core/device_state_transitions_test.go
+++ b/rw_core/core/device_state_transitions_test.go
@@ -78,10 +78,6 @@
return nil
}
-func (tdm *testDeviceManager) MarkChildDevicesAsUnReachable(to *voltha.Device) error {
- return nil
-}
-
func init() {
log.AddPackage(log.JSON, log.WarnLevel, nil)
//log.UpdateAllLoggers(log.Fields{"instanceId": "device-state-transition"})
@@ -202,30 +198,6 @@
assert.Equal(t, 1, len(handlers))
assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
- from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
- to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
- handlers = transitionMap.GetTransitionHandler(from, to)
- assert.Equal(t, 1, len(handlers))
- assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
-
- from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
- to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
- handlers = transitionMap.GetTransitionHandler(from, to)
- assert.Equal(t, 1, len(handlers))
- assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
-
- from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
- to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
- handlers = transitionMap.GetTransitionHandler(from, to)
- assert.Equal(t, 1, len(handlers))
- assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
-
- from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN)
- to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
- handlers = transitionMap.GetTransitionHandler(from, to)
- assert.Equal(t, 1, len(handlers))
- assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
-
from = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
handlers = transitionMap.GetTransitionHandler(from, to)
diff --git a/rw_core/coreIf/device_manager_if.go b/rw_core/coreIf/device_manager_if.go
index 9f9eef4..04a3d72 100644
--- a/rw_core/coreIf/device_manager_if.go
+++ b/rw_core/coreIf/device_manager_if.go
@@ -34,5 +34,4 @@
DeleteLogicalPorts(cDevice *voltha.Device) error
DeleteAllChildDevices(cDevice *voltha.Device) error
RunPostDeviceDelete(cDevice *voltha.Device) error
- MarkChildDevicesAsUnReachable(cDevice *voltha.Device) error
}
diff --git a/rw_core/flow_decomposition/flow_decomposer_test.go b/rw_core/flow_decomposition/flow_decomposer_test.go
index 43b813a..f21f589 100644
--- a/rw_core/flow_decomposition/flow_decomposer_test.go
+++ b/rw_core/flow_decomposition/flow_decomposer_test.go
@@ -146,10 +146,6 @@
return nil
}
-func (tdm *testDeviceManager) MarkChildDevicesAsUnReachable(cDevice *voltha.Device) error {
- return nil
-}
-
type testFlowDecomposer struct {
dMgr *testDeviceManager
logicalPorts map[uint32]*voltha.LogicalPort