[VOL-1479] Ensure root device is set.
Ensure the core sets the created device as root instead of relying
on the adapters to do so. Without that setting the proper state
transition in the core does not happen.
Change-Id: I86a2da1fa6fd961d53de7845d47fd1286e921c9f
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index 88b0c7d..b36e8d4 100644
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -130,6 +130,8 @@
func (dMgr *DeviceManager) createDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
log.Debugw("createDevice", log.Fields{"device": device, "aproxy": dMgr.adapterProxy})
+ // Ensure this device is set as root
+ device.Root = true
// Create and start a device agent for that device
agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy)
dMgr.addDeviceAgentToMap(agent)
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
index e313b77..3d0da1b 100644
--- a/rw_core/core/logical_device_manager.go
+++ b/rw_core/core/logical_device_manager.go
@@ -318,6 +318,10 @@
log.Debugw("AddUNILogicalPort", log.Fields{"logDeviceId": logDeviceId, "parentId": parentId})
+ if parentId == "" || logDeviceId == nil {
+ return errors.New("Device-in-invalid-state")
+ }
+
if agent := ldMgr.getLogicalDeviceAgent(*logDeviceId); agent != nil {
if err := agent.addUNILogicalPort(ctx, childDevice); err != nil {
return err