[VOL-2174] Race condition when creating NNI port

This commit fixes the race condition where a the NNI logical port
is not created.  The root cause is that at the time an addport
request is received the parent id of the root device was not set
leadint the addport to believe that it does not exist even if it
does.

Change-Id: Ib9de9f4d3fd74fc142c35a75ba5f9a836985715b
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index fea66d6..d9e8364 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -649,6 +649,24 @@
 	return nil
 }
 
+func (agent *DeviceAgent) setParentId(device *voltha.Device, parentId string) error {
+	agent.lockDevice.Lock()
+	defer agent.lockDevice.Unlock()
+	log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentId})
+	if storeDevice, err := agent.getDeviceWithoutLock(); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		// clone the device
+		cloned := proto.Clone(storeDevice).(*voltha.Device)
+		cloned.ParentId = parentId
+		// Store the device
+		if err := agent.updateDeviceInStoreWithoutLock(cloned, false, ""); err != nil {
+			return err
+		}
+		return nil
+	}
+}
+
 func (agent *DeviceAgent) updatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
 	agent.lockDevice.Lock()
 	defer agent.lockDevice.Unlock()