This commit consists of the following:
1) The kafka messaging proxy in Twisted python for adapters
2) Initial implementation and containerization of ponsim OLT adapter
and ponsim ONU adapter
3) Initial submission of request and response facade in both Twisted
python and Go Language
4) Initial implementation of device management and logical device management
in the Core
5) Update to the log module to allow dynamic setting of log level per
package using the gRPC API
6) Bug fixes and minor changes

Change-Id: Ia8f033da84cfd08275335bae9542802415e7bb0f
diff --git a/rw_core/core/adapter_proxy.go b/rw_core/core/adapter_proxy.go
new file mode 100644
index 0000000..a0e25f3
--- /dev/null
+++ b/rw_core/core/adapter_proxy.go
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"github.com/golang/protobuf/ptypes"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/kafka"
+	ca "github.com/opencord/voltha-go/protos/core_adapter"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+)
+
+type AdapterProxy struct {
+	TestMode   bool
+	kafkaProxy *kafka.KafkaMessagingProxy
+}
+
+func NewAdapterProxy(kafkaProxy *kafka.KafkaMessagingProxy) *AdapterProxy {
+	var proxy AdapterProxy
+	proxy.kafkaProxy = kafkaProxy
+	return &proxy
+}
+
+func (ap *AdapterProxy) AdoptDevice(ctx context.Context, device *voltha.Device) error {
+	log.Debugw("AdoptDevice", log.Fields{"device": device})
+	topic := kafka.Topic{Name: device.Type}
+	args := make([]*kafka.KVArg, 1)
+	args[0] = &kafka.KVArg{
+		Key:   "device",
+		Value: device,
+	}
+	success, result := ap.kafkaProxy.InvokeRPC(ctx, "adopt_device", &topic, true, args...)
+	log.Debugw("AdoptDevice-response", log.Fields{"deviceid": device.Id, "success": success, "result": result})
+	if success {
+		return nil
+	} else {
+		unpackResult := &ca.Error{}
+		var err error
+		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+		}
+		log.Debugw("AdoptDevice-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+		// TODO:  Need to get the real error code
+		return status.Errorf(codes.Canceled, "%s", unpackResult.Reason)
+	}
+}
+
+func (ap *AdapterProxy) AdapterDescriptor() (*voltha.Adapter, error) {
+	log.Debug("AdapterDescriptor")
+	return nil, nil
+}
+
+func (ap *AdapterProxy) DeviceTypes() (*voltha.DeviceType, error) {
+	log.Debug("DeviceTypes")
+	return nil, nil
+}
+
+func (ap *AdapterProxy) Health() (*voltha.HealthStatus, error) {
+	log.Debug("Health")
+	return nil, nil
+}
+
+func (ap *AdapterProxy) ReconcileDevice(device voltha.Device) error {
+	log.Debug("ReconcileDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) AbandonDevice(device voltha.Device) error {
+	log.Debug("AbandonDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) DisableDevice(device voltha.Device) error {
+	log.Debug("DisableDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) ReEnableDevice(device voltha.Device) error {
+	log.Debug("ReEnableDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) RebootDevice(device voltha.Device) error {
+	log.Debug("RebootDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) DeleteDevice(device voltha.Device) error {
+	log.Debug("DeleteDevice")
+	return nil
+}
+
+func (ap *AdapterProxy) GetDeviceDetails(device voltha.Device) (*voltha.Device, error) {
+	log.Debug("GetDeviceDetails")
+	return nil, nil
+}
+
+func (ap *AdapterProxy) DownloadImage(device voltha.Device, download voltha.ImageDownload) error {
+	log.Debug("DownloadImage")
+	return nil
+}
+
+func (ap *AdapterProxy) GetImageDownloadStatus(device voltha.Device, download voltha.ImageDownload) error {
+	log.Debug("GetImageDownloadStatus")
+	return nil
+}
+
+func (ap *AdapterProxy) CancelImageDownload(device voltha.Device, download voltha.ImageDownload) error {
+	log.Debug("CancelImageDownload")
+	return nil
+}
+
+func (ap *AdapterProxy) ActivateImageUpdate(device voltha.Device, download voltha.ImageDownload) error {
+	log.Debug("ActivateImageUpdate")
+	return nil
+}
+
+func (ap *AdapterProxy) RevertImageUpdate(device voltha.Device, download voltha.ImageDownload) error {
+	log.Debug("RevertImageUpdate")
+	return nil
+}
+
+func (ap *AdapterProxy) SelfTestDevice(device voltha.Device) (*voltha.SelfTestResponse, error) {
+	log.Debug("SelfTestDevice")
+	return nil, nil
+}
+
+func (ap *AdapterProxy) UpdateFlowsBulk(device voltha.Device, flows voltha.Flows, groups voltha.FlowGroups) error {
+	log.Debug("UpdateFlowsBulk")
+	return nil
+}
+
+func (ap *AdapterProxy) UpdateFlowsIncremental(device voltha.Device, flowChanges voltha.Flows, groupChanges voltha.FlowGroups) error {
+	log.Debug("UpdateFlowsIncremental")
+	return nil
+}
+
+func (ap *AdapterProxy) UpdatePmConfig(device voltha.Device, pmConfigs voltha.PmConfigs) error {
+	log.Debug("UpdatePmConfig")
+	return nil
+}
+
+func (ap *AdapterProxy) ReceivePacketOut(deviceId voltha.ID, egressPortNo int, msg interface{}) error {
+	log.Debug("ReceivePacketOut")
+	return nil
+}
+
+func (ap *AdapterProxy) SuppressAlarm(filter voltha.AlarmFilter) error {
+	log.Debug("SuppressAlarm")
+	return nil
+}
+
+func (ap *AdapterProxy) UnSuppressAlarm(filter voltha.AlarmFilter) error {
+	log.Debug("UnSuppressAlarm")
+	return nil
+}
+
+func (ap *AdapterProxy) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ca.SwitchCapability, error) {
+	log.Debugw("GetOfpDeviceInfo", log.Fields{"device": device})
+	topic := kafka.Topic{Name: device.Type}
+	args := make([]*kafka.KVArg, 1)
+	args[0] = &kafka.KVArg{
+		Key:   "device",
+		Value: device,
+	}
+	success, result := ap.kafkaProxy.InvokeRPC(ctx, "get_ofp_device_info", &topic, true, args...)
+	log.Debugw("GetOfpDeviceInfo-response", log.Fields{"device": device, "success": success, "result": result})
+	if success {
+		unpackResult := &ca.SwitchCapability{}
+		if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
+			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+			return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
+		}
+		return unpackResult, nil
+	} else {
+		unpackResult := &ca.Error{}
+		var err error
+		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+		}
+		log.Debugw("GetOfpDeviceInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+		// TODO:  Need to get the real error code
+		return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
+	}
+}
+
+func (ap *AdapterProxy) GetOfpPortInfo(ctx context.Context, device *voltha.Device, portNo uint32) (*ca.PortCapability, error) {
+	log.Debug("GetOfpPortInfo", log.Fields{"device": device})
+	topic := kafka.Topic{Name: device.Type}
+	args := make([]*kafka.KVArg, 2)
+	args[0] = &kafka.KVArg{
+		Key:   "device",
+		Value: device,
+	}
+	pNo := &ca.IntType{Val: int64(portNo)}
+	args[1] = &kafka.KVArg{
+		Key:   "port_no",
+		Value: pNo,
+	}
+
+	success, result := ap.kafkaProxy.InvokeRPC(ctx, "get_ofp_port_info", &topic, true, args...)
+	log.Debugw("GetOfpPortInfo-response", log.Fields{"deviceid": device.Id, "device": device, "success": success, "result": result})
+	if success {
+		unpackResult := &ca.PortCapability{}
+		if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
+			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+			return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
+		}
+		return unpackResult, nil
+	} else {
+		unpackResult := &ca.Error{}
+		var err error
+		if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+			log.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
+		}
+		log.Debugw("GetOfpPortInfo-return", log.Fields{"deviceid": device.Id, "success": success, "error": err})
+		// TODO:  Need to get the real error code
+		return nil, status.Errorf(codes.Internal, "%s", unpackResult.Reason)
+	}
+}
diff --git a/rw_core/core/adapter_request_handler.go b/rw_core/core/adapter_request_handler.go
new file mode 100644
index 0000000..95ad69d
--- /dev/null
+++ b/rw_core/core/adapter_request_handler.go
@@ -0,0 +1,355 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"errors"
+	"github.com/golang/protobuf/ptypes"
+	"github.com/golang/protobuf/ptypes/empty"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	ca "github.com/opencord/voltha-go/protos/core_adapter"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+)
+
+type AdapterRequestHandlerProxy struct {
+	TestMode         bool
+	deviceMgr        *DeviceManager
+	lDeviceMgr       *LogicalDeviceManager
+	localDataProxy   *model.Proxy
+	clusterDataProxy *model.Proxy
+}
+
+func NewAdapterRequestHandlerProxy(dMgr *DeviceManager, ldMgr *LogicalDeviceManager, cdProxy *model.Proxy, ldProxy *model.Proxy) *AdapterRequestHandlerProxy {
+	var proxy AdapterRequestHandlerProxy
+	proxy.deviceMgr = dMgr
+	proxy.lDeviceMgr = ldMgr
+	proxy.clusterDataProxy = cdProxy
+	proxy.localDataProxy = ldProxy
+	return &proxy
+}
+
+func (rhp *AdapterRequestHandlerProxy) Register(args []*ca.Argument) (*voltha.CoreInstance, error) {
+	if len(args) != 1 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	adapter := &voltha.Adapter{}
+	if err := ptypes.UnmarshalAny(args[0].Value, adapter); err != nil {
+		log.Warnw("cannot-unmarshal-adapter", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("Register", log.Fields{"Adapter": *adapter})
+	// TODO process the request and store the data in the KV store
+
+	if rhp.TestMode { // Execute only for test cases
+		return &voltha.CoreInstance{InstanceId: "CoreInstance"}, nil
+	}
+	return &voltha.CoreInstance{InstanceId: "CoreInstance"}, nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) GetDevice(args []*ca.Argument) (*voltha.Device, error) {
+	if len(args) != 1 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	pID := &voltha.ID{}
+	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
+		log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("GetDevice", log.Fields{"deviceId": pID.Id})
+
+	if rhp.TestMode { // Execute only for test cases
+		return &voltha.Device{Id: pID.Id}, nil
+	}
+
+	// Get the device via the device manager
+	if device, err := rhp.deviceMgr.getDevice(pID.Id); err != nil {
+		return nil, status.Errorf(codes.NotFound, "%s", err.Error())
+	} else {
+		return device, nil
+	}
+}
+
+func (rhp *AdapterRequestHandlerProxy) DeviceUpdate(args []*ca.Argument) (*empty.Empty, error) {
+	if len(args) != 1 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	device := &voltha.Device{}
+	if err := ptypes.UnmarshalAny(args[0].Value, device); err != nil {
+		log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("DeviceUpdate", log.Fields{"device": device})
+
+	if rhp.TestMode { // Execute only for test cases
+		return new(empty.Empty), nil
+	}
+	if err := rhp.deviceMgr.updateDevice(device); err != nil {
+		log.Debugw("DeviceUpdate-error", log.Fields{"device": device, "error": err})
+		return nil, status.Errorf(codes.Internal, "%s", err.Error())
+	}
+	return new(empty.Empty), nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) GetChildDevice(args []*ca.Argument) (*voltha.Device, error) {
+	if len(args) < 1 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	pID := &ca.StrType{}
+	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
+		log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("GetChildDevice", log.Fields{"deviceId": pID.Val})
+
+	if rhp.TestMode { // Execute only for test cases
+		return &voltha.Device{Id: pID.Val}, nil
+	}
+	return nil, nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) GetPorts(args []*ca.Argument) (*voltha.Ports, error) {
+	if len(args) != 2 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	pID := &ca.StrType{}
+	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
+		log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+		return nil, err
+	}
+	// Porttype is an enum sent as an integer proto
+	pt := &ca.IntType{}
+	if err := ptypes.UnmarshalAny(args[1].Value, pt); err != nil {
+		log.Warnw("cannot-unmarshal-porttype", log.Fields{"error": err})
+		return nil, err
+	}
+
+	log.Debugw("GetPorts", log.Fields{"deviceID": pID.Val, "portype": pt.Val})
+
+	if rhp.TestMode { // Execute only for test cases
+		aPort := &voltha.Port{Label: "test_port"}
+		allPorts := &voltha.Ports{}
+		allPorts.Items = append(allPorts.Items, aPort)
+		return allPorts, nil
+	}
+	return nil, nil
+
+}
+
+func (rhp *AdapterRequestHandlerProxy) GetChildDevices(args []*ca.Argument) (*voltha.Device, error) {
+	if len(args) != 1 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	pID := &ca.StrType{}
+	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
+		log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+		return nil, err
+	}
+	log.Debugw("GetChildDevice", log.Fields{"deviceId": pID.Val})
+
+	if rhp.TestMode { // Execute only for test cases
+		return &voltha.Device{Id: pID.Val}, nil
+	}
+	//TODO: Complete
+	return nil, nil
+}
+
+// ChildDeviceDetected is invoked when a child device is detected.  The following
+// parameters are expected:
+// {parent_device_id, parent_port_no, child_device_type, proxy_address, admin_state, **kw)
+func (rhp *AdapterRequestHandlerProxy) ChildDeviceDetected(args []*ca.Argument) (*empty.Empty, error) {
+	if len(args) < 4 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+
+	pID := &voltha.ID{}
+	portNo := &ca.IntType{}
+	dt := &ca.StrType{}
+	chnlId := &ca.IntType{}
+	for _, arg := range args {
+		switch arg.Key {
+		case "parent_device_id":
+			if err := ptypes.UnmarshalAny(arg.Value, pID); err != nil {
+				log.Warnw("cannot-unmarshal-parent-device-id", log.Fields{"error": err})
+				return nil, err
+			}
+		case "parent_port_no":
+			if err := ptypes.UnmarshalAny(arg.Value, portNo); err != nil {
+				log.Warnw("cannot-unmarshal-parent-port", log.Fields{"error": err})
+				return nil, err
+			}
+		case "child_device_type":
+			if err := ptypes.UnmarshalAny(arg.Value, dt); err != nil {
+				log.Warnw("cannot-unmarshal-child-device-type", log.Fields{"error": err})
+				return nil, err
+			}
+		case "channel_id":
+			if err := ptypes.UnmarshalAny(arg.Value, chnlId); err != nil {
+				log.Warnw("cannot-unmarshal-channel-id", log.Fields{"error": err})
+				return nil, err
+			}
+		}
+	}
+
+	log.Debugw("ChildDeviceDetected", log.Fields{"parentDeviceId": pID.Id, "parentPortNo": portNo.Val,
+		"deviceType": dt.Val, "channelId": chnlId.Val})
+
+	if rhp.TestMode { // Execute only for test cases
+		return nil, nil
+	}
+
+	// Run child detection in it's own go routine as it can be a lengthy process
+	go rhp.deviceMgr.childDeviceDetected(pID.Id, portNo.Val, dt.Val, chnlId.Val)
+
+	return new(empty.Empty), nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) DeviceStateUpdate(args []*ca.Argument) (*empty.Empty, error) {
+	if len(args) < 2 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	deviceId := &voltha.ID{}
+	operStatus := &ca.IntType{}
+	connStatus := &ca.IntType{}
+	for _, arg := range args {
+		switch arg.Key {
+		case "device_id":
+			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+				return nil, err
+			}
+		case "oper_status":
+			if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
+				log.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
+				return nil, err
+			}
+			if operStatus.Val == -1 {
+				operStatus = nil
+			}
+		case "connect_status":
+			if err := ptypes.UnmarshalAny(arg.Value, connStatus); err != nil {
+				log.Warnw("cannot-unmarshal-connStatus", log.Fields{"error": err})
+				return nil, err
+			}
+			if connStatus.Val == -1 {
+				connStatus = nil
+			}
+		}
+	}
+
+	log.Debugw("DeviceStateUpdate", log.Fields{"deviceId": deviceId.Id, "oper-status": operStatus, "conn-status": connStatus})
+
+	if rhp.TestMode { // Execute only for test cases
+		return nil, nil
+	}
+	if err := rhp.deviceMgr.updateDeviceState(deviceId.Id, operStatus, connStatus); err != nil {
+		log.Debugw("DeviceUpdate-error", log.Fields{"deviceId": deviceId.Id, "error": err})
+		return nil, status.Errorf(codes.Internal, "%s", err.Error())
+	}
+	return new(empty.Empty), nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) PortCreated(args []*ca.Argument) (*empty.Empty, error) {
+	if len(args) != 2 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	deviceId := &voltha.ID{}
+	port := &voltha.Port{}
+	for _, arg := range args {
+		switch arg.Key {
+		case "device_id":
+			if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+				log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+				return nil, err
+			}
+		case "port":
+			if err := ptypes.UnmarshalAny(arg.Value, port); err != nil {
+				log.Warnw("cannot-unmarshal-port", log.Fields{"error": err})
+				return nil, err
+			}
+		}
+	}
+
+	log.Debugw("PortCreated", log.Fields{"deviceId": deviceId.Id, "port": port})
+
+	if rhp.TestMode { // Execute only for test cases
+		return nil, nil
+	}
+
+	if err := rhp.deviceMgr.addPort(deviceId.Id, port); err != nil {
+		log.Debugw("addport-error", log.Fields{"deviceId": deviceId.Id, "error": err})
+		return nil, status.Errorf(codes.Internal, "%s", err.Error())
+	}
+	return new(empty.Empty), nil
+}
+
+func (rhp *AdapterRequestHandlerProxy) DevicePMConfigUpdate(args []*ca.Argument) (*empty.Empty, error) {
+	if len(args) != 2 {
+		log.Warn("invalid-number-of-args", log.Fields{"args": args})
+		err := errors.New("invalid-number-of-args")
+		return nil, err
+	}
+	pmConfigs := &voltha.PmConfigs{}
+	init := &ca.BoolType{}
+	for _, arg := range args {
+		switch arg.Key {
+		case "device_pm_config":
+			if err := ptypes.UnmarshalAny(arg.Value, pmConfigs); err != nil {
+				log.Warnw("cannot-unmarshal-pm-config", log.Fields{"error": err})
+				return nil, err
+			}
+		case "init":
+			if err := ptypes.UnmarshalAny(arg.Value, init); err != nil {
+				log.Warnw("cannot-unmarshal-boolean", log.Fields{"error": err})
+				return nil, err
+			}
+		}
+	}
+
+	log.Debugw("DevicePMConfigUpdate", log.Fields{"deviceId": pmConfigs.Id, "configs": pmConfigs,
+		"init": init})
+
+	if rhp.TestMode { // Execute only for test cases
+		return nil, nil
+	}
+
+	if err := rhp.deviceMgr.updatePmConfigs(pmConfigs.Id, pmConfigs); err != nil {
+		log.Debugw("update-pmconfigs-error", log.Fields{"deviceId": pmConfigs.Id, "error": err})
+		return nil, status.Errorf(codes.Internal, "%s", err.Error())
+	}
+	return new(empty.Empty), nil
+
+}
diff --git a/rw_core/core/core.go b/rw_core/core/core.go
new file mode 100644
index 0000000..f9e42ef
--- /dev/null
+++ b/rw_core/core/core.go
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	grpcserver "github.com/opencord/voltha-go/common/grpc"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/kafka"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"github.com/opencord/voltha-go/rw_core/config"
+	"google.golang.org/grpc"
+	"reflect"
+)
+
+type Core struct {
+	instanceId        string
+	deviceMgr         *DeviceManager
+	logicalDeviceMgr  *LogicalDeviceManager
+	grpcServer        *grpcserver.GrpcServer
+	grpcNBIAPIHanfler *APIHandler
+	config            *config.RWCoreFlags
+	kmp               *kafka.KafkaMessagingProxy
+	clusterDataRoot   *model.Root
+	localDataRoot     *model.Root
+	clusterDataProxy  *model.Proxy
+	localDataProxy    *model.Proxy
+	exitChannel       chan int
+}
+
+func init() {
+	log.AddPackage(log.JSON, log.WarnLevel, nil)
+}
+
+func NewCore(id string, cf *config.RWCoreFlags) *Core {
+	var core Core
+	core.instanceId = id
+	core.exitChannel = make(chan int, 1)
+	core.config = cf
+	// TODO: Setup the KV store
+	core.clusterDataRoot = model.NewRoot(&voltha.Voltha{}, nil, reflect.TypeOf(model.NonPersistedRevision{}))
+	core.localDataRoot = model.NewRoot(&voltha.CoreInstance{}, nil, reflect.TypeOf(model.NonPersistedRevision{}))
+	core.clusterDataProxy = core.clusterDataRoot.Node.GetProxy("/", false)
+	core.localDataProxy = core.localDataRoot.Node.GetProxy("/", false)
+	return &core
+}
+
+func (core *Core) Start(ctx context.Context) {
+	log.Info("starting-core")
+	core.startKafkaMessagingProxy(ctx)
+	log.Info("values", log.Fields{"kmp": core.kmp})
+	core.deviceMgr = NewDeviceManager(core.kmp, core.localDataProxy)
+	core.logicalDeviceMgr = NewLogicalDeviceManager(core.deviceMgr, core.kmp, core.localDataProxy)
+	core.registerAdapterRequestHandler(ctx, core.deviceMgr, core.logicalDeviceMgr, core.localDataProxy, core.clusterDataProxy)
+	go core.startDeviceManager(ctx)
+	go core.startLogicalDeviceManager(ctx)
+	go core.startGRPCService(ctx)
+
+	log.Info("core-started")
+}
+
+func (core *Core) Stop(ctx context.Context) {
+	log.Info("stopping-core")
+	core.exitChannel <- 1
+	log.Info("core-stopped")
+}
+
+//startGRPCService creates the grpc service handler, registers it to the grpc server
+// and starts the server
+func (core *Core) startGRPCService(ctx context.Context) {
+	//	create an insecure gserver server
+	core.grpcServer = grpcserver.NewGrpcServer(core.config.GrpcHost, core.config.GrpcPort, nil, false)
+	log.Info("grpc-server-created")
+
+	core.grpcNBIAPIHanfler = NewAPIHandler(core.deviceMgr, core.logicalDeviceMgr, core.clusterDataProxy, core.localDataProxy)
+	//	Create a function to register the core GRPC service with the GRPC server
+	f := func(gs *grpc.Server) {
+		voltha.RegisterVolthaServiceServer(
+			gs,
+			core.grpcNBIAPIHanfler,
+		)
+	}
+
+	core.grpcServer.AddService(f)
+	log.Info("grpc-service-added")
+
+	//	Start the server
+	core.grpcServer.Start(context.Background())
+	log.Info("grpc-server-started")
+}
+
+func (core *Core) startKafkaMessagingProxy(ctx context.Context) error {
+	log.Infow("starting-kafka-messaging-proxy", log.Fields{"host": core.config.KafkaAdapterHost,
+		"port": core.config.KafkaAdapterPort, "topic": core.config.CoreTopic})
+	var err error
+	if core.kmp, err = kafka.NewKafkaMessagingProxy(
+		kafka.KafkaHost(core.config.KafkaAdapterHost),
+		kafka.KafkaPort(core.config.KafkaAdapterPort),
+		kafka.DefaultTopic(&kafka.Topic{Name: core.config.CoreTopic})); err != nil {
+		log.Errorw("fail-to-create-kafka-proxy", log.Fields{"error": err})
+		return err
+	}
+
+	if err = core.kmp.Start(); err != nil {
+		log.Fatalw("error-starting-messaging-proxy", log.Fields{"error": err})
+		return err
+	}
+
+	log.Info("kafka-messaging-proxy-created")
+	return nil
+}
+
+func (core *Core) registerAdapterRequestHandler(ctx context.Context, dMgr *DeviceManager, ldMgr *LogicalDeviceManager,
+	cdProxy *model.Proxy, ldProxy *model.Proxy) error {
+	requestProxy := NewAdapterRequestHandlerProxy(dMgr, ldMgr, cdProxy, ldProxy)
+	core.kmp.SubscribeWithTarget(kafka.Topic{Name: core.config.CoreTopic}, requestProxy)
+
+	log.Info("request-handler")
+	return nil
+}
+
+func (core *Core) startDeviceManager(ctx context.Context) {
+	// TODO: Interaction between the logicaldevicemanager and devicemanager should mostly occur via
+	// callbacks.  For now, until the model is ready, devicemanager will keep a reference to the
+	// logicaldevicemanager to initiate the creation of logical devices
+	log.Info("starting-DeviceManager")
+	core.deviceMgr.Start(ctx, core.logicalDeviceMgr)
+	log.Info("started-DeviceManager")
+}
+
+func (core *Core) startLogicalDeviceManager(ctx context.Context) {
+	log.Info("starting-Logical-DeviceManager")
+	core.logicalDeviceMgr.Start(ctx)
+	log.Info("started-Logical-DeviceManager")
+}
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
new file mode 100644
index 0000000..aa13748
--- /dev/null
+++ b/rw_core/core/device_agent.go
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"github.com/gogo/protobuf/proto"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/protos/core_adapter"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"reflect"
+)
+
+type DeviceAgent struct {
+	deviceId       string
+	lastData       *voltha.Device
+	adapterProxy   *AdapterProxy
+	deviceMgr      *DeviceManager
+	localDataProxy *model.Proxy
+	exitChannel    chan int
+}
+
+func newDeviceAgent(ap *AdapterProxy, device *voltha.Device, deviceMgr *DeviceManager, ldProxy *model.Proxy) *DeviceAgent {
+	var agent DeviceAgent
+	device.Id = CreateDeviceId()
+	agent.deviceId = device.Id
+	agent.adapterProxy = ap
+	agent.lastData = device
+	agent.deviceMgr = deviceMgr
+	agent.exitChannel = make(chan int, 1)
+	agent.localDataProxy = ldProxy
+	return &agent
+}
+
+func (agent *DeviceAgent) start(ctx context.Context) {
+	log.Debugw("starting-device-agent", log.Fields{"device": agent.lastData})
+	// Add the initial device to the local model
+	if added := agent.localDataProxy.Add("/devices", agent.lastData, ""); added == nil {
+		log.Errorw("failed-to-add-device", log.Fields{"deviceId": agent.deviceId})
+	}
+	log.Debug("device-agent-started")
+}
+
+func (agent *DeviceAgent) Stop(ctx context.Context) {
+	log.Debug("stopping-device-agent")
+	agent.exitChannel <- 1
+	log.Debug("device-agent-stopped")
+}
+
+func (agent *DeviceAgent) enableDevice(ctx context.Context) error {
+	log.Debugw("enableDevice", log.Fields{"id": agent.lastData.Id, "device": agent.lastData})
+	// Update the device status
+	if device, err := agent.deviceMgr.getDevice(agent.deviceId); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		cloned := reflect.ValueOf(device).Elem().Interface().(voltha.Device)
+		cloned.AdminState = voltha.AdminState_ENABLED
+		cloned.OperStatus = voltha.OperStatus_ACTIVATING
+		if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+			return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceId)
+		} else {
+			if err := agent.adapterProxy.AdoptDevice(ctx, &cloned); err != nil {
+				log.Debugw("enableDevice-error", log.Fields{"id": agent.lastData.Id, "error": err})
+				return err
+			}
+			agent.lastData = &cloned
+		}
+	}
+	return nil
+}
+
+func (agent *DeviceAgent) getNNIPorts(ctx context.Context) *voltha.Ports {
+	log.Debugw("getNNIPorts", log.Fields{"id": agent.deviceId})
+	ports := &voltha.Ports{}
+	if device, _ := agent.deviceMgr.getDevice(agent.deviceId); device != nil {
+		for _, port := range device.Ports {
+			if port.Type == voltha.Port_ETHERNET_NNI {
+				ports.Items = append(ports.Items, port)
+			}
+		}
+	}
+	return ports
+}
+
+func (agent *DeviceAgent) getSwitchCapability(ctx context.Context) (*core_adapter.SwitchCapability, error) {
+	log.Debugw("getSwitchCapability", log.Fields{"deviceId": agent.deviceId})
+	if device, err := agent.deviceMgr.getDevice(agent.deviceId); device == nil {
+		return nil, err
+	} else {
+		var switchCap *core_adapter.SwitchCapability
+		var err error
+		if switchCap, err = agent.adapterProxy.GetOfpDeviceInfo(ctx, device); err != nil {
+			log.Debugw("getSwitchCapability-error", log.Fields{"id": device.Id, "error": err})
+			return nil, err
+		}
+		return switchCap, nil
+	}
+}
+
+func (agent *DeviceAgent) getPortCapability(ctx context.Context, portNo uint32) (*core_adapter.PortCapability, error) {
+	log.Debugw("getPortCapability", log.Fields{"deviceId": agent.deviceId})
+	if device, err := agent.deviceMgr.getDevice(agent.deviceId); device == nil {
+		return nil, err
+	} else {
+		var portCap *core_adapter.PortCapability
+		var err error
+		if portCap, err = agent.adapterProxy.GetOfpPortInfo(ctx, device, portNo); err != nil {
+			log.Debugw("getPortCapability-error", log.Fields{"id": device.Id, "error": err})
+			return nil, err
+		}
+		return portCap, nil
+	}
+}
+
+func (agent *DeviceAgent) updateDevice(device *voltha.Device) error {
+	log.Debugw("updateDevice", log.Fields{"deviceId": device.Id})
+	// Get the dev info from the model
+	if storedData, err := agent.deviceMgr.getDevice(device.Id); err != nil {
+		return status.Errorf(codes.NotFound, "%s", device.Id)
+	} else {
+		// store the changed data
+		cloned := (proto.Clone(device)).(*voltha.Device)
+		afterUpdate := agent.localDataProxy.Update("/devices/"+device.Id, cloned, false, "")
+		if afterUpdate == nil {
+			return status.Errorf(codes.Internal, "%s", device.Id)
+		}
+		// Perform the state transition
+		if err := agent.deviceMgr.processTransition(storedData, cloned); err != nil {
+			log.Warnw("process-transition-error", log.Fields{"deviceid": device.Id, "error": err})
+			return err
+		}
+		return nil
+	}
+}
+
+func (agent *DeviceAgent) updateDeviceState(operState *core_adapter.IntType, connState *core_adapter.IntType) error {
+	// Work only on latest data
+	if storeDevice, err := agent.deviceMgr.getDevice(agent.deviceId); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		// clone the device
+		cloned := reflect.ValueOf(storeDevice).Elem().Interface().(voltha.Device)
+		if operState != nil {
+			cloned.OperStatus = voltha.OperStatus_OperStatus(operState.Val)
+		}
+		if connState != nil {
+			cloned.ConnectStatus = voltha.ConnectStatus_ConnectStatus(connState.Val)
+		}
+		log.Debugw("DeviceStateUpdate-device", log.Fields{"device": cloned})
+		// Store the device
+		if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+			return status.Errorf(codes.Internal, "%s", agent.deviceId)
+		}
+		// Perform the state transition
+		if err := agent.deviceMgr.processTransition(storeDevice, &cloned); err != nil {
+			log.Warnw("process-transition-error", log.Fields{"deviceid": agent.deviceId, "error": err})
+			return err
+		}
+		return nil
+	}
+}
+
+func (agent *DeviceAgent) updatePmConfigs(pmConfigs *voltha.PmConfigs) error {
+	log.Debug("updatePmConfigs")
+	// Work only on latest data
+	if storeDevice, err := agent.deviceMgr.getDevice(agent.deviceId); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		// clone the device
+		cloned := reflect.ValueOf(storeDevice).Elem().Interface().(voltha.Device)
+		cp := proto.Clone(pmConfigs)
+		cloned.PmConfigs = cp.(*voltha.PmConfigs)
+		// Store the device
+		afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
+		if afterUpdate == nil {
+			return status.Errorf(codes.Internal, "%s", agent.deviceId)
+		}
+		return nil
+	}
+}
+
+func (agent *DeviceAgent) addPort(port *voltha.Port) error {
+	log.Debug("addPort")
+	// Work only on latest data
+	if storeDevice, err := agent.deviceMgr.getDevice(agent.deviceId); err != nil {
+		return status.Errorf(codes.NotFound, "%s", agent.deviceId)
+	} else {
+		// clone the device
+		cloned := reflect.ValueOf(storeDevice).Elem().Interface().(voltha.Device)
+		if cloned.Ports == nil {
+			//	First port
+			cloned.Ports = make([]*voltha.Port, 0)
+		}
+		cp := proto.Clone(port)
+		cloned.Ports = append(cloned.Ports, cp.(*voltha.Port))
+		// Store the device
+		afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, "")
+		if afterUpdate == nil {
+			return status.Errorf(codes.Internal, "%s", agent.deviceId)
+		}
+		return nil
+	}
+}
+
+// TODO: A generic device update by attribute
+func (agent *DeviceAgent) updateDeviceAttribute(name string, value interface{}) {
+	if value == nil {
+		return
+	}
+	var storeDevice *voltha.Device
+	var err error
+	if storeDevice, err = agent.deviceMgr.getDevice(agent.deviceId); err != nil {
+		return
+	}
+	updated := false
+	s := reflect.ValueOf(storeDevice).Elem()
+	if s.Kind() == reflect.Struct {
+		// exported field
+		f := s.FieldByName(name)
+		if f.IsValid() && f.CanSet() {
+			switch f.Kind() {
+			case reflect.String:
+				f.SetString(value.(string))
+				updated = true
+			case reflect.Uint32:
+				f.SetUint(uint64(value.(uint32)))
+				updated = true
+			case reflect.Bool:
+				f.SetBool(value.(bool))
+				updated = true
+			}
+		}
+	}
+	log.Debugw("update-field-status", log.Fields{"device": storeDevice, "name": name, "updated": updated})
+	//	Save the data
+	cloned := reflect.ValueOf(storeDevice).Elem().Interface().(voltha.Device)
+	if afterUpdate := agent.localDataProxy.Update("/devices/"+agent.deviceId, &cloned, false, ""); afterUpdate == nil {
+		log.Warnw("attribute-update-failed", log.Fields{"attribute": name, "value": value})
+	}
+	return
+}
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
new file mode 100644
index 0000000..a6c0c8d
--- /dev/null
+++ b/rw_core/core/device_manager.go
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"errors"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/kafka"
+	"github.com/opencord/voltha-go/protos/core_adapter"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"reflect"
+	"runtime"
+	"sync"
+)
+
+type DeviceManager struct {
+	deviceAgents        map[string]*DeviceAgent
+	adapterProxy        *AdapterProxy
+	logicalDeviceMgr    *LogicalDeviceManager
+	kafkaProxy          *kafka.KafkaMessagingProxy
+	stateTransitions    *TransitionMap
+	localDataProxy      *model.Proxy
+	exitChannel         chan int
+	lockDeviceAgentsMap sync.RWMutex
+}
+
+func NewDeviceManager(kafkaProxy *kafka.KafkaMessagingProxy, ldProxy *model.Proxy) *DeviceManager {
+	var deviceMgr DeviceManager
+	deviceMgr.exitChannel = make(chan int, 1)
+	deviceMgr.deviceAgents = make(map[string]*DeviceAgent)
+	deviceMgr.adapterProxy = NewAdapterProxy(kafkaProxy)
+	deviceMgr.kafkaProxy = kafkaProxy
+	deviceMgr.localDataProxy = ldProxy
+	deviceMgr.lockDeviceAgentsMap = sync.RWMutex{}
+	return &deviceMgr
+}
+
+func (dMgr *DeviceManager) Start(ctx context.Context, logicalDeviceMgr *LogicalDeviceManager) {
+	log.Info("starting-device-manager")
+	dMgr.logicalDeviceMgr = logicalDeviceMgr
+	dMgr.stateTransitions = NewTransitionMap(dMgr)
+	log.Info("device-manager-started")
+}
+
+func (dMgr *DeviceManager) Stop(ctx context.Context) {
+	log.Info("stopping-device-manager")
+	dMgr.exitChannel <- 1
+	log.Info("device-manager-stopped")
+}
+
+func sendResponse(ctx context.Context, ch chan interface{}, result interface{}) {
+	if ctx.Err() == nil {
+		// Returned response only of the ctx has not been cancelled/timeout/etc
+		// Channel is automatically closed when a context is Done
+		ch <- result
+		log.Debugw("sendResponse", log.Fields{"result": result})
+	} else {
+		// Should the transaction be reverted back?
+		log.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
+	}
+}
+
+func (dMgr *DeviceManager) addDeviceAgentToMap(agent *DeviceAgent) {
+	dMgr.lockDeviceAgentsMap.Lock()
+	defer dMgr.lockDeviceAgentsMap.Unlock()
+	if _, exist := dMgr.deviceAgents[agent.deviceId]; !exist {
+		dMgr.deviceAgents[agent.deviceId] = agent
+	}
+}
+
+func (dMgr *DeviceManager) getDeviceAgent(deviceId string) *DeviceAgent {
+	dMgr.lockDeviceAgentsMap.Lock()
+	defer dMgr.lockDeviceAgentsMap.Unlock()
+	if agent, ok := dMgr.deviceAgents[deviceId]; ok {
+		return agent
+	}
+	return nil
+}
+
+func (dMgr *DeviceManager) createDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
+	log.Debugw("createDevice-start", log.Fields{"device": device, "aproxy": dMgr.adapterProxy})
+
+	// Create and start a device agent for that device
+	agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.localDataProxy)
+	dMgr.addDeviceAgentToMap(agent)
+	agent.start(ctx)
+
+	sendResponse(ctx, ch, nil)
+}
+
+func (dMgr *DeviceManager) enableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
+	log.Debugw("enableDevice-start", log.Fields{"deviceid": id})
+
+	var res interface{}
+	if agent := dMgr.getDeviceAgent(id.Id); agent != nil {
+		res = agent.enableDevice(ctx)
+		log.Debugw("EnableDevice-result", log.Fields{"result": res})
+	} else {
+		res = status.Errorf(codes.NotFound, "%s", id.Id)
+	}
+
+	sendResponse(ctx, ch, res)
+}
+
+func (dMgr *DeviceManager) getDevice(id string) (*voltha.Device, error) {
+	log.Debugw("getDevice-start", log.Fields{"deviceid": id})
+
+	if device := dMgr.localDataProxy.Get("/devices/"+id, 1, false, ""); device == nil {
+		return nil, status.Errorf(codes.NotFound, "%s", id)
+	} else {
+		cloned := reflect.ValueOf(device).Elem().Interface().(voltha.Device)
+		return &cloned, nil
+	}
+}
+
+func (dMgr *DeviceManager) ListDevices() (*voltha.Devices, error) {
+	log.Debug("ListDevices-start")
+	result := &voltha.Devices{}
+	dMgr.lockDeviceAgentsMap.Lock()
+	defer dMgr.lockDeviceAgentsMap.Unlock()
+	for _, agent := range dMgr.deviceAgents {
+		if device := dMgr.localDataProxy.Get("/devices/"+agent.deviceId, 1, false, ""); device != nil {
+			cloned := reflect.ValueOf(device).Elem().Interface().(voltha.Device)
+			result.Items = append(result.Items, &cloned)
+		}
+	}
+	return result, nil
+}
+
+func (dMgr *DeviceManager) updateDevice(device *voltha.Device) error {
+	log.Debugw("updateDevice-start", log.Fields{"deviceid": device.Id, "device": device})
+
+	if agent := dMgr.getDeviceAgent(device.Id); agent != nil {
+		return agent.updateDevice(device)
+	}
+	return status.Errorf(codes.NotFound, "%s", device.Id)
+}
+
+func (dMgr *DeviceManager) addPort(deviceId string, port *voltha.Port) error {
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.addPort(port)
+	}
+	return status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) updatePmConfigs(deviceId string, pmConfigs *voltha.PmConfigs) error {
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.updatePmConfigs(pmConfigs)
+	}
+	return status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) getSwitchCapability(ctx context.Context, deviceId string) (*core_adapter.SwitchCapability, error) {
+	log.Debugw("getSwitchCapability-start", log.Fields{"deviceid": deviceId})
+
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.getSwitchCapability(ctx)
+	}
+	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) getNNIPorts(ctx context.Context, deviceId string) (*voltha.Ports, error) {
+	log.Debugw("getNNIPorts-start", log.Fields{"deviceid": deviceId})
+
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.getNNIPorts(ctx), nil
+	}
+	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) getPortCapability(ctx context.Context, deviceId string, portNo uint32) (*core_adapter.PortCapability, error) {
+	log.Debugw("getPortCapability-start", log.Fields{"deviceid": deviceId})
+
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.getPortCapability(ctx, portNo)
+	}
+	return nil, status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) updateDeviceState(deviceId string, operState *core_adapter.IntType, connState *core_adapter.IntType) error {
+	log.Debugw("updateDeviceState-start", log.Fields{"deviceid": deviceId, "operState": operState, "connState": connState})
+	if agent := dMgr.getDeviceAgent(deviceId); agent != nil {
+		return agent.updateDeviceState(operState, connState)
+	}
+	return status.Errorf(codes.NotFound, "%s", deviceId)
+}
+
+func (dMgr *DeviceManager) childDeviceDetected(parentDeviceId string, parentPortNo int64, deviceType string, channelId int64) error {
+	log.Debugw("childDeviceDetected-start", log.Fields{"parentDeviceId": parentDeviceId})
+
+	// Create the ONU device
+	childDevice := &voltha.Device{}
+	childDevice.Id = CreateDeviceId()
+	childDevice.Type = deviceType
+	childDevice.ParentId = parentDeviceId
+	childDevice.ParentPortNo = uint32(parentPortNo)
+	childDevice.Root = false
+	childDevice.ProxyAddress = &voltha.Device_ProxyAddress{ChannelId: uint32(channelId)}
+
+	// Create and start a device agent for that device
+	agent := newDeviceAgent(dMgr.adapterProxy, childDevice, dMgr, dMgr.localDataProxy)
+	dMgr.addDeviceAgentToMap(agent)
+	agent.start(nil)
+
+	// Activate the child device
+	if agent := dMgr.getDeviceAgent(childDevice.Id); agent != nil {
+		return agent.enableDevice(nil)
+	}
+
+	return nil
+}
+
+func (dMgr *DeviceManager) processTransition(previous *voltha.Device, current *voltha.Device) error {
+	// This will be triggered on every update to the device.
+	handler := dMgr.stateTransitions.GetTransitionHandler(previous, current)
+	if handler != nil {
+		log.Debugw("found-handler", log.Fields{"handler": funcName(handler)})
+		return handler(previous, current)
+	}
+	log.Debugw("handler-not-found", log.Fields{"deviceId": current.Id})
+	return nil
+}
+
+func (dMgr *DeviceManager) createLogicalDevice(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("createLogicalDevice")
+	var logicalId *string
+	var err error
+	if logicalId, err = dMgr.logicalDeviceMgr.CreateLogicalDevice(nil, cDevice); err != nil {
+		log.Warnw("createlogical-device-error", log.Fields{"device": cDevice})
+		return err
+	}
+	// Update the parent device with the logical id
+	dMgr.UpdateDeviceAttribute(cDevice.Id, "ParentId", *logicalId)
+	return nil
+}
+
+func (dMgr *DeviceManager) addUNILogicalPort(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("addUNILogicalPort")
+	if err := dMgr.logicalDeviceMgr.AddUNILogicalPort(nil, cDevice); err != nil {
+		log.Warnw("addUNILogicalPort-error", log.Fields{"device": cDevice, "err": err})
+		return err
+	}
+	return nil
+}
+
+func (dMgr *DeviceManager) activateDevice(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("activateDevice")
+	return nil
+}
+
+func (dMgr *DeviceManager) disableDevice(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("disableDevice")
+	return nil
+}
+
+func (dMgr *DeviceManager) abandonDevice(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("abandonDevice")
+	return nil
+}
+
+func (dMgr *DeviceManager) reEnableDevice(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("reEnableDevice")
+	return nil
+}
+
+func (dMgr *DeviceManager) noOp(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("noOp")
+	return nil
+}
+
+func (dMgr *DeviceManager) notAllowed(pDevice *voltha.Device, cDevice *voltha.Device) error {
+	log.Info("notAllowed")
+	return errors.New("Transition-not-allowed")
+}
+
+func funcName(f interface{}) string {
+	p := reflect.ValueOf(f).Pointer()
+	rf := runtime.FuncForPC(p)
+	return rf.Name()
+}
+
+func (dMgr *DeviceManager) UpdateDeviceAttribute(deviceId string, attribute string, value interface{}) {
+	if agent, ok := dMgr.deviceAgents[deviceId]; ok {
+		agent.updateDeviceAttribute(attribute, value)
+	}
+}
+
+func (dMgr *DeviceManager) GetParentDeviceId(deviceId string) *string {
+	if device, _ := dMgr.getDevice(deviceId); device != nil {
+		log.Infow("GetParentDeviceId", log.Fields{"device": device})
+		return &device.ParentId
+	}
+	return nil
+}
diff --git a/rw_core/core/device_state_transitions.go b/rw_core/core/device_state_transitions.go
new file mode 100644
index 0000000..0f0239c
--- /dev/null
+++ b/rw_core/core/device_state_transitions.go
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/protos/voltha"
+)
+
+type DeviceType int32
+
+const (
+	parent DeviceType = 0
+	child  DeviceType = 1
+	any    DeviceType = 2
+)
+
+type DeviceState struct {
+	Admin       voltha.AdminState_AdminState
+	Connection  voltha.ConnectStatus_ConnectStatus
+	Operational voltha.OperStatus_OperStatus
+}
+
+type TransitionHandler func(*voltha.Device, *voltha.Device) error
+
+type Transition struct {
+	deviceType    DeviceType
+	previousState DeviceState
+	currentState  DeviceState
+	handler       TransitionHandler
+}
+
+type TransitionMap struct {
+	transitions []Transition
+}
+
+func NewTransitionMap(dMgr *DeviceManager) *TransitionMap {
+	var transitionMap TransitionMap
+	transitionMap.transitions = make([]Transition, 0)
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_UNKNOWN, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.activateDevice})
+	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_UNKNOWN, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+	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_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.activateDevice})
+	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_DOWNLOADING_IMAGE, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_UNKNOWN, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    parent,
+			previousState: DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_ACTIVATING},
+			currentState:  DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_ACTIVE},
+			handler:       dMgr.createLogicalDevice})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    child,
+			previousState: DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_ACTIVATING},
+			currentState:  DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_ACTIVE},
+			handler:       dMgr.addUNILogicalPort})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			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},
+			handler:       dMgr.disableDevice})
+
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_PREPROVISIONED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.abandonDevice})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_UNKNOWN, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_PREPROVISIONED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.abandonDevice})
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_ENABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.reEnableDevice})
+
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_DOWNLOADING_IMAGE, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+
+	transitionMap.transitions = append(transitionMap.transitions,
+		Transition{
+			deviceType:    any,
+			previousState: DeviceState{Admin: voltha.AdminState_DOWNLOADING_IMAGE, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			currentState:  DeviceState{Admin: voltha.AdminState_DISABLED, Connection: voltha.ConnectStatus_UNKNOWN, Operational: voltha.OperStatus_UNKNOWN},
+			handler:       dMgr.notAllowed})
+
+	return &transitionMap
+}
+
+func getDeviceStates(device *voltha.Device) *DeviceState {
+	return &DeviceState{Admin: device.AdminState, Connection: device.ConnectStatus, Operational: device.OperStatus}
+}
+
+// isMatched matches a state transition.  It returns whether there is a match and if there is whether it is an exact match
+func getHandler(previous *DeviceState, current *DeviceState, transition *Transition) (TransitionHandler, bool) {
+
+	// Do we have an exact match?
+	if *previous == transition.previousState && *current == transition.currentState {
+		return transition.handler, true
+	}
+	// If the admin state changed then prioritize it first
+	if previous.Admin != current.Admin {
+		if previous.Admin == transition.previousState.Admin && current.Admin == transition.currentState.Admin {
+			return transition.handler, false
+		}
+	}
+	// If the operational state changed then prioritize it in second position
+	if previous.Operational != current.Operational {
+		if previous.Operational == transition.previousState.Operational && current.Operational == transition.currentState.Operational {
+			return transition.handler, false
+		}
+	}
+	// If the connection state changed then prioritize it in third position
+	if previous.Connection != current.Connection {
+		if previous.Connection == transition.previousState.Connection && current.Connection == transition.currentState.Connection {
+			return transition.handler, false
+		}
+	}
+	return nil, false
+}
+
+func (tMap *TransitionMap) GetTransitionHandler(pDevice *voltha.Device, cDevice *voltha.Device) TransitionHandler {
+	//1. Get the previous and current set of states
+	pState := getDeviceStates(pDevice)
+	cState := getDeviceStates(cDevice)
+	log.Infow("DeviceType", log.Fields{"device": pDevice})
+	deviceType := parent
+	if !pDevice.Root {
+		log.Info("device is child")
+		deviceType = child
+	}
+	log.Infof("deviceType:%d-deviceId:%s-previous:%v-current:%v", deviceType, pDevice.Id, pState, cState)
+
+	//2. Go over transition array to get the right transition
+	var currentMatch TransitionHandler
+	var tempHandler TransitionHandler
+	var exactMatch bool
+	var deviceTypeMatch bool
+	for _, aTransition := range tMap.transitions {
+		// consider transition only if it matches deviceType or is a wild card - any
+		if aTransition.deviceType != deviceType && aTransition.deviceType != any {
+			continue
+		}
+		tempHandler, exactMatch = getHandler(pState, cState, &aTransition)
+		if tempHandler != nil {
+			if exactMatch {
+				return tempHandler
+			} else {
+				if currentMatch == nil {
+					currentMatch = tempHandler
+				} else if aTransition.deviceType == deviceType {
+					currentMatch = tempHandler
+					deviceTypeMatch = true
+				} else if !deviceTypeMatch {
+					currentMatch = tempHandler
+				}
+			}
+		}
+	}
+	return currentMatch
+}
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
new file mode 100644
index 0000000..6af73cd
--- /dev/null
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -0,0 +1,297 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"errors"
+	"github.com/golang/protobuf/ptypes/empty"
+	da "github.com/opencord/voltha-go/common/core/northbound/grpc"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/protos/common"
+	"github.com/opencord/voltha-go/protos/openflow_13"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/metadata"
+	"google.golang.org/grpc/status"
+)
+
+type APIHandler struct {
+	deviceMgr        *DeviceManager
+	logicalDeviceMgr *LogicalDeviceManager
+	clusterDataProxy *model.Proxy
+	localDataProxy   *model.Proxy
+	da.DefaultAPIHandler
+}
+
+func NewAPIHandler(deviceMgr *DeviceManager, lDeviceMgr *LogicalDeviceManager, cdProxy *model.Proxy, ldProxy *model.Proxy) *APIHandler {
+	handler := &APIHandler{deviceMgr: deviceMgr,
+		logicalDeviceMgr: lDeviceMgr,
+		clusterDataProxy: cdProxy,
+		localDataProxy:   ldProxy}
+	return handler
+}
+func isTestMode(ctx context.Context) bool {
+	md, _ := metadata.FromIncomingContext(ctx)
+	_, exist := md[common.TestModeKeys_api_test.String()]
+	return exist
+}
+
+func (handler *APIHandler) UpdateLogLevel(ctx context.Context, logging *voltha.Logging) (*empty.Empty, error) {
+	log.Debugw("UpdateLogLevel-request", log.Fields{"newloglevel": logging.Level, "intval": int(logging.Level)})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		log.SetPackageLogLevel(logging.PackageName, int(logging.Level))
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+
+}
+
+func processEnableDevicePort(ctx context.Context, id *voltha.LogicalPortId, ch chan error) {
+	log.Debugw("processEnableDevicePort", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+	ch <- status.Errorf(100, "%d-%s", 100, "erreur")
+
+}
+
+func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+	log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	ch := make(chan error)
+	go processEnableDevicePort(ctx, id, ch)
+	select {
+	case resp := <-ch:
+		close(ch)
+		return new(empty.Empty), resp
+	case <-ctx.Done():
+		return nil, ctx.Err()
+	}
+}
+
+func (handler *APIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+	log.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
+	log.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
+	log.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+// GetDevice must be implemented in the read-only containers - should it also be implemented here?
+func (handler *APIHandler) GetDevice(ctx context.Context, id *voltha.ID) (*voltha.Device, error) {
+	log.Debugw("GetDevice-request", log.Fields{"id": id})
+	return handler.deviceMgr.getDevice(id.Id)
+}
+
+// GetDevice must be implemented in the read-only containers - should it also be implemented here?
+func (handler *APIHandler) ListDevices(ctx context.Context, empty *empty.Empty) (*voltha.Devices, error) {
+	log.Debug("ListDevices")
+	return handler.deviceMgr.ListDevices()
+}
+
+// GetLogicalDevice must be implemented in the read-only containers - should it also be implemented here?
+func (handler *APIHandler) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
+	log.Debugw("GetLogicalDevice-request", log.Fields{"id": id})
+	return handler.logicalDeviceMgr.getLogicalDevice(id.Id)
+}
+
+// ListLogicalDevices must be implemented in the read-only containers - should it also be implemented here?
+func (handler *APIHandler) ListLogicalDevices(ctx context.Context, empty *empty.Empty) (*voltha.LogicalDevices, error) {
+	log.Debug("ListLogicalDevices")
+	return handler.logicalDeviceMgr.listLogicalDevices()
+}
+
+func (handler *APIHandler) CreateDevice(ctx context.Context, device *voltha.Device) (*voltha.Device, error) {
+	log.Debugw("createdevice", log.Fields{"device": *device})
+	if isTestMode(ctx) {
+		return &voltha.Device{Id: device.Id}, nil
+	}
+	ch := make(chan interface{})
+	defer close(ch)
+	go handler.deviceMgr.createDevice(ctx, device, ch)
+	select {
+	case res := <-ch:
+		if res == nil {
+			return &voltha.Device{Id: device.Id}, nil
+		} else if err, ok := res.(error); ok {
+			return &voltha.Device{Id: device.Id}, err
+		} else {
+			log.Warnw("create-device-unexpected-return-type", log.Fields{"result": res})
+			err = status.Errorf(codes.Internal, "%s", res)
+			return &voltha.Device{Id: device.Id}, err
+		}
+	case <-ctx.Done():
+		log.Debug("createdevice-client-timeout")
+		return nil, ctx.Err()
+	}
+}
+
+func (handler *APIHandler) EnableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+	log.Debugw("enabledevice", log.Fields{"id": id})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	ch := make(chan interface{})
+	defer close(ch)
+	go handler.deviceMgr.enableDevice(ctx, id, ch)
+	select {
+	case res := <-ch:
+		if res == nil {
+			return new(empty.Empty), nil
+		} else if err, ok := res.(error); ok {
+			return new(empty.Empty), err
+		} else {
+			log.Warnw("enable-device-unexpected-return-type", log.Fields{"result": res})
+			err = status.Errorf(codes.Internal, "%s", res)
+			return new(empty.Empty), err
+		}
+	case <-ctx.Done():
+		log.Debug("enabledevice-client-timeout")
+		return nil, ctx.Err()
+	}
+}
+
+func (handler *APIHandler) DisableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+	log.Debugw("disabledevice-request", log.Fields{"id": id})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) RebootDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+	log.Debugw("disabledevice-request", log.Fields{"id": id})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+	log.Debugw("deletedevice-request", log.Fields{"id": id})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+	log.Debugw("DownloadImage-request", log.Fields{"img": *img})
+	if isTestMode(ctx) {
+		resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+		return resp, nil
+	}
+
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+	log.Debugw("CancelImageDownload-request", log.Fields{"img": *img})
+	if isTestMode(ctx) {
+		resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+		return resp, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+	log.Debugw("ActivateImageUpdate-request", log.Fields{"img": *img})
+	if isTestMode(ctx) {
+		resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+		return resp, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+	log.Debugw("RevertImageUpdate-request", log.Fields{"img": *img})
+	if isTestMode(ctx) {
+		resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+		return resp, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
+	log.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) CreateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+	log.Debugw("CreateAlarmFilter-request", log.Fields{"filter": *filter})
+	if isTestMode(ctx) {
+		f := &voltha.AlarmFilter{Id: filter.Id}
+		return f, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) UpdateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+	log.Debugw("UpdateAlarmFilter-request", log.Fields{"filter": *filter})
+	if isTestMode(ctx) {
+		f := &voltha.AlarmFilter{Id: filter.Id}
+		return f, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) DeleteAlarmFilter(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+	log.Debugw("DeleteAlarmFilter-request", log.Fields{"id": *id})
+	if isTestMode(ctx) {
+		out := new(empty.Empty)
+		return out, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) SelfTest(ctx context.Context, id *voltha.ID) (*voltha.SelfTestResponse, error) {
+	log.Debugw("SelfTest-request", log.Fields{"id": id})
+	if isTestMode(ctx) {
+		resp := &voltha.SelfTestResponse{Result: voltha.SelfTestResponse_SUCCESS}
+		return resp, nil
+	}
+	return nil, errors.New("UnImplemented")
+}
diff --git a/rw_core/core/grpc_nbi_api_handler_client_test.go b/rw_core/core/grpc_nbi_api_handler_client_test.go
new file mode 100644
index 0000000..721271e
--- /dev/null
+++ b/rw_core/core/grpc_nbi_api_handler_client_test.go
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"github.com/golang/protobuf/ptypes/empty"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/protos/common"
+	"github.com/opencord/voltha-go/protos/openflow_13"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/metadata"
+	"google.golang.org/grpc/status"
+	"os"
+	"testing"
+)
+
+var conn *grpc.ClientConn
+var stub voltha.VolthaServiceClient
+var testMode string
+
+/*
+NOTE:  These tests require the rw_core to run prior to executing these test cases
+*/
+
+func setup() {
+	var err error
+
+	if err = log.AddPackage(log.JSON, log.WarnLevel, log.Fields{"instanceId": "testing"}); err != nil {
+		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+	}
+	conn, err = grpc.Dial("localhost:50057", grpc.WithInsecure())
+	if err != nil {
+		log.Fatalf("did not connect: %s", err)
+	}
+
+	stub = voltha.NewVolthaServiceClient(conn)
+	testMode = common.TestModeKeys_api_test.String()
+}
+
+func TestGetDevice(t *testing.T) {
+	var id common.ID
+	id.Id = "anyid"
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.GetDevice(ctx, &id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, id.Id, st.Message())
+	assert.Equal(t, codes.NotFound, st.Code())
+}
+
+func TestUpdateLogLevelError(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	level := voltha.Logging{PackageName: "github.com/opencord/voltha-go/rw_core/core", Level: common.LogLevel_ERROR}
+	response, err := stub.UpdateLogLevel(ctx, &level)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestGetVoltha(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.GetVoltha(ctx, &empty.Empty{})
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestUpdateLogLevelDebug(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	level := voltha.Logging{PackageName: "github.com/opencord/voltha-go/rw_core/core", Level: common.LogLevel_DEBUG}
+	response, err := stub.UpdateLogLevel(ctx, &level)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestGetCoreInstance(t *testing.T) {
+	id := &voltha.ID{Id: "getCoreInstance"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.GetCoreInstance(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestGetLogicalDevice(t *testing.T) {
+	id := &voltha.ID{Id: "getLogicalDevice"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.GetLogicalDevice(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, id.Id, st.Message())
+	assert.Equal(t, codes.NotFound, st.Code())
+}
+
+func TestGetLogicalDevicePort(t *testing.T) {
+	id := &voltha.LogicalPortId{Id: "GetLogicalDevicePort"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.GetLogicalDevicePort(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDevicePorts(t *testing.T) {
+	id := &voltha.ID{Id: "listLogicalDevicePorts"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.ListLogicalDevicePorts(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDeviceFlows(t *testing.T) {
+	id := &voltha.ID{Id: "ListLogicalDeviceFlows"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.ListLogicalDeviceFlows(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDeviceFlowGroups(t *testing.T) {
+	id := &voltha.ID{Id: "ListLogicalDeviceFlowGroups"}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.ListLogicalDeviceFlowGroups(ctx, id)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListDevices(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, _ := stub.ListDevices(ctx, &empty.Empty{})
+	assert.Equal(t, len(response.Items), 0)
+}
+
+func TestListAdapters(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.ListAdapters(ctx, &empty.Empty{})
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDevices(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, _ := stub.ListLogicalDevices(ctx, &empty.Empty{})
+	assert.Equal(t, len(response.Items), 0)
+}
+
+func TestListCoreInstances(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	response, err := stub.ListCoreInstances(ctx, &empty.Empty{})
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestCreateDevice(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	device := &voltha.Device{Id: "newdevice"}
+	response, err := stub.CreateDevice(ctx, device)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &voltha.Device{Id: "newdevice"}, response)
+	assert.Nil(t, err)
+}
+
+func TestEnableDevice(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.ID{Id: "enabledevice"}
+	response, err := stub.EnableDevice(ctx, id)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestDisableDevice(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.ID{Id: "DisableDevice"}
+	response, err := stub.DisableDevice(ctx, id)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestRebootDevice(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.ID{Id: "RebootDevice"}
+	response, err := stub.RebootDevice(ctx, id)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestDeleteDevice(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.ID{Id: "DeleteDevice"}
+	response, err := stub.DeleteDevice(ctx, id)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestEnableLogicalDevicePort(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.LogicalPortId{Id: "EnableLogicalDevicePort"}
+	response, err := stub.EnableLogicalDevicePort(ctx, id)
+	if e, ok := status.FromError(err); ok {
+		log.Infow("response", log.Fields{"error": err, "errorcode": e.Code(), "msg": e.Message()})
+	}
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestDisableLogicalDevicePort(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	id := &voltha.LogicalPortId{Id: "DisableLogicalDevicePort"}
+	response, err := stub.DisableLogicalDevicePort(ctx, id)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestUpdateLogicalDeviceFlowGroupTable(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	flow := &openflow_13.FlowGroupTableUpdate{Id: "UpdateLogicalDeviceFlowGroupTable"}
+	response, err := stub.UpdateLogicalDeviceFlowGroupTable(ctx, flow)
+	log.Infow("response", log.Fields{"res": response, "error": err})
+	assert.Equal(t, &empty.Empty{}, response)
+	assert.Nil(t, err)
+}
+
+func TestGetImageDownloadStatus(t *testing.T) {
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+	img := &voltha.ImageDownload{Id: "GetImageDownloadStatus"}
+	response, err := stub.GetImageDownloadStatus(ctx, img)
+	assert.Nil(t, response)
+	st, _ := status.FromError(err)
+	assert.Equal(t, "UnImplemented", st.Message())
+}
+
+// TODO: complete the remaining tests
+
+func shutdown() {
+	conn.Close()
+}
+
+func TestMain(m *testing.M) {
+	setup()
+	code := m.Run()
+	shutdown()
+	os.Exit(code)
+}
diff --git a/rw_core/core/id.go b/rw_core/core/id.go
new file mode 100644
index 0000000..d5aebd5
--- /dev/null
+++ b/rw_core/core/id.go
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"crypto/rand"
+	"encoding/hex"
+	m "math/rand"
+)
+
+func randomHex(n int) (string, error) {
+	bytes := make([]byte, n)
+	if _, err := rand.Read(bytes); err != nil {
+		return "", err
+	}
+	return hex.EncodeToString(bytes), nil
+}
+
+// CreateDeviceId produces a device ID. DeviceId is 16 hex long - lower 12 hex is the device id.
+// TODO:  A cluster unique ID may be required
+func CreateDeviceId() string {
+	val, _ := randomHex(12)
+	return val
+}
+
+// CreateLogicalDeviceId is not used for now as the logical device ID is derived from the
+// OLT MAC address
+func CreateLogicalDeviceId() string {
+	// logical device id is 16 hex long - lower 12 hex is the logical device id.  For now just generate the 12 hex
+	val, _ := randomHex(12)
+	return val
+}
+
+// CreateLogicalPortId produces a random port ID for a logical device.   
+func CreateLogicalPortId() uint32 {
+	//	A logical port is a uint32
+	return m.Uint32()
+}
diff --git a/rw_core/core/logical_device_agent.go b/rw_core/core/logical_device_agent.go
new file mode 100644
index 0000000..5a9562a
--- /dev/null
+++ b/rw_core/core/logical_device_agent.go
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"github.com/gogo/protobuf/proto"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	ca "github.com/opencord/voltha-go/protos/core_adapter"
+	"github.com/opencord/voltha-go/protos/openflow_13"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"reflect"
+)
+
+type LogicalDeviceAgent struct {
+	logicalDeviceId string
+	lastData        *voltha.LogicalDevice
+	rootDeviceId    string
+	deviceMgr       *DeviceManager
+	ldeviceMgr      *LogicalDeviceManager
+	localDataProxy  *model.Proxy
+	exitChannel     chan int
+}
+
+func NewLogicalDeviceAgent(id string, device *voltha.Device, ldeviceMgr *LogicalDeviceManager, deviceMgr *DeviceManager,
+	ldProxy *model.Proxy) *LogicalDeviceAgent {
+	var agent LogicalDeviceAgent
+	agent.exitChannel = make(chan int, 1)
+	agent.logicalDeviceId = id
+	agent.rootDeviceId = device.Id
+	agent.deviceMgr = deviceMgr
+	agent.localDataProxy = ldProxy
+	agent.ldeviceMgr = ldeviceMgr
+	return &agent
+}
+
+func (agent *LogicalDeviceAgent) Start(ctx context.Context) error {
+	log.Info("starting-logical_device-agent")
+	//Build the logical device based on information retrieved from the device adapter
+	var switchCap *ca.SwitchCapability
+	var err error
+	if switchCap, err = agent.deviceMgr.getSwitchCapability(ctx, agent.rootDeviceId); err != nil {
+		log.Errorw("error-creating-logical-device", log.Fields{"error": err})
+		return err
+	}
+	ld := &voltha.LogicalDevice{Id: agent.logicalDeviceId, RootDeviceId: agent.rootDeviceId}
+	ld.Desc = (proto.Clone(switchCap.Desc)).(*openflow_13.OfpDesc)
+	ld.SwitchFeatures = (proto.Clone(switchCap.SwitchFeatures)).(*openflow_13.OfpSwitchFeatures)
+
+	//Add logical ports to the logical device based on the number of NNI ports discovered
+	//First get the default port capability - TODO:  each NNI port may have different capabilities,
+	//hence. may need to extract the port by the NNI port id defined by the adapter during device
+	//creation
+	var nniPorts *voltha.Ports
+	if nniPorts, err = agent.deviceMgr.getNNIPorts(ctx, agent.rootDeviceId); err != nil {
+		log.Errorw("error-creating-logical-port", log.Fields{"error": err})
+	}
+	var portCap *ca.PortCapability
+	for _, port := range nniPorts.Items {
+		log.Infow("NNI PORTS", log.Fields{"NNI": port})
+		if portCap, err = agent.deviceMgr.getPortCapability(ctx, agent.rootDeviceId, port.PortNo); err != nil {
+			log.Errorw("error-creating-logical-device", log.Fields{"error": err})
+			return err
+		}
+
+		lp := (proto.Clone(portCap.Port)).(*voltha.LogicalPort)
+		ld.Ports = append(ld.Ports, lp)
+	}
+	// Save the logical device
+	if added := agent.localDataProxy.Add("/logical_devices", ld, ""); added == nil {
+		log.Errorw("failed-to-add-logical-device", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+	} else {
+		log.Debugw("logicaldevice-created", log.Fields{"logicaldeviceId": agent.logicalDeviceId})
+	}
+
+	return nil
+}
+
+func (agent *LogicalDeviceAgent) addUNILogicalPort(ctx context.Context, childDevice *voltha.Device, portNo uint32) error {
+	log.Info("addUNILogicalPort-start")
+	// Build the logical device based on information retrieved from the device adapter
+	var portCap *ca.PortCapability
+	var err error
+	if portCap, err = agent.deviceMgr.getPortCapability(ctx, childDevice.Id, portNo); err != nil {
+		log.Errorw("error-creating-logical-port", log.Fields{"error": err})
+		return err
+	}
+	// Get stored logical device
+	if ldevice, err := agent.ldeviceMgr.getLogicalDevice(agent.logicalDeviceId); err != nil {
+		return status.Error(codes.NotFound, agent.logicalDeviceId)
+	} else {
+		cloned := reflect.ValueOf(ldevice).Elem().Interface().(voltha.LogicalDevice)
+		lp := (proto.Clone(portCap.Port)).(*voltha.LogicalPort)
+		cloned.Ports = append(cloned.Ports, lp)
+		afterUpdate := agent.localDataProxy.Update("/logical_devices/"+agent.logicalDeviceId, &cloned, false, "")
+		if afterUpdate == nil {
+			return status.Errorf(codes.Internal, "failed-add-UNI-port:%s", agent.logicalDeviceId)
+		}
+		return nil
+	}
+}
+
+func (agent *LogicalDeviceAgent) Stop(ctx context.Context) {
+	log.Info("stopping-logical_device-agent")
+	agent.exitChannel <- 1
+	log.Info("logical_device-agent-stopped")
+}
+
+func (agent *LogicalDeviceAgent) getLogicalDevice(ctx context.Context) *voltha.LogicalDevice {
+	log.Debug("getLogicalDevice")
+	cp := proto.Clone(agent.lastData)
+	return cp.(*voltha.LogicalDevice)
+}
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
new file mode 100644
index 0000000..61f96e8
--- /dev/null
+++ b/rw_core/core/logical_device_manager.go
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package core
+
+import (
+	"context"
+	"errors"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/kafka"
+	"github.com/opencord/voltha-go/protos/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"reflect"
+	"strings"
+	"sync"
+)
+
+type LogicalDeviceManager struct {
+	logicalDeviceAgents        map[string]*LogicalDeviceAgent
+	deviceMgr                  *DeviceManager
+	adapterProxy               *AdapterProxy
+	kafkaProxy                 *kafka.KafkaMessagingProxy
+	localDataProxy             *model.Proxy
+	exitChannel                chan int
+	lockLogicalDeviceAgentsMap sync.RWMutex
+}
+
+func NewLogicalDeviceManager(deviceMgr *DeviceManager, kafkaProxy *kafka.KafkaMessagingProxy, ldProxy *model.Proxy) *LogicalDeviceManager {
+	var logicalDeviceMgr LogicalDeviceManager
+	logicalDeviceMgr.exitChannel = make(chan int, 1)
+	logicalDeviceMgr.logicalDeviceAgents = make(map[string]*LogicalDeviceAgent)
+	logicalDeviceMgr.deviceMgr = deviceMgr
+	logicalDeviceMgr.kafkaProxy = kafkaProxy
+	logicalDeviceMgr.localDataProxy = ldProxy
+	logicalDeviceMgr.lockLogicalDeviceAgentsMap = sync.RWMutex{}
+	return &logicalDeviceMgr
+}
+
+func (ldMgr *LogicalDeviceManager) Start(ctx context.Context) {
+	log.Info("starting-logical-device-manager")
+	log.Info("logical-device-manager-started")
+}
+
+func (ldMgr *LogicalDeviceManager) Stop(ctx context.Context) {
+	log.Info("stopping-logical-device-manager")
+	ldMgr.exitChannel <- 1
+	log.Info("logical-device-manager-stopped")
+}
+
+func (ldMgr *LogicalDeviceManager) addLogicalDeviceAgentToMap(agent *LogicalDeviceAgent) {
+	ldMgr.lockLogicalDeviceAgentsMap.Lock()
+	defer ldMgr.lockLogicalDeviceAgentsMap.Unlock()
+	if _, exist := ldMgr.logicalDeviceAgents[agent.logicalDeviceId]; !exist {
+		ldMgr.logicalDeviceAgents[agent.logicalDeviceId] = agent
+	}
+}
+
+func (ldMgr *LogicalDeviceManager) getLogicalDeviceAgent(logicalDeviceId string) *LogicalDeviceAgent {
+	ldMgr.lockLogicalDeviceAgentsMap.Lock()
+	defer ldMgr.lockLogicalDeviceAgentsMap.Unlock()
+	if agent, ok := ldMgr.logicalDeviceAgents[logicalDeviceId]; ok {
+		return agent
+	}
+	return nil
+}
+
+func (ldMgr *LogicalDeviceManager) getLogicalDevice(id string) (*voltha.LogicalDevice, error) {
+	log.Debugw("getlogicalDevice-start", log.Fields{"logicaldeviceid": id})
+	logicalDevice := ldMgr.localDataProxy.Get("/logical_devices/"+id, 1, false, "")
+	if logicalDevice != nil {
+		cloned := reflect.ValueOf(logicalDevice).Elem().Interface().(voltha.LogicalDevice)
+		return &cloned, nil
+	}
+	return nil, status.Errorf(codes.NotFound, "%s", id)
+}
+
+func (ldMgr *LogicalDeviceManager) listLogicalDevices() (*voltha.LogicalDevices, error) {
+	log.Debug("listLogicalDevices-start")
+	result := &voltha.LogicalDevices{}
+	ldMgr.lockLogicalDeviceAgentsMap.Lock()
+	defer ldMgr.lockLogicalDeviceAgentsMap.Unlock()
+	for _, agent := range ldMgr.logicalDeviceAgents {
+		logicalDevice := ldMgr.localDataProxy.Get("/logical_devices/"+agent.logicalDeviceId, 1, false, "")
+		if logicalDevice != nil {
+			cloned := reflect.ValueOf(logicalDevice).Elem().Interface().(voltha.LogicalDevice)
+			result.Items = append(result.Items, &cloned)
+		}
+	}
+	return result, nil
+}
+
+func (ldMgr *LogicalDeviceManager) CreateLogicalDevice(ctx context.Context, device *voltha.Device) (*string, error) {
+	log.Infow("creating-logical-device-start", log.Fields{"deviceId": device.Id})
+	// Sanity check
+	if !device.Root {
+		return nil, errors.New("Device-not-root")
+	}
+
+	// Create a logical device agent - the logical device Id is based on the mac address of the device
+	// For now use the serial number - it may contain any combination of alphabetic characters and numbers,
+	// with length varying from eight characters to a maximum of 14 characters.   Mac Address is part of oneof
+	// in the Device model.  May need to be moved out.
+	macAddress := device.MacAddress
+	id := strings.Replace(macAddress, ":", "", -1)
+	log.Debugw("setting-logical-device-id", log.Fields{"logicaldeviceId": id})
+
+	agent := NewLogicalDeviceAgent(id, device, ldMgr, ldMgr.deviceMgr, ldMgr.localDataProxy)
+	ldMgr.addLogicalDeviceAgentToMap(agent)
+	go agent.Start(ctx)
+
+	log.Info("creating-logical-device-ends")
+	return &id, nil
+}
+
+func (ldMgr *LogicalDeviceManager) AddUNILogicalPort(ctx context.Context, childDevice *voltha.Device) error {
+	log.Infow("AddUNILogicalPort-start", log.Fields{"deviceId": childDevice.Id})
+	// Sanity check
+	if childDevice.Root {
+		return errors.New("Device-root")
+	}
+
+	// Get the logical device id parent device
+	parentId := childDevice.ParentId
+	logDeviceId := ldMgr.deviceMgr.GetParentDeviceId(parentId)
+
+	log.Infow("AddUNILogicalPort", log.Fields{"logDeviceId": logDeviceId, "parentId": parentId})
+
+	if agent := ldMgr.getLogicalDeviceAgent(*logDeviceId); agent != nil {
+		return agent.addUNILogicalPort(ctx, childDevice, childDevice.ProxyAddress.ChannelId)
+	}
+	return status.Errorf(codes.NotFound, "%s", childDevice.Id)
+}
diff --git a/rw_core/core/requestHandlerProxy.go b/rw_core/core/requestHandlerProxy.go
deleted file mode 100644
index 1582906..0000000
--- a/rw_core/core/requestHandlerProxy.go
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package core
-
-import (
-	"errors"
-	"github.com/golang/protobuf/ptypes"
-	"github.com/opencord/voltha-go/common/log"
-	ca "github.com/opencord/voltha-go/protos/core_adapter"
-	"github.com/opencord/voltha-go/protos/voltha"
-)
-
-type RequestHandlerProxy struct {
-	TestMode bool
-}
-
-func (rhp *RequestHandlerProxy) GetDevice(args []*ca.Argument) (error, *voltha.Device) {
-	if len(args) != 1 {
-		log.Warn("invalid-number-of-args", log.Fields{"args": args})
-		err := errors.New("invalid-number-of-args")
-		return err, nil
-	}
-	pID := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err, nil
-	}
-	log.Debugw("GetDevice", log.Fields{"deviceId": pID.Val})
-	// TODO process the request
-
-	if rhp.TestMode { // Execute only for test cases
-		return nil, &voltha.Device{Id: pID.Val}
-	}
-	return nil, nil
-}
-
-func (rhp *RequestHandlerProxy) GetChildDevice(args []*ca.Argument) (error, *voltha.Device) {
-	if len(args) < 1 {
-		log.Warn("invalid-number-of-args", log.Fields{"args": args})
-		err := errors.New("invalid-number-of-args")
-		return err, nil
-	}
-	pID := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err, nil
-	}
-	// TODO decompose the other parameteres for matching criteria and process
-	log.Debugw("GetChildDevice", log.Fields{"deviceId": pID.Val})
-
-	if rhp.TestMode { // Execute only for test cases
-		return nil, &voltha.Device{Id: pID.Val}
-	}
-	return nil, nil
-}
-
-func (rhp *RequestHandlerProxy) GetPorts(args []*ca.Argument) (error, *voltha.Ports) {
-	if len(args) != 2 {
-		log.Warn("invalid-number-of-args", log.Fields{"args": args})
-		err := errors.New("invalid-number-of-args")
-		return err, nil
-	}
-	pID := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err, nil
-	}
-	// Porttype is an enum sent as an integer proto
-	pt := &ca.IntType{}
-	if err := ptypes.UnmarshalAny(args[1].Value, pt); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err, nil
-	}
-
-	// TODO decompose the other parameteres for matching criteria
-	log.Debugw("GetPorts", log.Fields{"deviceID": pID.Val, "portype": pt.Val})
-
-	if rhp.TestMode { // Execute only for test cases
-		aPort := &voltha.Port{Label: "test_port"}
-		allPorts := &voltha.Ports{}
-		allPorts.Items = append(allPorts.Items, aPort)
-		return nil, allPorts
-	}
-	return nil, nil
-
-}
-
-func (rhp *RequestHandlerProxy) GetChildDevices(args []*ca.Argument) (error, *voltha.Device) {
-	if len(args) != 1 {
-		log.Warn("invalid-number-of-args", log.Fields{"args": args})
-		err := errors.New("invalid-number-of-args")
-		return err, nil
-	}
-	pID := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err, nil
-	}
-	// TODO decompose the other parameteres for matching criteria and process
-	log.Debugw("GetChildDevice", log.Fields{"deviceId": pID.Val})
-
-	if rhp.TestMode { // Execute only for test cases
-		return nil, &voltha.Device{Id: pID.Val}
-	}
-	return nil, nil
-}
-
-// ChildDeviceDetected is invoked when a child device is detected.  The following
-// parameters are expected:
-// {parent_device_id, parent_port_no, child_device_type, proxy_address, admin_state, **kw)
-func (rhp *RequestHandlerProxy) ChildDeviceDetected(args []*ca.Argument) error {
-	if len(args) < 5 {
-		log.Warn("invalid-number-of-args", log.Fields{"args": args})
-		err := errors.New("invalid-number-of-args")
-		return err
-	}
-
-	pID := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[0].Value, pID); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err
-	}
-	portNo := &ca.IntType{}
-	if err := ptypes.UnmarshalAny(args[1].Value, portNo); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err
-	}
-	dt := &ca.StrType{}
-	if err := ptypes.UnmarshalAny(args[2].Value, dt); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err
-	}
-	pAddr := &voltha.Device_ProxyAddress{}
-	if err := ptypes.UnmarshalAny(args[3].Value, pAddr); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err
-	}
-	adminState := &ca.IntType{}
-	if err := ptypes.UnmarshalAny(args[4].Value, adminState); err != nil {
-		log.Warnw("cannot-unmarshal-argument", log.Fields{"error": err})
-		return err
-	}
-
-	// Need to decode the other params - in this case the key will represent the proto type
-	// TODO decompose the other parameteres for matching criteria and process
-	log.Debugw("ChildDeviceDetected", log.Fields{"deviceId": pID.Val, "portNo": portNo.Val,
-		"deviceType": dt.Val, "proxyAddress": pAddr, "adminState": adminState})
-
-	if rhp.TestMode { // Execute only for test cases
-		return nil
-	}
-	return nil
-}