VOL-2868 Model simplification/removal.

Reduced the model to its most commonly used functions. (Removed unused logic & test cases.)
Reworked remaining functions to be more intuitive to use, and to more closely follow golang conventions.

Change-Id: Ibbb267ff37e039b73489b4379aa2654208614d5b
diff --git a/rw_core/core/adapter_manager.go b/rw_core/core/adapter_manager.go
index 383600d..1ed5b23 100644
--- a/rw_core/core/adapter_manager.go
+++ b/rw_core/core/adapter_manager.go
@@ -18,7 +18,6 @@
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"sync"
 	"time"
@@ -141,19 +140,17 @@
 //loadAdaptersAndDevicetypesInMemory loads the existing set of adapters and device types in memory
 func (aMgr *AdapterManager) loadAdaptersAndDevicetypesInMemory() error {
 	// Load the adapters
-	adaptersIf, err := aMgr.clusterDataProxy.List(context.Background(), "/adapters", 0, false, "")
-	if err != nil {
+	var adapters []*voltha.Adapter
+	if err := aMgr.clusterDataProxy.List(context.Background(), "adapters", &adapters); err != nil {
 		logger.Errorw("Failed-to-list-adapters-from-cluster-data-proxy", log.Fields{"error": err})
 		return err
 	}
-	if adaptersIf != nil {
-		for _, adapterIf := range adaptersIf.([]interface{}) {
-			if adapter, ok := adapterIf.(*voltha.Adapter); ok {
-				if err := aMgr.addAdapter(adapter, false); err != nil {
-					logger.Errorw("failed to add adapter", log.Fields{"adapterId": adapter.Id})
-				} else {
-					logger.Debugw("adapter added successfully", log.Fields{"adapterId": adapter.Id})
-				}
+	if len(adapters) != 0 {
+		for _, adapter := range adapters {
+			if err := aMgr.addAdapter(adapter, false); err != nil {
+				logger.Errorw("failed to add adapter", log.Fields{"adapterId": adapter.Id})
+			} else {
+				logger.Debugw("adapter added successfully", log.Fields{"adapterId": adapter.Id})
 			}
 		}
 	} else {
@@ -163,20 +160,16 @@
 	}
 
 	// Load the device types
-	deviceTypesIf, err := aMgr.clusterDataProxy.List(context.Background(), "/device_types", 0, false, "")
-	if err != nil {
+	var deviceTypes []*voltha.DeviceType
+	if err := aMgr.clusterDataProxy.List(context.Background(), "device_types", &deviceTypes); err != nil {
 		logger.Errorw("Failed-to-list-device-types-from-cluster-data-proxy", log.Fields{"error": err})
 		return err
 	}
-	if deviceTypesIf != nil {
+	if len(deviceTypes) != 0 {
 		dTypes := &voltha.DeviceTypes{Items: []*voltha.DeviceType{}}
-		for _, deviceTypeIf := range deviceTypesIf.([]interface{}) {
-			if dType, ok := deviceTypeIf.(*voltha.DeviceType); ok {
-				logger.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
-				dTypes.Items = append(dTypes.Items, dType)
-			} else {
-				logger.Errorw("not an voltha device type", log.Fields{"interface": deviceTypeIf})
-			}
+		for _, dType := range deviceTypes {
+			logger.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
+			dTypes.Items = append(dTypes.Items, dType)
 		}
 		return aMgr.addDeviceTypes(dTypes, false)
 	}
@@ -203,22 +196,14 @@
 	if _, exist := aMgr.adapterAgents[adapter.Id]; !exist {
 		if saveToDb {
 			// Save the adapter to the KV store - first check if it already exist
-			kvAdapter, err := aMgr.clusterDataProxy.Get(context.Background(), "/adapters/"+adapter.Id, 0, false, "")
-			if err != nil {
+			if have, err := aMgr.clusterDataProxy.Get(context.Background(), "adapters/"+adapter.Id, &voltha.Adapter{}); err != nil {
 				logger.Errorw("failed-to-get-adapters-from-cluster-proxy", log.Fields{"error": err})
 				return err
-			}
-			if kvAdapter == nil {
-				added, err := aMgr.clusterDataProxy.AddWithID(context.Background(), "/adapters", adapter.Id, adapter, "")
-				if err != nil {
+			} else if !have {
+				if err := aMgr.clusterDataProxy.AddWithID(context.Background(), "adapters", adapter.Id, adapter); err != nil {
 					logger.Errorw("failed-to-save-adapter-to-cluster-proxy", log.Fields{"error": err})
 					return err
 				}
-				if added == nil {
-					//TODO:  Errors when saving to KV would require a separate go routine to be launched and try the saving again
-					logger.Errorw("failed-to-save-adapter", log.Fields{"adapter": adapter})
-					return errors.New("failed-to-save-adapter")
-				}
 				logger.Debugw("adapter-saved-to-KV-Store", log.Fields{"adapter": adapter})
 			}
 		}
@@ -241,23 +226,16 @@
 	if saveToDb {
 		// Save the device types to the KV store
 		for _, deviceType := range deviceTypes.Items {
-			dType, err := aMgr.clusterDataProxy.Get(context.Background(), "/device_types/"+deviceType.Id, 0, false, "")
-			if err != nil {
+			if have, err := aMgr.clusterDataProxy.Get(context.Background(), "device_types/"+deviceType.Id, &voltha.DeviceType{}); err != nil {
 				logger.Errorw("Failed-to--device-types-from-cluster-data-proxy", log.Fields{"error": err})
 				return err
-			}
-			if dType == nil {
+			} else if !have {
 				//	Does not exist - save it
 				clonedDType := (proto.Clone(deviceType)).(*voltha.DeviceType)
-				added, err := aMgr.clusterDataProxy.AddWithID(context.Background(), "/device_types", deviceType.Id, clonedDType, "")
-				if err != nil {
+				if err := aMgr.clusterDataProxy.AddWithID(context.Background(), "device_types", deviceType.Id, clonedDType); err != nil {
 					logger.Errorw("Failed-to-add-device-types-to-cluster-data-proxy", log.Fields{"error": err})
 					return err
 				}
-				if added == nil {
-					logger.Errorw("failed-to-save-deviceType", log.Fields{"deviceType": deviceType})
-					return errors.New("failed-to-save-deviceType")
-				}
 				logger.Debugw("device-type-saved-to-KV-Store", log.Fields{"deviceType": deviceType})
 			}
 		}
diff --git a/rw_core/core/core.go b/rw_core/core/core.go
index 69cd3c8..5043d47 100644
--- a/rw_core/core/core.go
+++ b/rw_core/core/core.go
@@ -18,7 +18,6 @@
 
 import (
 	"context"
-	"fmt"
 	"sync"
 	"time"
 
@@ -46,8 +45,6 @@
 	adapterMgr        *AdapterManager
 	config            *config.RWCoreFlags
 	kmp               kafka.InterContainerProxy
-	clusterDataRoot   model.Root
-	localDataRoot     model.Root
 	clusterDataProxy  *model.Proxy
 	localDataProxy    *model.Proxy
 	exitChannel       chan struct{}
@@ -79,8 +76,6 @@
 		Timeout:                 cf.KVStoreTimeout,
 		LivenessChannelInterval: livenessChannelInterval,
 		PathPrefix:              cf.KVStoreDataPrefix}
-	core.clusterDataRoot = model.NewRoot(&voltha.Voltha{}, &core.backend)
-	core.localDataRoot = model.NewRoot(&voltha.CoreInstance{}, &core.backend)
 	return &core
 }
 
@@ -112,18 +107,9 @@
 	if p != nil {
 		p.UpdateStatus("kv-store", probe.ServiceStatusRunning)
 	}
-	var err error
 
-	core.clusterDataProxy, err = core.clusterDataRoot.CreateProxy(ctx, "/", false)
-	if err != nil {
-		probe.UpdateStatusFromContext(ctx, "kv-store", probe.ServiceStatusNotReady)
-		return fmt.Errorf("Failed to create cluster data proxy")
-	}
-	core.localDataProxy, err = core.localDataRoot.CreateProxy(ctx, "/", false)
-	if err != nil {
-		probe.UpdateStatusFromContext(ctx, "kv-store", probe.ServiceStatusNotReady)
-		return fmt.Errorf("Failed to create local data proxy")
-	}
+	core.clusterDataProxy = model.NewProxy(&core.backend, "/")
+	core.localDataProxy = model.NewProxy(&core.backend, "/")
 
 	// core.kmp must be created before deviceMgr and adapterMgr, as they will make
 	// private copies of the poiner to core.kmp.
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 4c2b9f6..69391fb 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -19,6 +19,7 @@
 import (
 	"context"
 	"encoding/hex"
+	"errors"
 	"fmt"
 	"github.com/golang/protobuf/ptypes"
 	"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
@@ -100,21 +101,17 @@
 	var device *voltha.Device
 	if deviceToCreate == nil {
 		// Load the existing device
-		loadedDevice, err := agent.clusterDataProxy.Get(ctx, "/devices/"+agent.deviceID, 1, true, "")
+		device := &voltha.Device{}
+		have, err := agent.clusterDataProxy.Get(ctx, "devices/"+agent.deviceID, device)
 		if err != nil {
 			return nil, err
+		} else if !have {
+			return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
 		}
-		if loadedDevice != nil {
-			var ok bool
-			if device, ok = loadedDevice.(*voltha.Device); ok {
-				agent.deviceType = device.Adapter
-				agent.device = proto.Clone(device).(*voltha.Device)
-			} else {
-				return nil, status.Errorf(codes.NotFound, "device-%s", agent.deviceID)
-			}
-		} else {
-			return nil, status.Errorf(codes.NotFound, "device-%s-loading-failed", agent.deviceID)
-		}
+
+		agent.deviceType = device.Adapter
+		agent.device = proto.Clone(device).(*voltha.Device)
+
 		logger.Infow("device-loaded-from-dB", log.Fields{"device-id": agent.deviceID})
 	} else {
 		// Create a new device
@@ -133,12 +130,8 @@
 		}
 
 		// Add the initial device to the local model
-		added, err := agent.clusterDataProxy.AddWithID(ctx, "/devices", agent.deviceID, device, "")
-		if err != nil {
-			return nil, err
-		}
-		if added == nil {
-			return nil, status.Errorf(codes.Aborted, "failed-adding-device-%s", agent.deviceID)
+		if err := agent.clusterDataProxy.AddWithID(ctx, "devices", agent.deviceID, device); err != nil {
+			return nil, status.Errorf(codes.Aborted, "failed-adding-device-%s: %s", agent.deviceID, err)
 		}
 		agent.device = device
 	}
@@ -163,13 +156,9 @@
 	logger.Infow("stopping-device-agent", log.Fields{"deviceId": agent.deviceID, "parentId": agent.parentID})
 
 	//	Remove the device from the KV store
-	removed, err := agent.clusterDataProxy.Remove(ctx, "/devices/"+agent.deviceID, "")
-	if err != nil {
+	if err := agent.clusterDataProxy.Remove(ctx, "devices/"+agent.deviceID); err != nil {
 		return err
 	}
-	if removed == nil {
-		logger.Debugw("device-already-removed", log.Fields{"device-id": agent.deviceID})
-	}
 
 	close(agent.exitChannel)
 
@@ -189,18 +178,17 @@
 	defer agent.requestQueue.RequestComplete()
 	logger.Debug("reconciling-device-agent-devicetype")
 	// TODO: context timeout
-	device, err := agent.clusterDataProxy.Get(ctx, "/devices/"+agent.deviceID, 1, true, "")
-	if err != nil {
+	device := &voltha.Device{}
+	if have, err := agent.clusterDataProxy.Get(ctx, "devices/"+agent.deviceID, device); err != nil {
 		logger.Errorw("kv-get-failed", log.Fields{"device-id": agent.deviceID, "error": err})
 		return
+	} else if !have {
+		return // not found in kv
 	}
-	if device != nil {
-		if d, ok := device.(*voltha.Device); ok {
-			agent.deviceType = d.Adapter
-			agent.device = proto.Clone(d).(*voltha.Device)
-			logger.Debugw("reconciled-device-agent-devicetype", log.Fields{"device-id": agent.deviceID, "type": agent.deviceType})
-		}
-	}
+
+	agent.deviceType = device.Adapter
+	agent.device = device
+	logger.Debugw("reconciled-device-agent-devicetype", log.Fields{"device-id": agent.deviceID, "type": agent.deviceType})
 }
 
 // onSuccess is a common callback for scenarios where we receive a nil response following a request to an adapter
@@ -1527,13 +1515,13 @@
 //This is an update operation to model without Lock.This function must never be invoked by another function unless the latter holds a lock on the device.
 // It is an internal helper function.
 func (agent *DeviceAgent) updateDeviceInStoreWithoutLock(ctx context.Context, device *voltha.Device, strict bool, txid string) error {
-	updateCtx := context.WithValue(ctx, model.RequestTimestamp, time.Now().UnixNano())
-	afterUpdate, err := agent.clusterDataProxy.Update(updateCtx, "/devices/"+agent.deviceID, device, strict, txid)
-	if err != nil {
-		return status.Errorf(codes.Internal, "failed-update-device:%s: %s", agent.deviceID, err)
+	if agent.stopped {
+		return errors.New("device agent stopped")
 	}
-	if afterUpdate == nil {
-		return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceID)
+
+	updateCtx := context.WithValue(ctx, model.RequestTimestamp, time.Now().UnixNano())
+	if err := agent.clusterDataProxy.Update(updateCtx, "devices/"+agent.deviceID, device); err != nil {
+		return status.Errorf(codes.Internal, "failed-update-device:%s: %s", agent.deviceID, err)
 	}
 	logger.Debugw("updated-device-in-store", log.Fields{"deviceId: ": agent.deviceID})
 
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index b88f38b..afe84e8 100755
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -382,26 +382,25 @@
 func (dMgr *DeviceManager) ListDevices(ctx context.Context) (*voltha.Devices, error) {
 	logger.Debug("ListDevices")
 	result := &voltha.Devices{}
-	devices, err := dMgr.clusterDataProxy.List(ctx, "/devices", 0, false, "")
-	if err != nil {
+
+	var devices []*voltha.Device
+	if err := dMgr.clusterDataProxy.List(ctx, "devices", &devices); err != nil {
 		logger.Errorw("failed-to-list-devices-from-cluster-proxy", log.Fields{"error": err})
 		return nil, err
 	}
-	if devices != nil {
-		for _, d := range devices.([]interface{}) {
-			device := d.(*voltha.Device)
-			// If device is not in memory then set it up
-			if !dMgr.IsDeviceInCache(device.Id) {
-				logger.Debugw("loading-device-from-Model", log.Fields{"id": device.Id})
-				agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
-				if _, err := agent.start(ctx, nil); err != nil {
-					logger.Warnw("failure-starting-agent", log.Fields{"deviceId": device.Id})
-				} else {
-					dMgr.addDeviceAgentToMap(agent)
-				}
+
+	for _, device := range devices {
+		// If device is not in memory then set it up
+		if !dMgr.IsDeviceInCache(device.Id) {
+			logger.Debugw("loading-device-from-Model", log.Fields{"id": device.Id})
+			agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
+			if _, err := agent.start(ctx, nil); err != nil {
+				logger.Warnw("failure-starting-agent", log.Fields{"deviceId": device.Id})
+			} else {
+				dMgr.addDeviceAgentToMap(agent)
 			}
-			result.Items = append(result.Items, device)
 		}
+		result.Items = append(result.Items, device)
 	}
 	logger.Debugw("ListDevices-end", log.Fields{"len": len(result.Items)})
 	return result, nil
@@ -410,22 +409,20 @@
 //isParentDeviceExist checks whether device is already preprovisioned.
 func (dMgr *DeviceManager) isParentDeviceExist(ctx context.Context, newDevice *voltha.Device) (bool, error) {
 	hostPort := newDevice.GetHostAndPort()
-	devices, err := dMgr.clusterDataProxy.List(ctx, "/devices", 0, false, "")
-	if err != nil {
+	var devices []*voltha.Device
+	if err := dMgr.clusterDataProxy.List(ctx, "devices", &devices); err != nil {
 		logger.Errorw("Failed to list devices from cluster data proxy", log.Fields{"error": err})
 		return false, err
 	}
-	if devices != nil {
-		for _, device := range devices.([]interface{}) {
-			if !device.(*voltha.Device).Root {
-				continue
-			}
-			if hostPort != "" && hostPort == device.(*voltha.Device).GetHostAndPort() && device.(*voltha.Device).AdminState != voltha.AdminState_DELETED {
-				return true, nil
-			}
-			if newDevice.MacAddress != "" && newDevice.MacAddress == device.(*voltha.Device).MacAddress && device.(*voltha.Device).AdminState != voltha.AdminState_DELETED {
-				return true, nil
-			}
+	for _, device := range devices {
+		if !device.Root {
+			continue
+		}
+		if hostPort != "" && hostPort == device.GetHostAndPort() && device.AdminState != voltha.AdminState_DELETED {
+			return true, nil
+		}
+		if newDevice.MacAddress != "" && newDevice.MacAddress == device.MacAddress && device.AdminState != voltha.AdminState_DELETED {
+			return true, nil
 		}
 	}
 	return false, nil
@@ -433,17 +430,15 @@
 
 //getDeviceFromModelretrieves the device data from the model.
 func (dMgr *DeviceManager) getDeviceFromModel(ctx context.Context, deviceID string) (*voltha.Device, error) {
-	device, err := dMgr.clusterDataProxy.Get(ctx, "/devices/"+deviceID, 0, false, "")
-	if err != nil {
+	device := &voltha.Device{}
+	if have, err := dMgr.clusterDataProxy.Get(ctx, "devices/"+deviceID, device); err != nil {
 		logger.Errorw("failed-to-get-device-info-from-cluster-proxy", log.Fields{"error": err})
 		return nil, err
+	} else if !have {
+		return nil, status.Error(codes.NotFound, deviceID)
 	}
-	if device != nil {
-		if d, ok := device.(*voltha.Device); ok {
-			return d, nil
-		}
-	}
-	return nil, status.Error(codes.NotFound, deviceID)
+
+	return device, nil
 }
 
 // loadDevice loads the deviceID in memory, if not present
@@ -947,21 +942,17 @@
 
 	if deviceType == "" && vendorID != "" {
 		logger.Debug("device-type-is-nil-fetching-device-type")
-		deviceTypesIf, err := dMgr.adapterMgr.clusterDataProxy.List(ctx, "/device_types", 0, false, "")
-		if err != nil {
+		var deviceTypes []*voltha.DeviceType
+		if err := dMgr.adapterMgr.clusterDataProxy.List(ctx, "device_types", &deviceTypes); err != nil {
 			logger.Errorw("failed-to-get-device-type-info", log.Fields{"error": err})
 			return nil, err
 		}
-		if deviceTypesIf != nil {
-		OLoop:
-			for _, deviceTypeIf := range deviceTypesIf.([]interface{}) {
-				if dType, ok := deviceTypeIf.(*voltha.DeviceType); ok {
-					for _, v := range dType.VendorIds {
-						if v == vendorID {
-							deviceType = dType.Adapter
-							break OLoop
-						}
-					}
+	OLoop:
+		for _, dType := range deviceTypes {
+			for _, v := range dType.VendorIds {
+				if v == vendorID {
+					deviceType = dType.Adapter
+					break OLoop
 				}
 			}
 		}
diff --git a/rw_core/core/logical_device_agent.go b/rw_core/core/logical_device_agent.go
index 2616540..76067bb 100644
--- a/rw_core/core/logical_device_agent.go
+++ b/rw_core/core/logical_device_agent.go
@@ -47,7 +47,7 @@
 	deviceMgr          *DeviceManager
 	ldeviceMgr         *LogicalDeviceManager
 	clusterDataProxy   *model.Proxy
-	exitChannel        chan int
+	stopped            bool
 	deviceRoutes       *route.DeviceRoutes
 	lockDeviceRoutes   sync.RWMutex
 	logicalPortsNo     map[uint32]bool //value is true for NNI port
@@ -63,7 +63,6 @@
 func newLogicalDeviceAgent(id string, sn string, deviceID string, ldeviceMgr *LogicalDeviceManager,
 	deviceMgr *DeviceManager, cdProxy *model.Proxy, timeout time.Duration) *LogicalDeviceAgent {
 	var agent LogicalDeviceAgent
-	agent.exitChannel = make(chan int, 1)
 	agent.logicalDeviceID = id
 	agent.serialNumber = sn
 	agent.rootDeviceID = deviceID
@@ -119,15 +118,11 @@
 		ld.Ports = []*voltha.LogicalPort{}
 
 		// Save the logical device
-		added, err := agent.clusterDataProxy.AddWithID(ctx, "/logical_devices", ld.Id, ld, "")
-		if err != nil {
+		if err := agent.clusterDataProxy.AddWithID(ctx, "logical_devices", ld.Id, ld); err != nil {
+			logger.Errorw("failed-to-add-logical-device", log.Fields{"logical-device-id": agent.logicalDeviceID})
 			return err
 		}
-		if added == nil {
-			logger.Errorw("failed-to-add-logical-device", log.Fields{"logical-device-id": agent.logicalDeviceID})
-		} else {
-			logger.Debugw("logicaldevice-created", log.Fields{"logical-device-id": agent.logicalDeviceID, "root-id": ld.RootDeviceId})
-		}
+		logger.Debugw("logicaldevice-created", log.Fields{"logical-device-id": agent.logicalDeviceID, "root-id": ld.RootDeviceId})
 
 		agent.logicalDevice = proto.Clone(ld).(*voltha.LogicalDevice)
 
@@ -141,14 +136,14 @@
 	} else {
 		//	load from dB - the logical may not exist at this time.  On error, just return and the calling function
 		// will destroy this agent.
-		logicalDevice, err := agent.clusterDataProxy.Get(ctx, "/logical_devices/"+agent.logicalDeviceID, 0, true, "")
+		ld := &voltha.LogicalDevice{}
+		have, err := agent.clusterDataProxy.Get(ctx, "logical_devices/"+agent.logicalDeviceID, ld)
 		if err != nil {
 			return err
-		}
-		ld, ok := logicalDevice.(*voltha.LogicalDevice)
-		if !ok {
+		} else if !have {
 			return status.Errorf(codes.NotFound, "logical_device-%s", agent.logicalDeviceID)
 		}
+
 		// Update the root device Id
 		agent.rootDeviceID = ld.RootDeviceId
 
@@ -186,15 +181,13 @@
 		defer agent.requestQueue.RequestComplete()
 
 		//Remove the logical device from the model
-		if removed, err := agent.clusterDataProxy.Remove(ctx, "/logical_devices/"+agent.logicalDeviceID, ""); err != nil {
+		if err := agent.clusterDataProxy.Remove(ctx, "logical_devices/"+agent.logicalDeviceID); err != nil {
 			returnErr = err
-		} else if removed == nil {
-			returnErr = status.Errorf(codes.Aborted, "failed-to-remove-logical-ldevice-%s", agent.logicalDeviceID)
 		} else {
 			logger.Debugw("logicaldevice-removed", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
 		}
 
-		close(agent.exitChannel)
+		agent.stopped = true
 
 		logger.Info("logical_device-agent-stopped")
 	})
@@ -539,16 +532,16 @@
 
 //updateLogicalDeviceWithoutLock updates the model with the logical device.  It clones the logicaldevice before saving it
 func (agent *LogicalDeviceAgent) updateLogicalDeviceWithoutLock(ctx context.Context, logicalDevice *voltha.LogicalDevice) error {
+	if agent.stopped {
+		return errors.New("logical device agent stopped")
+	}
+
 	updateCtx := context.WithValue(ctx, model.RequestTimestamp, time.Now().UnixNano())
-	afterUpdate, err := agent.clusterDataProxy.Update(updateCtx, "/logical_devices/"+agent.logicalDeviceID, logicalDevice, false, "")
-	if err != nil {
+	if err := agent.clusterDataProxy.Update(updateCtx, "logical_devices/"+agent.logicalDeviceID, logicalDevice); err != nil {
 		logger.Errorw("failed-to-update-logical-devices-to-cluster-proxy", log.Fields{"error": err})
 		return err
 	}
-	if afterUpdate == nil {
-		return status.Errorf(codes.Internal, "failed-updating-logical-device:%s", agent.logicalDeviceID)
-	}
-	//agent.logicalDevice = (proto.Clone(logicalDevice)).(*voltha.LogicalDevice)
+
 	agent.logicalDevice = logicalDevice
 
 	return nil
diff --git a/rw_core/core/logical_device_agent_test.go b/rw_core/core/logical_device_agent_test.go
index 0babfad..175fe06 100644
--- a/rw_core/core/logical_device_agent_test.go
+++ b/rw_core/core/logical_device_agent_test.go
@@ -487,9 +487,8 @@
 	clonedLD.DatapathId = rand.Uint64()
 	lDeviceAgent := newLogicalDeviceAgent(clonedLD.Id, clonedLD.Id, clonedLD.RootDeviceId, lDeviceMgr, deviceMgr, lDeviceMgr.clusterDataProxy, lDeviceMgr.defaultTimeout)
 	lDeviceAgent.logicalDevice = clonedLD
-	added, err := lDeviceAgent.clusterDataProxy.AddWithID(context.Background(), "/logical_devices", clonedLD.Id, clonedLD, "")
+	err := lDeviceAgent.clusterDataProxy.AddWithID(context.Background(), "logical_devices", clonedLD.Id, clonedLD)
 	assert.Nil(t, err)
-	assert.NotNil(t, added)
 	lDeviceMgr.addLogicalDeviceAgentToMap(lDeviceAgent)
 	return lDeviceAgent
 }
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
index f2554d6..86e6b63 100644
--- a/rw_core/core/logical_device_manager.go
+++ b/rw_core/core/logical_device_manager.go
@@ -137,18 +137,13 @@
 //listLogicalDevices returns the list of all logical devices
 func (ldMgr *LogicalDeviceManager) listLogicalDevices(ctx context.Context) (*voltha.LogicalDevices, error) {
 	logger.Debug("ListAllLogicalDevices")
-	result := &voltha.LogicalDevices{}
-	logicalDevices, err := ldMgr.clusterDataProxy.List(ctx, "/logical_devices", 0, true, "")
-	if err != nil {
+
+	var logicalDevices []*voltha.LogicalDevice
+	if err := ldMgr.clusterDataProxy.List(ctx, "logical_devices", &logicalDevices); err != nil {
 		logger.Errorw("failed-to-list-logical-devices-from-cluster-proxy", log.Fields{"error": err})
 		return nil, err
 	}
-	if logicalDevices != nil {
-		for _, logicalDevice := range logicalDevices.([]interface{}) {
-			result.Items = append(result.Items, logicalDevice.(*voltha.LogicalDevice))
-		}
-	}
-	return result, nil
+	return &voltha.LogicalDevices{Items: logicalDevices}, nil
 }
 
 func (ldMgr *LogicalDeviceManager) createLogicalDevice(ctx context.Context, device *voltha.Device) (*string, error) {
@@ -218,17 +213,15 @@
 
 //getLogicalDeviceFromModel retrieves the logical device data from the model.
 func (ldMgr *LogicalDeviceManager) getLogicalDeviceFromModel(ctx context.Context, lDeviceID string) (*voltha.LogicalDevice, error) {
-	logicalDevice, err := ldMgr.clusterDataProxy.Get(ctx, "/logical_devices/"+lDeviceID, 0, false, "")
-	if err != nil {
+	logicalDevice := &voltha.LogicalDevice{}
+	if have, err := ldMgr.clusterDataProxy.Get(ctx, "logical_devices/"+lDeviceID, logicalDevice); err != nil {
 		logger.Errorw("failed-to-get-logical-devices-from-cluster-proxy", log.Fields{"error": err})
 		return nil, err
+	} else if !have {
+		return nil, status.Error(codes.NotFound, lDeviceID)
 	}
-	if logicalDevice != nil {
-		if lDevice, ok := logicalDevice.(*voltha.LogicalDevice); ok {
-			return lDevice, nil
-		}
-	}
-	return nil, status.Error(codes.NotFound, lDeviceID)
+
+	return logicalDevice, nil
 }
 
 // load loads a logical device manager in memory