[VOL-4291] Rw-core updates for gRPC migration

Change-Id: I8d5a554409115b29318089671ca4e1ab3fa98810
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index 116dc71..9543a7e 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -19,15 +19,29 @@
 import (
 	"context"
 	"fmt"
-	"github.com/opencord/voltha-protos/v4/go/extension"
 	"strconv"
 	"strings"
 	"sync"
+	"time"
 
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
-	ic "github.com/opencord/voltha-protos/v4/go/inter_container"
-	of "github.com/opencord/voltha-protos/v4/go/openflow_13"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	"github.com/golang/protobuf/ptypes/empty"
+	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
+	"github.com/opencord/voltha-protos/v5/go/adapter_services"
+	"github.com/opencord/voltha-protos/v5/go/common"
+	"github.com/opencord/voltha-protos/v5/go/core"
+	"google.golang.org/grpc"
+
+	"github.com/opencord/voltha-protos/v5/go/extension"
+	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+	"github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+const (
+	numONUPerOLT      = 4
+	startingUNIPortNo = 100
 )
 
 func macAddressToUint32Array(mac string) []uint32 {
@@ -44,27 +58,55 @@
 	return result
 }
 
+// GetNumONUPerOLT returns number of ONUs per OLT
+func GetNumONUPerOLT() int {
+	return numONUPerOLT
+}
+
+// Returns the starting UNI port number
+func GetStartingUNIPortNo() int {
+	return startingUNIPortNo
+}
+
 // Adapter represents adapter attributes
 type Adapter struct {
-	coreProxy        adapterif.CoreProxy
-	flows            map[uint64]*voltha.OfpFlowStats
-	flowLock         sync.RWMutex
-	devices          map[string]*voltha.Device
-	deviceLock       sync.RWMutex
-	failFlowAdd      bool
-	failFlowDelete   bool
-	failDeleteDevice bool
+	flows                map[string]map[uint64]*openflow_13.OfpFlowStats
+	flowLock             sync.RWMutex
+	devices              map[string]*voltha.Device
+	deviceLock           sync.RWMutex
+	failFlowAdd          map[string]bool
+	failFlowAddLock      sync.RWMutex
+	failFlowDelete       map[string]bool
+	failFlowDeleteLock   sync.RWMutex
+	failDeleteDevice     map[string]bool
+	failDeleteDeviceLock sync.RWMutex
+	coreEnpoint          string
+	coreClient           *vgrpc.Client
+	serviceEndpoint      string
+	DeviceType           string
+	vendor               string
+	Probe                *probe.Probe
 }
 
 // NewAdapter creates adapter instance
-func NewAdapter(cp adapterif.CoreProxy) *Adapter {
+func NewAdapter(serviceEndpoint, coreEndpoint, deviceType, vendor string) *Adapter {
 	return &Adapter{
-		flows:     map[uint64]*voltha.OfpFlowStats{},
-		devices:   map[string]*voltha.Device{},
-		coreProxy: cp,
+		flows:            map[string]map[uint64]*openflow_13.OfpFlowStats{},
+		devices:          map[string]*voltha.Device{},
+		failFlowAdd:      map[string]bool{},
+		failFlowDelete:   map[string]bool{},
+		failDeleteDevice: map[string]bool{},
+		coreEnpoint:      coreEndpoint,
+		serviceEndpoint:  serviceEndpoint,
+		DeviceType:       deviceType,
+		vendor:           vendor,
 	}
 }
 
+func (ta *Adapter) IsReady() bool {
+	return ta.Probe.IsReady()
+}
+
 func (ta *Adapter) storeDevice(d *voltha.Device) {
 	ta.deviceLock.Lock()
 	defer ta.deviceLock.Unlock()
@@ -83,255 +125,287 @@
 	ta.storeDevice(d)
 }
 
-// Adapter_descriptor -
-func (ta *Adapter) Adapter_descriptor(ctx context.Context) error { // nolint
-	return nil
+func (ta *Adapter) GetEndPoint() string {
+	return ta.serviceEndpoint
 }
 
-// Device_types -
-func (ta *Adapter) Device_types(ctx context.Context) (*voltha.DeviceTypes, error) { // nolint
-	return nil, nil
-}
-
-// Health -
-func (ta *Adapter) Health(ctx context.Context) (*voltha.HealthStatus, error) {
-	return nil, nil
-}
-
-// Adopt_device -
-func (ta *Adapter) Adopt_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Reconcile_device -
-func (ta *Adapter) Reconcile_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Abandon_device -
-func (ta *Adapter) Abandon_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Disable_device -
-func (ta *Adapter) Disable_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Reenable_device -
-func (ta *Adapter) Reenable_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Reboot_device -
-func (ta *Adapter) Reboot_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Self_test_device -
-func (ta *Adapter) Self_test_device(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
-}
-
-// Delete_device -
-func (ta *Adapter) Delete_device(ctx context.Context, device *voltha.Device) error { // nolint
-	if ta.failDeleteDevice {
-		return fmt.Errorf("delete-device-failure")
+func (ta *Adapter) GetCoreClient() (core.CoreServiceClient, error) {
+	// Wait until the Core is up and running
+	for {
+		if ta.coreClient != nil {
+			client, err := ta.coreClient.GetClient()
+			if err != nil {
+				logger.Infow(context.Background(), "got-error-core-client", log.Fields{"error": err})
+				time.Sleep(1 * time.Second)
+				continue
+			}
+			c, ok := client.(core.CoreServiceClient)
+			if ok {
+				logger.Debug(context.Background(), "got-valid-client")
+				return c, nil
+			}
+		}
+		logger.Info(context.Background(), "waiting-for-grpc-core-client")
+		time.Sleep(1 * time.Second)
 	}
-	return nil
 }
 
-// Get_device_details -
-func (ta *Adapter) Get_device_details(ctx context.Context, device *voltha.Device) error { // nolint
-	return nil
+// Helper methods
+// startGRPCService creates the grpc service handlers, registers it to the grpc server and starts the server
+func (ta *Adapter) startGRPCService(ctx context.Context, server *vgrpc.GrpcServer, handler adapter_services.AdapterServiceServer, serviceName string) {
+	logger.Infow(ctx, "service-created", log.Fields{"service": serviceName})
+
+	server.AddService(func(gs *grpc.Server) { adapter_services.RegisterAdapterServiceServer(gs, handler) })
+	logger.Infow(ctx, "service-added", log.Fields{"service": serviceName})
+
+	ta.Probe.UpdateStatus(ctx, serviceName, probe.ServiceStatusRunning)
+	logger.Infow(ctx, "service-started", log.Fields{"service": serviceName})
+
+	// Note that there is a small window here in which the core could return its status as ready,
+	// when it really isn't.  This is unlikely to cause issues, as the delay is incredibly short.
+	server.Start(ctx)
+	ta.Probe.UpdateStatus(ctx, serviceName, probe.ServiceStatusStopped)
 }
 
-// Update_flows_bulk -
-func (ta *Adapter) Update_flows_bulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { // nolint
-	return nil
+func setAndTestCoreServiceHandler(ctx context.Context, conn *grpc.ClientConn) interface{} {
+	svc := core.NewCoreServiceClient(conn)
+	if h, err := svc.GetHealthStatus(ctx, &empty.Empty{}); err != nil || h.State != voltha.HealthStatus_HEALTHY {
+		return nil
+	}
+	return svc
 }
 
-// Update_flows_incrementally mocks the incremental flow update
-func (ta *Adapter) Update_flows_incrementally(ctx context.Context, device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { // nolint
+// gRPC service
+func (ta *Adapter) GetHealthStatus(ctx context.Context, empty *empty.Empty) (*voltha.HealthStatus, error) {
+	return &voltha.HealthStatus{State: voltha.HealthStatus_HEALTHY}, nil
+}
+
+// Device
+
+func (ta *Adapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) ReconcileDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) DeleteDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	ta.failDeleteDeviceLock.RLock()
+	haveToFail, ok := ta.failDeleteDevice[device.Id]
+	if ok && haveToFail {
+		ta.failDeleteDeviceLock.RUnlock()
+		return nil, fmt.Errorf("delete-device-failure")
+	}
+	ta.failDeleteDeviceLock.RUnlock()
+	if ok {
+		ta.RemoveDevice(device.Id)
+	}
+	logger.Debugw(ctx, "device-deleted-in-adapter", log.Fields{"device-id": device.Id})
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) SelfTestDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) ChildDeviceLost(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) {
+	return nil, nil
+}
+
+// Ports
+
+func (ta *Adapter) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+// Flows
+func (ta *Adapter) UpdateFlowsBulk(ctx context.Context, flows *ic.BulkFlows) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
+}
+
+func (ta *Adapter) UpdateFlowsIncrementally(ctx context.Context, incrFlows *ic.IncrementalFlows) (*empty.Empty, error) {
 	ta.flowLock.Lock()
 	defer ta.flowLock.Unlock()
 
-	if flows.ToAdd != nil && len(flows.ToAdd.Items) > 0 {
-		if ta.failFlowAdd {
-			return fmt.Errorf("flow-add-error")
+	if _, ok := ta.flows[incrFlows.Device.Id]; !ok {
+		ta.flows[incrFlows.Device.Id] = map[uint64]*openflow_13.OfpFlowStats{}
+	}
+
+	if incrFlows.Flows.ToAdd != nil && len(incrFlows.Flows.ToAdd.Items) > 0 {
+		ta.failFlowAddLock.RLock()
+		if haveToFail, ok := ta.failFlowAdd[incrFlows.Device.Id]; ok && haveToFail {
+			ta.failFlowAddLock.RUnlock()
+			return nil, fmt.Errorf("flow-add-error")
 		}
-		for _, f := range flows.ToAdd.Items {
-			ta.flows[f.Id] = f
+		ta.failFlowAddLock.RUnlock()
+		for _, f := range incrFlows.Flows.ToAdd.Items {
+			ta.flows[incrFlows.Device.Id][f.Id] = f
 		}
 	}
-	if flows.ToRemove != nil && len(flows.ToRemove.Items) > 0 {
-		if ta.failFlowDelete {
-			return fmt.Errorf("flow-delete-error")
+	if incrFlows.Flows.ToRemove != nil && len(incrFlows.Flows.ToRemove.Items) > 0 {
+		ta.failFlowDeleteLock.RLock()
+		if haveToFail, ok := ta.failFlowDelete[incrFlows.Device.Id]; ok && haveToFail {
+			ta.failFlowDeleteLock.RUnlock()
+			return nil, fmt.Errorf("flow-delete-error")
 		}
-		for _, f := range flows.ToRemove.Items {
-			delete(ta.flows, f.Id)
+		ta.failFlowDeleteLock.RUnlock()
+		for _, f := range incrFlows.Flows.ToRemove.Items {
+			delete(ta.flows[incrFlows.Device.Id], f.Id)
 		}
 	}
-	return nil
+	return &empty.Empty{}, nil
 }
 
-// Update_pm_config -
-func (ta *Adapter) Update_pm_config(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error { // nolint
-	return nil
+//Packets
+func (ta *Adapter) SendPacketOut(ctx context.Context, packet *ic.PacketOut) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
 }
 
-// Receive_packet_out -
-func (ta *Adapter) Receive_packet_out(ctx context.Context, deviceID string, egressPortNo int, msg *of.OfpPacketOut) error { // nolint
-	return nil
+// PM
+func (ta *Adapter) UpdatePmConfig(ctx context.Context, configs *ic.PmConfigsInfo) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
 }
 
-// Suppress_event -
-func (ta *Adapter) Suppress_event(ctx context.Context, filter *voltha.EventFilter) error { // nolint
-	return nil
+// Image
+func (ta *Adapter) DownloadOnuImage(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) {
+	return &voltha.DeviceImageResponse{}, nil
 }
 
-// Unsuppress_event -
-func (ta *Adapter) Unsuppress_event(ctx context.Context, filter *voltha.EventFilter) error { // nolint
-	return nil
+func (ta *Adapter) GetOnuImageStatus(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+	return &voltha.DeviceImageResponse{}, nil
 }
 
-// Get_ofp_device_info -
-func (ta *Adapter) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
-	return &ic.SwitchCapability{
-		Desc: &of.OfpDesc{
-			HwDesc:    "adapter_mock",
-			SwDesc:    "adapter_mock",
-			SerialNum: "000000000",
-		},
-		SwitchFeatures: &of.OfpSwitchFeatures{
-			NBuffers: 256,
-			NTables:  2,
-			Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS |
-				of.OfpCapabilities_OFPC_TABLE_STATS |
-				of.OfpCapabilities_OFPC_PORT_STATS |
-				of.OfpCapabilities_OFPC_GROUP_STATS),
-		},
-	}, nil
+func (ta *Adapter) AbortOnuImageUpgrade(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+	return &voltha.DeviceImageResponse{}, nil
 }
 
-// Process_inter_adapter_message -
-func (ta *Adapter) Process_inter_adapter_message(ctx context.Context, msg *ic.InterAdapterMessage) error { // nolint
-	return nil
+func (ta *Adapter) GetOnuImages(ctx context.Context, id *common.ID) (*voltha.OnuImages, error) {
+	return &voltha.OnuImages{}, nil
 }
 
-// Download_image -
-func (ta *Adapter) Download_image(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
+func (ta *Adapter) ActivateOnuImage(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+	return &voltha.DeviceImageResponse{}, nil
+}
+
+func (ta *Adapter) CommitOnuImage(ctx context.Context, request *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
+	return &voltha.DeviceImageResponse{}, nil
+}
+
+// Deprecated image APIs
+func (ta *Adapter) DownloadImage(ctx context.Context, in *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
+	return &voltha.ImageDownload{}, nil
+}
+
+func (ta *Adapter) GetImageDownloadStatus(ctx context.Context, in *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
+	return &voltha.ImageDownload{}, nil
+}
+
+func (ta *Adapter) CancelImageDownload(ctx context.Context, in *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
+	return &voltha.ImageDownload{}, nil
+}
+
+func (ta *Adapter) ActivateImageUpdate(ctx context.Context, in *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
+	return &voltha.ImageDownload{}, nil
+}
+
+func (ta *Adapter) RevertImageUpdate(ctx context.Context, in *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
+	return &voltha.ImageDownload{}, nil
+}
+
+// OMCI test
+func (ta *Adapter) StartOmciTest(ctx context.Context, test *ic.OMCITest) (*voltha.TestResponse, error) {
 	return nil, nil
 }
 
-// Get_image_download_status -
-func (ta *Adapter) Get_image_download_status(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
-	return nil, nil
+// Events
+func (ta *Adapter) SuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
 }
 
-// Cancel_image_download -
-func (ta *Adapter) Cancel_image_download(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
-	return nil, nil
+func (ta *Adapter) UnSuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
 }
 
-// Activate_image_update -
-func (ta *Adapter) Activate_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
-	return nil, nil
+func (ta *Adapter) SimulateAlarm(context.Context, *ic.SimulateAlarmMessage) (*common.OperationResp, error) {
+	return &common.OperationResp{}, nil
 }
 
-// Revert_image_update -
-func (ta *Adapter) Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
-	return nil, nil
+func (ta *Adapter) GetExtValue(context.Context, *ic.GetExtValueMessage) (*common.ReturnValues, error) {
+	return &common.ReturnValues{}, nil
 }
 
-// Enable_port -
-func (ta *Adapter) Enable_port(ctx context.Context, deviceId string, port *voltha.Port) error { //nolint
-	return nil
+func (ta *Adapter) SetExtValue(context.Context, *ic.SetExtValueMessage) (*empty.Empty, error) {
+	return &empty.Empty{}, nil
 }
 
-// Disable_port -
-func (ta *Adapter) Disable_port(ctx context.Context, deviceId string, port *voltha.Port) error { //nolint
-	return nil
+func (ta *Adapter) GetSingleValue(context.Context, *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
+	return &extension.SingleGetValueResponse{}, nil
 }
 
-// Child_device_lost -
-func (ta *Adapter) Child_device_lost(ctx context.Context, childDevice *voltha.Device) error { //nolint
-	return nil
+func (ta *Adapter) SetSingleValue(context.Context, *extension.SingleSetValueRequest) (*extension.SingleSetValueResponse, error) {
+	return &extension.SingleSetValueResponse{}, nil
 }
 
-// Start_omci_test
-func (ta *Adapter) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { //nolint
-	return nil, nil
-}
-
-func (ta *Adapter) Get_ext_value(ctx context.Context, deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error) { //nolint
-	return nil, nil
-}
-
-// Single_get_value_request retrieves a single value.
-func (ta *Adapter) Single_get_value_request(ctx context.Context, // nolint
-	request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
-	return nil, nil
-}
-
+// APIs for test ONLY
 // GetFlowCount returns the total number of flows presently under this adapter
-func (ta *Adapter) GetFlowCount() int {
+func (ta *Adapter) GetFlowCount(deviceID string) int {
 	ta.flowLock.RLock()
 	defer ta.flowLock.RUnlock()
 
-	return len(ta.flows)
+	if _, ok := ta.flows[deviceID]; ok {
+		return len(ta.flows[deviceID])
+	}
+	return 0
 }
 
-// ClearFlows removes all flows in this adapter
-func (ta *Adapter) ClearFlows() {
+// RemoveDevice removes all flows in this adapter
+func (ta *Adapter) RemoveDevice(deviceID string) {
 	ta.flowLock.Lock()
 	defer ta.flowLock.Unlock()
+	ta.failFlowAddLock.Lock()
+	defer ta.failFlowAddLock.Unlock()
+	ta.failFlowDeleteLock.Lock()
+	defer ta.failFlowDeleteLock.Unlock()
 
-	ta.flows = map[uint64]*voltha.OfpFlowStats{}
+	delete(ta.flows, deviceID)
+	delete(ta.failFlowAdd, deviceID)
+	delete(ta.failFlowDelete, deviceID)
 }
 
 // SetFlowAction sets the adapter action on addition and deletion of flows
-func (ta *Adapter) SetFlowAction(failFlowAdd, failFlowDelete bool) {
-	ta.failFlowAdd = failFlowAdd
-	ta.failFlowDelete = failFlowDelete
+func (ta *Adapter) SetFlowAction(deviceID string, failFlowAdd, failFlowDelete bool) {
+	ta.failFlowAddLock.Lock()
+	defer ta.failFlowAddLock.Unlock()
+	ta.failFlowDeleteLock.Lock()
+	defer ta.failFlowDeleteLock.Unlock()
+	ta.failFlowAdd[deviceID] = failFlowAdd
+	ta.failFlowDelete[deviceID] = failFlowDelete
 }
 
 // SetDeleteAction sets the adapter action on delete device
-func (ta *Adapter) SetDeleteAction(failDeleteDevice bool) {
-	ta.failDeleteDevice = failDeleteDevice
-}
-
-// Download_onu_image -
-func (ta *Adapter) Download_onu_image(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	return nil, nil
-}
-
-// Get_onu_image_status -
-func (ta *Adapter) Get_onu_image_status(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	return nil, nil
-}
-
-// Abort_onu_image_upgrade -
-func (ta *Adapter) Abort_onu_image_upgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	return nil, nil
-}
-
-// Get_onu_images -
-func (ta *Adapter) Get_onu_images(ctx context.Context, deviceID string) (*voltha.OnuImages, error) { //nolint
-	return nil, nil
-}
-
-// Activate_onu_image -
-func (ta *Adapter) Activate_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	return nil, nil
-}
-
-// Commit_onu_image -
-func (ta *Adapter) Commit_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	return nil, nil
-}
-
-// Process_tech_profile_instance_request -
-func (ta *Adapter) Process_tech_profile_instance_request(ctx context.Context, msg *ic.InterAdapterTechProfileInstanceRequestMessage) *ic.InterAdapterTechProfileDownloadMessage { //nolint
-	return nil
+func (ta *Adapter) SetDeleteAction(deviceID string, failDeleteDevice bool) {
+	ta.failDeleteDeviceLock.Lock()
+	defer ta.failDeleteDeviceLock.Unlock()
+	ta.failDeleteDevice[deviceID] = failDeleteDevice
 }
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index 6c8b186..b0ff711 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -20,58 +20,131 @@
 	"context"
 	"errors"
 	"fmt"
-	"github.com/opencord/voltha-protos/v4/go/extension"
+	"strconv"
 	"strings"
 
+	"github.com/golang/protobuf/ptypes/empty"
+	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
+	"github.com/opencord/voltha-protos/v5/go/common"
+	"github.com/opencord/voltha-protos/v5/go/extension"
+	"github.com/phayes/freeport"
+
 	"github.com/gogo/protobuf/proto"
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters"
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
-	com "github.com/opencord/voltha-lib-go/v5/pkg/adapters/common"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
-	ic "github.com/opencord/voltha-protos/v4/go/inter_container"
-	of "github.com/opencord/voltha-protos/v4/go/openflow_13"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	com "github.com/opencord/voltha-lib-go/v7/pkg/adapters/common"
+	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+	of "github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
-const (
-	numONUPerOLT      = 4
-	startingUNIPortNo = 100
-)
-
-// static implementation check
-var _ adapters.IAdapter = &OLTAdapter{}
-
 // OLTAdapter represent OLT adapter
 type OLTAdapter struct {
 	*Adapter
+	ChildDeviceType string
+	childVendor     string
+	grpcServer      *vgrpc.GrpcServer
 }
 
 // NewOLTAdapter - creates OLT adapter instance
-func NewOLTAdapter(ctx context.Context, cp adapterif.CoreProxy) *OLTAdapter {
-	return &OLTAdapter{
-		Adapter: NewAdapter(cp),
+func NewOLTAdapter(ctx context.Context, coreEndpoint string, deviceType string, vendor string, childDeviceType, childVendor string) *OLTAdapter {
+	// Get an available  port
+	grpcPort, err := freeport.GetFreePort()
+	if err != nil {
+		logger.Fatalw(ctx, "no-free-port", log.Fields{"error": err})
 	}
+
+	// start gRPC handler
+	listeningAddress := fmt.Sprintf("127.0.0.1:%s", strconv.Itoa(grpcPort))
+	oltAdapter := &OLTAdapter{Adapter: NewAdapter(listeningAddress, coreEndpoint, deviceType, vendor),
+		ChildDeviceType: childDeviceType, childVendor: childVendor}
+
+	oltAdapter.start(ctx)
+	return oltAdapter
+}
+
+func (oltA *OLTAdapter) oltRestarted(ctx context.Context, endPoint string) error {
+	logger.Errorw(ctx, "remote-restarted", log.Fields{"endpoint": endPoint})
+	return nil
+}
+
+func (oltA *OLTAdapter) start(ctx context.Context) {
+
+	// Set up the probe service
+	oltA.Probe = &probe.Probe{}
+	probePort, err := freeport.GetFreePort()
+	if err != nil {
+		logger.Fatal(ctx, "Cannot get a freeport for probePort")
+	}
+	probeAddress := "127.0.0.1:" + strconv.Itoa(probePort)
+	go oltA.Probe.ListenAndServe(ctx, probeAddress)
+
+	probeCtx := context.WithValue(ctx, probe.ProbeContextKey, oltA.Probe)
+
+	oltA.Probe.RegisterService(ctx, "olt-grpc-service", oltA.coreEnpoint)
+
+	oltA.grpcServer = vgrpc.NewGrpcServer(oltA.serviceEndpoint, nil, false, nil)
+
+	logger.Debugw(ctx, "OLTAdapter-address", log.Fields{"address": oltA.serviceEndpoint})
+
+	go oltA.startGRPCService(ctx, oltA.grpcServer, oltA, "olt-grpc-service")
+
+	// Establish grpc connection to Core
+	if oltA.coreClient, err = vgrpc.NewClient(oltA.coreEnpoint,
+		oltA.oltRestarted,
+		vgrpc.ActivityCheck(true)); err != nil {
+		logger.Fatal(ctx, "grpc-client-not-created")
+	}
+
+	go oltA.coreClient.Start(probeCtx, setAndTestCoreServiceHandler)
+
+	logger.Debugw(ctx, "OLTAdapter-started", log.Fields{"grpc-address": oltA.serviceEndpoint})
+
+}
+
+// Stop brings down core services
+func (oltA *OLTAdapter) StopGrpcClient() {
+	// Stop the grpc clients
+	oltA.coreClient.Stop(context.Background())
+}
+
+// Stop brings down core services
+func (oltA *OLTAdapter) Stop() {
+
+	// Stop the grpc
+	if oltA.grpcServer != nil {
+		oltA.grpcServer.Stop()
+	}
+	logger.Debugw(context.Background(), "OLTAdapter-stopped", log.Fields{"grpc-address": oltA.serviceEndpoint})
+
 }
 
 // Adopt_device creates new handler for added device
-func (oltA *OLTAdapter) Adopt_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (oltA *OLTAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	logger.Debugw(ctx, "AdoptDevice", log.Fields{"device": device.AdapterEndpoint, "device-type": oltA.DeviceType})
 	go func() {
 		d := proto.Clone(device).(*voltha.Device)
 		d.Root = true
-		d.Vendor = "olt_adapter_mock"
+		d.Vendor = oltA.vendor
 		d.Model = "go-mock"
 		d.SerialNumber = com.GetRandomSerialNumber()
 		d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
 		oltA.storeDevice(d)
-		if res := oltA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
-			logger.Fatalf(ctx, "deviceUpdate-failed-%s", res)
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
 		}
+		if _, err := c.DeviceUpdate(context.TODO(), d); err != nil {
+			logger.Fatalf(ctx, "deviceUpdate-failed-%s", err)
+		}
+
 		capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
 		nniPort := &voltha.Port{
+			DeviceId:   device.Id,
 			PortNo:     2,
 			Label:      fmt.Sprintf("nni-%d", 2),
 			Type:       voltha.Port_ETHERNET_NNI,
-			OperStatus: voltha.OperStatus_ACTIVE,
+			OperStatus: common.OperStatus_ACTIVE,
 			OfpPort: &of.OfpPort{
 				HwAddr:     macAddressToUint32Array("11:22:33:44:55:66"),
 				Config:     0,
@@ -83,30 +156,30 @@
 				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
 			},
 		}
-		var err error
-		if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, nniPort); err != nil {
+		if _, err = c.PortCreated(context.TODO(), nniPort); err != nil {
 			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
 		ponPort := &voltha.Port{
+			DeviceId:   device.Id,
 			PortNo:     1,
 			Label:      fmt.Sprintf("pon-%d", 1),
 			Type:       voltha.Port_PON_OLT,
-			OperStatus: voltha.OperStatus_ACTIVE,
+			OperStatus: common.OperStatus_ACTIVE,
 		}
-		if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+		if _, err = c.PortCreated(context.TODO(), ponPort); err != nil {
 			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
-		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
-		d.OperStatus = voltha.OperStatus_ACTIVE
+		d.ConnectStatus = common.ConnectStatus_REACHABLE
+		d.OperStatus = common.OperStatus_ACTIVE
 
-		if err = oltA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
-			logger.Fatalf(ctx, "Device-state-update-failed-%s", err)
+		if _, err = c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{DeviceId: d.Id, OperStatus: d.OperStatus, ConnStatus: d.ConnectStatus}); err != nil {
+			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
 		//Get the latest device data from the Core
-		if d, err = oltA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
+		if d, err = c.GetDevice(context.TODO(), &common.ID{Id: d.Id}); err != nil {
 			logger.Fatalf(ctx, "getting-device-failed-%s", err)
 		}
 
@@ -116,21 +189,22 @@
 		initialUniPortNo := startingUNIPortNo
 		for i := 0; i < numONUPerOLT; i++ {
 			go func(seqNo int) {
-				if _, err := oltA.coreProxy.ChildDeviceDetected(
-					context.TODO(),
-					d.Id,
-					1,
-					"onu_adapter_mock",
-					initialUniPortNo+seqNo,
-					"onu_adapter_mock",
-					com.GetRandomSerialNumber(),
-					int64(seqNo)); err != nil {
-					logger.Fatalf(ctx, "failure-sending-child-device-%s", err)
+				if _, err := c.ChildDeviceDetected(context.TODO(),
+					&ic.DeviceDiscovery{
+						ParentId:        d.Id,
+						ParentPortNo:    1,
+						ChildDeviceType: oltA.ChildDeviceType,
+						ChannelId:       uint32(initialUniPortNo + seqNo),
+						VendorId:        oltA.childVendor,
+						SerialNumber:    com.GetRandomSerialNumber(),
+						OnuId:           uint32(seqNo),
+					}); err != nil {
+					logger.Fatalw(ctx, "failure-sending-child-device", log.Fields{"error": err, "parent-id": d.Id, "child-device-type": oltA.ChildDeviceType})
 				}
 			}(i)
 		}
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Single_get_value_request retrieves a single value.
@@ -141,7 +215,7 @@
 }
 
 // Get_ofp_device_info returns ofp device info
-func (oltA *OLTAdapter) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
+func (oltA *OLTAdapter) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
 	if d := oltA.getDevice(device.Id); d == nil {
 		logger.Fatalf(ctx, "device-not-found-%s", device.Id)
 	}
@@ -162,18 +236,8 @@
 	}, nil
 }
 
-// GetNumONUPerOLT returns number of ONUs per OLT
-func (oltA *OLTAdapter) GetNumONUPerOLT() int {
-	return numONUPerOLT
-}
-
-// Returns the starting UNI port number
-func (oltA *OLTAdapter) GetStartingUNIPortNo() int {
-	return startingUNIPortNo
-}
-
 // Disable_device disables device
-func (oltA *OLTAdapter) Disable_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (oltA *OLTAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
 	go func() {
 		if d := oltA.getDevice(device.Id); d == nil {
 			logger.Fatalf(ctx, "device-not-found-%s", device.Id)
@@ -181,15 +245,29 @@
 
 		cloned := proto.Clone(device).(*voltha.Device)
 		// Update the all ports state on that device to disable
-		if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
+		}
+
+		if _, err := c.PortsStateUpdate(context.TODO(),
+			&ic.PortStateFilter{
+				DeviceId:       cloned.Id,
+				PortTypeFilter: 0,
+				OperStatus:     common.OperStatus_UNKNOWN,
+			}); err != nil {
 			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 
 		//Update the device operational state
-		cloned.OperStatus = voltha.OperStatus_UNKNOWN
+		cloned.OperStatus = common.OperStatus_UNKNOWN
 		// The device is still reachable after it has been disabled, so the connection status should not be changed.
 
-		if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+			DeviceId:   cloned.Id,
+			OperStatus: cloned.OperStatus,
+			ConnStatus: cloned.ConnectStatus,
+		}); err != nil {
 			// Device may already have been deleted in the core
 			logger.Warnw(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
 			return
@@ -198,135 +276,156 @@
 		oltA.updateDevice(cloned)
 
 		// Tell the Core that all child devices have been disabled (by default it's an action already taken by the Core
-		if err := oltA.coreProxy.ChildDevicesLost(context.TODO(), cloned.Id); err != nil {
+		if _, err := c.ChildDevicesLost(context.TODO(), &common.ID{Id: cloned.Id}); err != nil {
 			// Device may already have been deleted in the core
 			logger.Warnw(ctx, "lost-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Reenable_device reenables device
-func (oltA *OLTAdapter) Reenable_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (oltA *OLTAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
 	go func() {
 		if d := oltA.getDevice(device.Id); d == nil {
 			logger.Fatalf(ctx, "device-not-found-%s", device.Id)
 		}
 
 		cloned := proto.Clone(device).(*voltha.Device)
+
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
+		}
+
 		// Update the all ports state on that device to enable
-		if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_ACTIVE); err != nil {
-			logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
+		if _, err := c.PortsStateUpdate(context.TODO(),
+			&ic.PortStateFilter{
+				DeviceId:       cloned.Id,
+				PortTypeFilter: 0,
+				OperStatus:     common.OperStatus_ACTIVE,
+			}); err != nil {
+			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 
 		//Update the device state
-		cloned.OperStatus = voltha.OperStatus_ACTIVE
+		cloned.OperStatus = common.OperStatus_ACTIVE
 
-		if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+			DeviceId:   cloned.Id,
+			OperStatus: cloned.OperStatus,
+			ConnStatus: cloned.ConnectStatus,
+		}); err != nil {
+			// Device may already have been deleted in the core
 			logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
+			return
 		}
 
 		// Tell the Core that all child devices have been enabled
-		if err := oltA.coreProxy.ChildDevicesDetected(context.TODO(), cloned.Id); err != nil {
+		if _, err := c.ChildDevicesDetected(context.TODO(), &common.ID{Id: cloned.Id}); err != nil {
 			logger.Fatalf(ctx, "detection-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Enable_port -
-func (oltA *OLTAdapter) Enable_port(ctx context.Context, deviceId string, Port *voltha.Port) error { //nolint
+func (oltA *OLTAdapter) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { //nolint
 	go func() {
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
+		}
 
-		if Port.Type == voltha.Port_PON_OLT {
-			if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_ACTIVE); err != nil {
-				logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
+		if port.Type == voltha.Port_PON_OLT {
+			if _, err := c.PortStateUpdate(context.TODO(),
+				&ic.PortState{
+					DeviceId:   port.DeviceId,
+					PortType:   voltha.Port_ETHERNET_NNI,
+					PortNo:     port.PortNo,
+					OperStatus: common.OperStatus_ACTIVE,
+				}); err != nil {
+				logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": port.DeviceId, "error": err})
 			}
 		}
 
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Disable_port -
-func (oltA *OLTAdapter) Disable_port(ctx context.Context, deviceId string, Port *voltha.Port) error { //nolint
+func (oltA *OLTAdapter) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { //nolint
 	go func() {
-
-		if Port.Type == voltha.Port_PON_OLT {
-			if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_DISCOVERED); err != nil {
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
+		}
+		if port.Type == voltha.Port_PON_OLT {
+			if _, err := c.PortStateUpdate(context.TODO(),
+				&ic.PortState{
+					DeviceId:   port.DeviceId,
+					PortType:   voltha.Port_PON_OLT,
+					PortNo:     port.PortNo,
+					OperStatus: common.OperStatus_DISCOVERED,
+				}); err != nil {
 				// Corresponding device may have been deleted
-				logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
+				logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": port.DeviceId, "error": err})
 			}
 		}
 	}()
-	return nil
-}
-
-// Child_device_lost deletes ONU and its references
-func (oltA *OLTAdapter) Child_device_lost(ctx context.Context, childDevice *voltha.Device) error { // nolint
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Reboot_device -
-func (oltA *OLTAdapter) Reboot_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (oltA *OLTAdapter) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
 	logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id})
 
 	go func() {
-		if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), device.Id, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
-			logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
+		c, err := oltA.GetCoreClient()
+		if err != nil {
+			return
 		}
-		if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), device.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
-			// Not an error as the previous command will start the process of clearing the OLT
-			logger.Infow(ctx, "port-update-failed", log.Fields{"device-id": device.Id, "error": err})
+
+		if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+			DeviceId:   device.Id,
+			OperStatus: common.OperStatus_UNKNOWN,
+			ConnStatus: common.ConnectStatus_UNREACHABLE,
+		}); err != nil {
+			logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
+			return
+		}
+
+		if _, err := c.PortsStateUpdate(context.TODO(),
+			&ic.PortStateFilter{
+				DeviceId:       device.Id,
+				PortTypeFilter: 0,
+				OperStatus:     common.OperStatus_UNKNOWN,
+			}); err != nil {
+			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // TODO: REMOVE Start_omci_test begins an omci self-test
-func (oltA *OLTAdapter) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*ic.TestResponse, error) { // nolint
-	_ = device
+func (oltA *OLTAdapter) StartOmciTest(ctx context.Context, test *ic.OMCITest) (*voltha.TestResponse, error) { // nolint
 	return nil, errors.New("start-omci-test-not-implemented")
 }
 
-func (oltA *OLTAdapter) Get_ext_value(ctx context.Context, deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error) { // nolint
-	_ = deviceId
-	_ = device
-	_ = valueflag
-	return nil, errors.New("get-ext-value-not-implemented")
-}
+// Helper for test only
+func (oltA *OLTAdapter) SetDeviceActive(deviceID string) {
+	c, err := oltA.GetCoreClient()
+	if err != nil {
+		return
+	}
 
-func (oltA *OLTAdapter) Download_onu_image(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = request
-	return nil, errors.New("download-onu-image-not-implemented")
-}
+	if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+		DeviceId:   deviceID,
+		OperStatus: common.OperStatus_ACTIVE,
+		ConnStatus: common.ConnectStatus_REACHABLE,
+	}); err != nil {
+		logger.Warnw(context.Background(), "device-state-update-failed", log.Fields{"device-id": deviceID, "error": err})
+		return
+	}
 
-func (oltA *OLTAdapter) Get_onu_image_status(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("get-onu-image-not-implemented")
-}
-
-func (oltA *OLTAdapter) Abort_onu_image_upgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("abort-onu-image-upgrade-not-implemented")
-}
-
-func (oltA *OLTAdapter) Get_onu_images(ctx context.Context, deviceID string) (*voltha.OnuImages, error) { //nolint
-	_ = deviceID
-	return nil, errors.New("get-onu-images-not-implemented")
-}
-
-func (oltA *OLTAdapter) Activate_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("activate-onu-image-not-implemented")
-}
-
-func (oltA *OLTAdapter) Commit_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("commit-onu-image-not-implemented")
-}
-
-func (oltA *OLTAdapter) Process_tech_profile_instance_request(ctx context.Context, in *ic.InterAdapterTechProfileInstanceRequestMessage) *ic.InterAdapterTechProfileDownloadMessage { //nolint
-	_ = in
-	return nil
 }
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 7ce6324..8fb4744 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -18,51 +18,121 @@
 
 import (
 	"context"
-	"errors"
 	"fmt"
-	"github.com/opencord/voltha-protos/v4/go/extension"
+	"strconv"
 	"strings"
 
+	"github.com/golang/protobuf/ptypes/empty"
+	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
+	"github.com/opencord/voltha-protos/v5/go/common"
+	"github.com/opencord/voltha-protos/v5/go/extension"
+	"github.com/phayes/freeport"
+
 	"github.com/gogo/protobuf/proto"
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
-	com "github.com/opencord/voltha-lib-go/v5/pkg/adapters/common"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
-	ic "github.com/opencord/voltha-protos/v4/go/inter_container"
-	of "github.com/opencord/voltha-protos/v4/go/openflow_13"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	com "github.com/opencord/voltha-lib-go/v7/pkg/adapters/common"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+	of "github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
 // ONUAdapter represent ONU adapter attributes
 type ONUAdapter struct {
 	*Adapter
+	grpcServer *vgrpc.GrpcServer
 }
 
 // NewONUAdapter creates ONU adapter
-func NewONUAdapter(ctx context.Context, cp adapterif.CoreProxy) *ONUAdapter {
-	return &ONUAdapter{
-		Adapter: NewAdapter(cp),
+func NewONUAdapter(ctx context.Context, coreEndpoint string, deviceType string, vendor string) *ONUAdapter {
+	// Get an available  port
+	grpcPort, err := freeport.GetFreePort()
+	if err != nil {
+		logger.Fatalw(ctx, "no-free-port", log.Fields{"error": err})
 	}
+	listeningAddress := fmt.Sprintf("127.0.0.1:%s", strconv.Itoa(grpcPort))
+	onuAdapter := &ONUAdapter{Adapter: NewAdapter(listeningAddress, coreEndpoint, deviceType, vendor)}
+
+	onuAdapter.start(ctx)
+	return onuAdapter
+}
+
+func (onuA *ONUAdapter) onuRestarted(ctx context.Context, endPoint string) error {
+	logger.Errorw(ctx, "remote-restarted", log.Fields{"endpoint": endPoint})
+	return nil
+}
+
+func (onuA *ONUAdapter) start(ctx context.Context) {
+
+	// Set up the probe service
+	onuA.Probe = &probe.Probe{}
+	probePort, err := freeport.GetFreePort()
+	if err != nil {
+		logger.Fatal(ctx, "Cannot get a freeport for probePort")
+	}
+	probeAddress := "127.0.0.1:" + strconv.Itoa(probePort)
+	go onuA.Probe.ListenAndServe(ctx, probeAddress)
+
+	probeCtx := context.WithValue(ctx, probe.ProbeContextKey, onuA.Probe)
+
+	onuA.Probe.RegisterService(ctx, "onu-grpc-service", onuA.coreEnpoint)
+
+	// start gRPC handler
+	onuA.grpcServer = vgrpc.NewGrpcServer(onuA.serviceEndpoint, nil, false, nil)
+
+	logger.Debugw(ctx, "ONUAdapter-address", log.Fields{"address": onuA.serviceEndpoint})
+
+	go onuA.startGRPCService(ctx, onuA.grpcServer, onuA, "onu-grpc-service")
+
+	// Establish grpc connection to Core
+	if onuA.coreClient, err = vgrpc.NewClient(onuA.coreEnpoint,
+		onuA.onuRestarted,
+		vgrpc.ActivityCheck(true)); err != nil {
+		logger.Fatal(ctx, "grpc-client-not-created")
+	}
+	go onuA.coreClient.Start(probeCtx, setAndTestCoreServiceHandler)
+
+	logger.Debugw(ctx, "ONUAdapter-started", log.Fields{"grpc-address": onuA.serviceEndpoint})
+}
+
+// Stop brings down core services
+func (onuA *ONUAdapter) StopGrpcClient() {
+	// Stop the grpc clients
+	onuA.coreClient.Stop(context.Background())
+}
+
+func (onuA *ONUAdapter) Stop() {
+	if onuA.grpcServer != nil {
+		onuA.grpcServer.Stop()
+	}
+	logger.Debugw(context.Background(), "ONUAdapter-stopped", log.Fields{"grpc-address": onuA.serviceEndpoint})
 }
 
 // Adopt_device creates new handler for added device
-func (onuA *ONUAdapter) Adopt_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (onuA *ONUAdapter) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
+	logger.Debugw(ctx, "AdoptDevice", log.Fields{"device": device.AdapterEndpoint, "device-type": onuA.DeviceType})
 	go func() {
 		d := proto.Clone(device).(*voltha.Device)
 		d.Root = false
-		d.Vendor = "onu_adapter_mock"
+		d.Vendor = onuA.vendor
 		d.Model = "go-mock"
 		d.SerialNumber = com.GetRandomSerialNumber()
 		d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
 		onuA.storeDevice(d)
-		if res := onuA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
-			logger.Fatalf(ctx, "deviceUpdate-failed-%s", res)
+
+		c, err := onuA.GetCoreClient()
+		if err != nil {
+			return
+		}
+		if _, err := c.DeviceUpdate(context.TODO(), d); err != nil {
+			logger.Fatalf(ctx, "deviceUpdate-failed-%s", err)
 		}
 
-		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
-		d.OperStatus = voltha.OperStatus_DISCOVERED
+		d.ConnectStatus = common.ConnectStatus_REACHABLE
+		d.OperStatus = common.OperStatus_DISCOVERED
 
-		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
-			logger.Fatalf(ctx, "device-state-update-failed-%s", err)
+		if _, err = c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{DeviceId: d.Id, OperStatus: d.OperStatus, ConnStatus: d.ConnectStatus}); err != nil {
+			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
 		uniPortNo := uint32(2)
@@ -74,10 +144,11 @@
 
 		capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
 		uniPort := &voltha.Port{
+			DeviceId:   d.Id,
 			PortNo:     uniPortNo,
 			Label:      fmt.Sprintf("uni-%d", uniPortNo),
 			Type:       voltha.Port_ETHERNET_UNI,
-			OperStatus: voltha.OperStatus_ACTIVE,
+			OperStatus: common.OperStatus_ACTIVE,
 			OfpPort: &of.OfpPort{
 				HwAddr:     macAddressToUint32Array("12:12:12:12:12:12"),
 				Config:     0,
@@ -90,8 +161,7 @@
 			},
 		}
 
-		var err error
-		if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, uniPort); err != nil {
+		if _, err = c.PortCreated(context.TODO(), uniPort); err != nil {
 			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
@@ -101,31 +171,34 @@
 		}
 
 		ponPort := &voltha.Port{
+			DeviceId:   d.Id,
 			PortNo:     ponPortNo,
 			Label:      fmt.Sprintf("pon-%d", ponPortNo),
 			Type:       voltha.Port_PON_ONU,
-			OperStatus: voltha.OperStatus_ACTIVE,
+			OperStatus: common.OperStatus_ACTIVE,
 			Peers: []*voltha.Port_PeerPort{{DeviceId: d.ParentId, // Peer device  is OLT
 				PortNo: device.ParentPortNo}}, // Peer port is parent's port number
 		}
-		if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+
+		if _, err = c.PortCreated(context.TODO(), ponPort); err != nil {
 			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
 
-		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
-		d.OperStatus = voltha.OperStatus_ACTIVE
+		d.ConnectStatus = common.ConnectStatus_REACHABLE
+		d.OperStatus = common.OperStatus_ACTIVE
 
-		if err = onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
-			logger.Fatalf(ctx, "device-state-update-failed-%s", err)
+		if _, err = c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{DeviceId: d.Id, OperStatus: d.OperStatus, ConnStatus: d.ConnectStatus}); err != nil {
+			logger.Fatalf(ctx, "PortCreated-failed-%s", err)
 		}
+
 		//Get the latest device data from the Core
-		if d, err = onuA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
+		if d, err = c.GetDevice(context.TODO(), &common.ID{Id: d.Id}); err != nil {
 			logger.Fatalf(ctx, "getting-device-failed-%s", err)
 		}
 
 		onuA.updateDevice(d)
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
 // Single_get_value_request retrieves a single value.
@@ -136,102 +209,89 @@
 }
 
 // Disable_device disables device
-func (onuA *ONUAdapter) Disable_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (onuA *ONUAdapter) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
 	go func() {
 		if d := onuA.getDevice(device.Id); d == nil {
 			logger.Fatalf(ctx, "device-not-found-%s", device.Id)
 		}
+
 		cloned := proto.Clone(device).(*voltha.Device)
 		// Update the all ports state on that device to disable
-		if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
-			// Device may also have been deleted in the Core
-			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
+		c, err := onuA.GetCoreClient()
+		if err != nil {
 			return
 		}
-		//Update the device state
-		cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
-		cloned.OperStatus = voltha.OperStatus_UNKNOWN
 
-		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		if _, err := c.PortsStateUpdate(context.TODO(),
+			&ic.PortStateFilter{
+				DeviceId:       cloned.Id,
+				PortTypeFilter: 0,
+				OperStatus:     common.OperStatus_UNKNOWN,
+			}); err != nil {
+			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
+		}
+
+		//Update the device operational state
+		cloned.ConnectStatus = common.ConnectStatus_UNREACHABLE
+		cloned.OperStatus = common.OperStatus_UNKNOWN
+
+		if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+			DeviceId:   cloned.Id,
+			OperStatus: cloned.OperStatus,
+			ConnStatus: cloned.ConnectStatus,
+		}); err != nil {
+			// Device may already have been deleted in the core
 			logger.Warnw(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
 			return
 		}
+
 		onuA.updateDevice(cloned)
+
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
-// Reenable_device reenables device
-func (onuA *ONUAdapter) Reenable_device(ctx context.Context, device *voltha.Device) error { // nolint
+func (onuA *ONUAdapter) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { // nolint
 	go func() {
 		if d := onuA.getDevice(device.Id); d == nil {
 			logger.Fatalf(ctx, "device-not-found-%s", device.Id)
 		}
 
 		cloned := proto.Clone(device).(*voltha.Device)
+
+		c, err := onuA.GetCoreClient()
+		if err != nil {
+			return
+		}
+
 		// Update the all ports state on that device to enable
-		if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_ACTIVE); err != nil {
-			logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
+		if _, err := c.PortsStateUpdate(context.TODO(),
+			&ic.PortStateFilter{
+				DeviceId:       cloned.Id,
+				PortTypeFilter: 0,
+				OperStatus:     common.OperStatus_ACTIVE,
+			}); err != nil {
+			logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err})
 		}
 
 		//Update the device state
-		cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
-		cloned.OperStatus = voltha.OperStatus_ACTIVE
+		cloned.ConnectStatus = common.ConnectStatus_REACHABLE
+		cloned.OperStatus = common.OperStatus_ACTIVE
 
-		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		if _, err := c.DeviceStateUpdate(context.TODO(), &ic.DeviceStateFilter{
+			DeviceId:   cloned.Id,
+			OperStatus: cloned.OperStatus,
+			ConnStatus: cloned.ConnectStatus,
+		}); err != nil {
+			// Device may already have been deleted in the core
 			logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
+			return
 		}
-
 		onuA.updateDevice(cloned)
 	}()
-	return nil
+	return &empty.Empty{}, nil
 }
 
-// Start_omci_test begins an omci self-test
-func (onuA *ONUAdapter) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*ic.TestResponse, error) { // nolint
-	_ = device
-	return &ic.TestResponse{Result: ic.TestResponse_SUCCESS}, nil
-}
-
-func (onuA *ONUAdapter) Get_ext_value(ctx context.Context, deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error) { // nolint
-	_ = deviceId
-	_ = device
-	_ = valueflag
-	return nil, errors.New("get-ext-value-not-implemented")
-}
-
-func (onuA *ONUAdapter) Download_onu_image(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	logger.Infof(ctx, "Download_onu_image")
-	_ = request
-	return nil, errors.New("download-onu-image-not-implemented")
-}
-
-func (onuA *ONUAdapter) Get_onu_image_status(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("get-onu-image-not-implemented")
-}
-
-func (onuA *ONUAdapter) Abort_onu_image_upgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("abort-onu-image-upgrade-not-implemented")
-}
-
-func (onuA *ONUAdapter) Get_onu_images(ctx context.Context, deviceID string) (*voltha.OnuImages, error) { //nolint
-	_ = deviceID
-	return nil, errors.New("get-onu-images-not-implemented")
-}
-
-func (onuA *ONUAdapter) Activate_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("activate-onu-image-not-implemented")
-}
-
-func (onuA *ONUAdapter) Commit_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint
-	_ = in
-	return nil, errors.New("commit-onu-image-not-implemented")
-}
-
-func (onuA *ONUAdapter) Process_tech_profile_instance_request(ctx context.Context, in *ic.InterAdapterTechProfileInstanceRequestMessage) *ic.InterAdapterTechProfileDownloadMessage { //nolint
-	_ = in
-	return nil
+func (onuA *ONUAdapter) StartOmciTest(ctx context.Context, _ *ic.OMCITest) (*voltha.TestResponse, error) { // nolint
+	return &voltha.TestResponse{Result: voltha.TestResponse_SUCCESS}, nil
 }
diff --git a/rw_core/mocks/adapter_onu_test.go b/rw_core/mocks/adapter_onu_test.go
deleted file mode 100644
index 20eef15..0000000
--- a/rw_core/mocks/adapter_onu_test.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2019-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 mocks
-
-import (
-	"context"
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters"
-	"testing"
-)
-
-func TestONUAdapterImplementsIAdapter(t *testing.T) {
-	adapter := NewONUAdapter(context.Background(), nil)
-
-	if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
-		t.Error("ONU adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
-	}
-}
diff --git a/rw_core/mocks/adapter_test.go b/rw_core/mocks/adapter_test.go
deleted file mode 100644
index cf8c3ca..0000000
--- a/rw_core/mocks/adapter_test.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2019-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 mocks
-
-import (
-	"github.com/opencord/voltha-lib-go/v5/pkg/adapters"
-	"testing"
-)
-
-func TestAdapterImplementsIAdapter(t *testing.T) {
-	adapter := NewAdapter(nil)
-
-	if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
-		t.Error("adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
-	}
-}
diff --git a/rw_core/mocks/common.go b/rw_core/mocks/common.go
index 360007a..1de8a1f 100644
--- a/rw_core/mocks/common.go
+++ b/rw_core/mocks/common.go
@@ -18,7 +18,7 @@
 package mocks
 
 import (
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 )
 
 var logger log.CLogger