Formatted code with 'go fmt'

Change-Id: I5361f3388a1fb8da1ef3222d51bc58355a804137
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index 1c2fdf9..83ce853 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -29,11 +29,11 @@
 	"github.com/golang/protobuf/ptypes"
 	com "github.com/opencord/voltha-go/adapters/common"
 	"github.com/opencord/voltha-go/common/log"
+	rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
 	"github.com/opencord/voltha-protos/go/common"
 	ic "github.com/opencord/voltha-protos/go/inter_container"
 	of "github.com/opencord/voltha-protos/go/openflow_13"
 	oop "github.com/opencord/voltha-protos/go/openolt"
-	rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
 	"github.com/opencord/voltha-protos/go/voltha"
 	"google.golang.org/grpc"
 )
@@ -61,7 +61,7 @@
 func NewDeviceHandler(cp *com.CoreProxy, ap *com.AdapterProxy, device *voltha.Device, adapter *OpenOLT) *DeviceHandler {
 	var dh DeviceHandler
 	dh.coreProxy = cp
-        dh.AdapterProxy = ap
+	dh.AdapterProxy = ap
 	cloned := (proto.Clone(device)).(*voltha.Device)
 	dh.deviceId = cloned.Id
 	dh.deviceType = cloned.Type
@@ -108,13 +108,13 @@
 
 func GetportLabel(portNum uint32, portType voltha.Port_PortType) string {
 
-    if portType == voltha.Port_ETHERNET_NNI {
-        return fmt.Sprintf("nni-%d",portNum)
-    } else if portType == voltha.Port_PON_OLT{
-        return fmt.Sprintf("pon-%d",portNum)
+	if portType == voltha.Port_ETHERNET_NNI {
+		return fmt.Sprintf("nni-%d", portNum)
+	} else if portType == voltha.Port_PON_OLT {
+		return fmt.Sprintf("pon-%d", portNum)
 	} else if portType == voltha.Port_ETHERNET_UNI {
 		log.Errorw("local UNI management not supported", log.Fields{})
-        return ""
+		return ""
 	}
 	return ""
 }
@@ -126,30 +126,30 @@
 	} else {
 		operStatus = voltha.OperStatus_DISCOVERED
 	}
-    // portNum := IntfIdToPortNo(intfId,portType)
+	// portNum := IntfIdToPortNo(intfId,portType)
 	portNum := intfId
-        label := GetportLabel(portNum, portType)
-        if len(label) == 0 {
-        log.Errorw("Invalid-port-label",log.Fields{"portNum":portNum,"portType":portType})
-        return
-    }
-    //    Now create  Port
-    port := &voltha.Port{
+	label := GetportLabel(portNum, portType)
+	if len(label) == 0 {
+		log.Errorw("Invalid-port-label", log.Fields{"portNum": portNum, "portType": portType})
+		return
+	}
+	//    Now create  Port
+	port := &voltha.Port{
 		PortNo:     portNum,
 		Label:      label,
 		Type:       portType,
 		OperStatus: operStatus,
 	}
-    log.Debugw("Sending port update to core",log.Fields{"port":port})
+	log.Debugw("Sending port update to core", log.Fields{"port": port})
 	// Synchronous call to update device - this method is run in its own go routine
-    if err := dh.coreProxy.PortCreated(nil, dh.device.Id, port); err != nil {
+	if err := dh.coreProxy.PortCreated(nil, dh.device.Id, port); err != nil {
 		log.Errorw("error-creating-nni-port", log.Fields{"deviceId": dh.device.Id, "error": err})
 	}
 }
 
 // readIndications to read the indications from the OLT device
 func (dh *DeviceHandler) readIndications() {
-    indications, err := dh.Client.EnableIndication(context.Background(), new(oop.Empty))
+	indications, err := dh.Client.EnableIndication(context.Background(), new(oop.Empty))
 	if err != nil {
 		log.Errorw("Failed to read indications", log.Fields{"err": err})
 		return
@@ -192,18 +192,18 @@
 		case *oop.Indication_OnuDiscInd:
 			onuDiscInd := indication.GetOnuDiscInd()
 			log.Infow("Received Onu discovery indication ", log.Fields{"OnuDiscInd": onuDiscInd})
-            //onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
-            //onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
-            // TODO Get onu ID from the resource manager
+			//onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
+			//onuId,err := dh.resourceMgr.GetONUID(onuDiscInd.GetIntfId())
+			// TODO Get onu ID from the resource manager
 			var onuId uint32 = 1
-            /*if err != nil{
-                log.Errorw("onu-id-unavailable",log.Fields{"intfId":onuDiscInd.GetIntfId()})
-                return
-            }*/
+			/*if err != nil{
+			    log.Errorw("onu-id-unavailable",log.Fields{"intfId":onuDiscInd.GetIntfId()})
+			    return
+			}*/
 
 			sn := dh.stringifySerialNumber(onuDiscInd.SerialNumber)
-            //FIXME: Duplicate child devices being create in go routine 
-                        dh.onuDiscIndication(onuDiscInd, onuId, sn)
+			//FIXME: Duplicate child devices being create in go routine
+			dh.onuDiscIndication(onuDiscInd, onuId, sn)
 		case *oop.Indication_OnuInd:
 			onuInd := indication.GetOnuInd()
 			log.Infow("Received Onu indication ", log.Fields{"OnuInd": onuInd})
@@ -232,13 +232,13 @@
 
 // doStateUp handle the olt up indication and update to voltha core
 func (dh *DeviceHandler) doStateUp() error {
-    // Synchronous call to update device state - this method is run in its own go routine
+	// Synchronous call to update device state - this method is run in its own go routine
 	if err := dh.coreProxy.DeviceStateUpdate(context.Background(), dh.device.Id, voltha.ConnectStatus_REACHABLE,
-        voltha.OperStatus_ACTIVE); err != nil {
-            log.Errorw("Failed to update device with OLT UP indication", log.Fields{"deviceId": dh.device.Id, "error": err})
-            return err
-    }
-    return nil
+		voltha.OperStatus_ACTIVE); err != nil {
+		log.Errorw("Failed to update device with OLT UP indication", log.Fields{"deviceId": dh.device.Id, "error": err})
+		return err
+	}
+	return nil
 }
 
 // doStateDown handle the olt down indication
@@ -249,26 +249,26 @@
 
 // doStateInit dial the grpc before going to init state
 func (dh *DeviceHandler) doStateInit() error {
-    var err error
-    dh.clientCon, err = grpc.Dial(dh.device.GetHostAndPort(), grpc.WithInsecure())
-    if err != nil {
+	var err error
+	dh.clientCon, err = grpc.Dial(dh.device.GetHostAndPort(), grpc.WithInsecure())
+	if err != nil {
 		log.Errorw("Failed to dial device", log.Fields{"DeviceId": dh.deviceId, "HostAndPort": dh.device.GetHostAndPort(), "err": err})
-        return err
-    }
-    return nil
+		return err
+	}
+	return nil
 }
 
 // postInit create olt client instance to invoke RPC on the olt device
 func (dh *DeviceHandler) postInit() error {
-    dh.Client = oop.NewOpenoltClient(dh.clientCon)
-    dh.transitionMap.Handle(GrpcConnected)
-    return nil
+	dh.Client = oop.NewOpenoltClient(dh.clientCon)
+	dh.transitionMap.Handle(GrpcConnected)
+	return nil
 }
 
 // doStateConnected get the device info and update to voltha core
 func (dh *DeviceHandler) doStateConnected() error {
-    log.Debug("OLT device has been connected")
-    deviceInfo, err := dh.Client.GetDeviceInfo(context.Background(), new(oop.Empty))
+	log.Debug("OLT device has been connected")
+	deviceInfo, err := dh.Client.GetDeviceInfo(context.Background(), new(oop.Empty))
 	if err != nil {
 		log.Errorw("Failed to fetch device info", log.Fields{"err": err})
 		return err
@@ -292,18 +292,18 @@
 	if err := dh.coreProxy.DeviceUpdate(nil, dh.device); err != nil {
 		log.Errorw("error-updating-device", log.Fields{"deviceId": dh.device.Id, "error": err})
 	}
-    KVStoreHostPort := fmt.Sprintf("%s:%d",dh.openOLT.KVStoreHost,dh.openOLT.KVStorePort)
-    // Instantiate resource manager
-    if dh.resourceMgr = rsrcMgr.NewResourceMgr(dh.deviceId, KVStoreHostPort,  dh.deviceType, deviceInfo); dh.resourceMgr == nil{
-        log.Error("Error while instantiating resource manager")
-        return errors.New("Instantiating resource manager failed")
-    }
-    // Instantiate flow manager
-    if dh.flowMgr = NewFlowManager(dh, dh.resourceMgr); dh.flowMgr == nil{
-        log.Error("Error while instantiating flow manager")
-        return errors.New("Instantiating flow manager failed")
-    }
-    /* TODO: Instantiate Alarm , stats , BW managers */
+	KVStoreHostPort := fmt.Sprintf("%s:%d", dh.openOLT.KVStoreHost, dh.openOLT.KVStorePort)
+	// Instantiate resource manager
+	if dh.resourceMgr = rsrcMgr.NewResourceMgr(dh.deviceId, KVStoreHostPort, dh.deviceType, deviceInfo); dh.resourceMgr == nil {
+		log.Error("Error while instantiating resource manager")
+		return errors.New("Instantiating resource manager failed")
+	}
+	// Instantiate flow manager
+	if dh.flowMgr = NewFlowManager(dh, dh.resourceMgr); dh.flowMgr == nil {
+		log.Error("Error while instantiating flow manager")
+		return errors.New("Instantiating flow manager failed")
+	}
+	/* TODO: Instantiate Alarm , stats , BW managers */
 
 	// Start reading indications
 	go dh.readIndications()
@@ -312,9 +312,9 @@
 
 // AdoptDevice adopts the OLT device
 func (dh *DeviceHandler) AdoptDevice(device *voltha.Device) {
-    dh.transitionMap = NewTransitionMap(dh)
+	dh.transitionMap = NewTransitionMap(dh)
 	log.Infow("AdoptDevice", log.Fields{"deviceId": device.Id, "Address": device.GetHostAndPort()})
-    dh.transitionMap.Handle(DeviceInit)
+	dh.transitionMap.Handle(DeviceInit)
 }
 
 // GetOfpDeviceInfo Get the Ofp device information
@@ -360,7 +360,7 @@
 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) error {
 	log.Debugw("omci indication", log.Fields{"intfId": omciInd.IntfId, "onuId": omciInd.OnuId})
 
-//        ponPort := IntfIdToPortNo(omciInd.GetIntfId(),voltha.Port_PON_OLT)
+	//        ponPort := IntfIdToPortNo(omciInd.GetIntfId(),voltha.Port_PON_OLT)
 	kwargs := make(map[string]interface{})
 	kwargs["onu_id"] = omciInd.OnuId
 	kwargs["parent_port_no"] = omciInd.GetIntfId()
@@ -439,10 +439,10 @@
 }
 
 func (dh *DeviceHandler) onuDiscIndication(onuDiscInd *oop.OnuDiscIndication, onuId uint32, sn string) error {
-        //channelId := MkUniPortNum(onuDiscInd.GetIntfId(), onuId, uint32(0))
-        //parentPortNo := IntfIdToPortNo(onuDiscInd.GetIntfId(),voltha.Port_PON_OLT)
-        channelId := onuDiscInd.GetIntfId()
-        parentPortNo := onuDiscInd.GetIntfId()
+	//channelId := MkUniPortNum(onuDiscInd.GetIntfId(), onuId, uint32(0))
+	//parentPortNo := IntfIdToPortNo(onuDiscInd.GetIntfId(),voltha.Port_PON_OLT)
+	channelId := onuDiscInd.GetIntfId()
+	parentPortNo := onuDiscInd.GetIntfId()
 	if err := dh.coreProxy.ChildDeviceDetected(nil, dh.device.Id, int(parentPortNo), "brcm_openomci_onu", int(channelId), string(onuDiscInd.SerialNumber.GetVendorId()), sn, int64(onuId)); err != nil {
 		log.Errorw("Create onu error", log.Fields{"parent_id": dh.device.Id, "ponPort": onuDiscInd.GetIntfId(), "onuId": onuId, "sn": sn, "error": err})
 		return err
@@ -469,7 +469,7 @@
 	serialNumber := dh.stringifySerialNumber(onuInd.SerialNumber)
 
 	kwargs := make(map[string]interface{})
-//        ponPort := IntfIdToPortNo(onuInd.GetIntfId(),voltha.Port_PON_OLT)
+	//        ponPort := IntfIdToPortNo(onuInd.GetIntfId(),voltha.Port_PON_OLT)
 
 	if serialNumber != "" {
 		kwargs["serial_number"] = serialNumber
@@ -560,32 +560,32 @@
 func (dh *DeviceHandler) Update_flows_bulk() error {
 	return errors.New("UnImplemented")
 }
-func (dh *DeviceHandler) GetChildDevice(parentPort uint32, onuId uint32)*voltha.Device{
-    log.Debugw("GetChildDevice",log.Fields{"pon port": parentPort,"onuId": onuId})
-    kwargs := make(map[string]interface{})
-    kwargs["onu_id"] = onuId
-    kwargs["parent_port_no"] = parentPort
-    onuDevice, err := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs)
-    if err != nil {
-        log.Errorw("onu not found", log.Fields{"intfId": parentPort, "onuId": onuId})
-        return nil
-    }
-    log.Debugw("Successfully received child device from core",log.Fields{"child_device":*onuDevice})
-    return  onuDevice
+func (dh *DeviceHandler) GetChildDevice(parentPort uint32, onuId uint32) *voltha.Device {
+	log.Debugw("GetChildDevice", log.Fields{"pon port": parentPort, "onuId": onuId})
+	kwargs := make(map[string]interface{})
+	kwargs["onu_id"] = onuId
+	kwargs["parent_port_no"] = parentPort
+	onuDevice, err := dh.coreProxy.GetChildDevice(nil, dh.device.Id, kwargs)
+	if err != nil {
+		log.Errorw("onu not found", log.Fields{"intfId": parentPort, "onuId": onuId})
+		return nil
+	}
+	log.Debugw("Successfully received child device from core", log.Fields{"child_device": *onuDevice})
+	return onuDevice
 }
 
 func (dh *DeviceHandler) UpdateFlowsIncrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges) error {
-    log.Debugw("In UpdateFlowsIncrementally",log.Fields{"deviceId":device.Id,"flows":flows,"groups":groups})
-    if flows != nil{
-    for _,flow := range flows.ToAdd.Items{
-        dh.flowMgr.AddFlow(flow)
-        }
-    }
-    if groups != nil{
-        for _,flow := range flows.ToRemove.Items{
-            log.Debug("Removing flow",log.Fields{"deviceId":device.Id,"flowToRemove":flow})
-          //  dh.flowMgr.RemoveFlow(flow)
-        }
-    }
-    return nil
+	log.Debugw("In UpdateFlowsIncrementally", log.Fields{"deviceId": device.Id, "flows": flows, "groups": groups})
+	if flows != nil {
+		for _, flow := range flows.ToAdd.Items {
+			dh.flowMgr.AddFlow(flow)
+		}
+	}
+	if groups != nil {
+		for _, flow := range flows.ToRemove.Items {
+			log.Debug("Removing flow", log.Fields{"deviceId": device.Id, "flowToRemove": flow})
+			//  dh.flowMgr.RemoveFlow(flow)
+		}
+	}
+	return nil
 }
diff --git a/adaptercore/olt_platform.go b/adaptercore/olt_platform.go
index faff0b4..60b9bb8 100644
--- a/adaptercore/olt_platform.go
+++ b/adaptercore/olt_platform.go
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 package adaptercore
-import (voltha "github.com/opencord/voltha-protos/go/voltha");
+
+import (
+	voltha "github.com/opencord/voltha-protos/go/voltha"
+)
 
 /*=====================================================================
 
@@ -72,13 +75,13 @@
     +--------+------------------------~~~------+
 */
 
-var MAX_ONUS_PER_PON = 32;
-var MIN_UPSTREAM_PORT_ID = 0xfffd;
-var MAX_UPSTREAM_PORT_ID = 0xfffffffd;
+var MAX_ONUS_PER_PON = 32
+var MIN_UPSTREAM_PORT_ID = 0xfffd
+var MAX_UPSTREAM_PORT_ID = 0xfffffffd
 
 func MkUniPortNum(intfId uint32, onuId uint32, uniId uint32) uint32 {
-/* TODO: Add checks */
-        return ((intfId << 11) | (onuId << 4) | uniId)
+	/* TODO: Add checks */
+	return ((intfId << 11) | (onuId << 4) | uniId)
 }
 
 func MkFlowId(intfId uint32, onuId uint32, idx uint32) uint32 {
@@ -94,20 +97,18 @@
 }
 
 func UniIdFromPortNum(portNum uint32) uint32 {
-        return ((portNum) & 0xF)
+	return ((portNum) & 0xF)
 }
 
-
-
 func IntfIdFromPonPortNo(portNo uint32) uint32 {
 	return (portNo & 15)
 }
 
 func IntfIdToPortNo(intfId uint32, intfType voltha.Port_PortType) uint32 {
-	if (( intfType ) == voltha.Port_ETHERNET_NNI) {
+	if (intfType) == voltha.Port_ETHERNET_NNI {
 		return ((1 << 16) | intfId)
 	} else {
-		if (( intfType ) == voltha.Port_PON_OLT) {
+		if (intfType) == voltha.Port_PON_OLT {
 			return ((2 << 28) | intfId)
 		} else {
 			return 0
@@ -120,10 +121,10 @@
 }
 
 func IntfIdToPortTypeName(intfId uint32) voltha.Port_PortType {
-	if (( ((2 << 28) ^ intfId) ) < 16) {
+	if ((2 << 28) ^ intfId) < 16 {
 		return voltha.Port_PON_OLT
 	} else {
-		if ( (intfId & (1 << 16)) ) == ( (1 << 16) ) {
+		if (intfId & (1 << 16)) == (1 << 16) {
 			return voltha.Port_ETHERNET_NNI
 		} else {
 			return voltha.Port_UNKNOWN
@@ -136,18 +137,18 @@
 }
 
 func ExtractAccessFromFlow(inPort uint32, outPort uint32) (uint32, uint32, uint32, uint32) {
-	if (IsUpstream(outPort)) {
-                return inPort, IntfIdFromUniPortNum(inPort), OnuIdFromPortNum(inPort), UniIdFromPortNum(inPort)
+	if IsUpstream(outPort) {
+		return inPort, IntfIdFromUniPortNum(inPort), OnuIdFromPortNum(inPort), UniIdFromPortNum(inPort)
 	} else {
-                return outPort, IntfIdFromUniPortNum(outPort), OnuIdFromPortNum(outPort), UniIdFromPortNum(outPort)
+		return outPort, IntfIdFromUniPortNum(outPort), OnuIdFromPortNum(outPort), UniIdFromPortNum(outPort)
 	}
 }
 
 func IsUpstream(outPort uint32) bool {
-	if ((outPort >= uint32(MIN_UPSTREAM_PORT_ID)) && (outPort <= uint32(MAX_UPSTREAM_PORT_ID))) {
+	if (outPort >= uint32(MIN_UPSTREAM_PORT_ID)) && (outPort <= uint32(MAX_UPSTREAM_PORT_ID)) {
 		return true
 	}
-	if ( (outPort & (1 << 16)) ) == ( (1 << 16) ) {
+	if (outPort & (1 << 16)) == (1 << 16) {
 		return true
 	}
 	return false
diff --git a/adaptercore/olt_state_transitions.go b/adaptercore/olt_state_transitions.go
index 45e5f5e..5d53fee 100644
--- a/adaptercore/olt_state_transitions.go
+++ b/adaptercore/olt_state_transitions.go
@@ -1,184 +1,184 @@
-/*

- * 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 adaptercore

-

-import (

-    "reflect"

-    "runtime"

-

-    "github.com/opencord/voltha-go/common/log"

-)

-

-// DeviceState OLT Device state

-type DeviceState int

-

-const (

-    // deviceStateNull OLT is not instantiated

-    deviceStateNull DeviceState = iota

-    // deviceStateInit OLT is instantiated

-    deviceStateInit

-    // deviceStateConnected Grpc session established with OLT

-    deviceStateConnected

-    // deviceStateUp Admin state of OLT is UP

-    deviceStateUp

-    // deviceStateDown Admin state of OLT is down

-    deviceStateDown

-)

-

-// Trigger for changing the state

-type Trigger int

-

-const (

-    // DeviceInit Go to Device init state

-    DeviceInit Trigger = iota

-    // GrpcConnected Go to connected state

-    GrpcConnected

-    // DeviceUpInd Go to Device up state

-    DeviceUpInd

-    // DeviceDownInd Go to Device down state

-    DeviceDownInd

-    // GrpcDisconnected Go to Device init state

-    GrpcDisconnected

-)

-

-// TransitionHandler function type for handling transition

-type TransitionHandler func() error

-

-// Transition to store state machine

-type Transition struct {

-    previousState []DeviceState

-    currentState  DeviceState

-    before        []TransitionHandler

-    after         []TransitionHandler

-}

-

-// TransitionMap to store all the states and current device state

-type TransitionMap struct {

-    transitions        map[Trigger]Transition

-    currentDeviceState DeviceState

-}

-

-//    OpenoltDevice state machine:

-//

-//        null ----> init ------> connected -----> up -----> down

-//                   ^ ^             |             ^         | |

-//                   | |             |             |         | |

-//                   | +-------------+             +---------+ |

-//                   |                                         |

-//                   +-----------------------------------------+

-

-// NewTransitionMap create a new state machine with all the transitions

-func NewTransitionMap(dh *DeviceHandler) *TransitionMap {

-    var transitionMap TransitionMap

-    transitionMap.currentDeviceState = deviceStateNull

-    transitionMap.transitions = make(map[Trigger]Transition)

-    // In doInit establish the grpc session

-    transitionMap.transitions[DeviceInit] =

-        Transition{

-            previousState: []DeviceState{deviceStateNull},

-            currentState:  deviceStateInit,

-            before:        []TransitionHandler{dh.doStateInit},

-            after:         []TransitionHandler{dh.postInit}}

-    // If gRpc session fails, re-establish the grpc session

-    transitionMap.transitions[GrpcDisconnected] =

-        Transition{

-            previousState: []DeviceState{deviceStateConnected, deviceStateDown},

-            currentState:  deviceStateInit,

-            before:        []TransitionHandler{dh.doStateInit},

-            after:         []TransitionHandler{dh.postInit}}

-    // in doConnected, create logical device and read the indications

-    transitionMap.transitions[GrpcConnected] =

-        Transition{

-            previousState: []DeviceState{deviceStateInit},

-            currentState:  deviceStateConnected,

-            before:        []TransitionHandler{dh.doStateConnected}}

-

-    // Once the olt UP is indication received, then do state up

-    transitionMap.transitions[DeviceUpInd] =

-        Transition{

-            previousState: []DeviceState{deviceStateConnected, deviceStateDown},

-            currentState:  deviceStateUp,

-            before:        []TransitionHandler{dh.doStateUp}}

-    // If olt DOWN indication comes then do sate down

-    transitionMap.transitions[DeviceDownInd] =

-        Transition{

-            previousState: []DeviceState{deviceStateUp},

-            currentState:  deviceStateDown,

-            before:        []TransitionHandler{dh.doStateDown}}

-

-    return &transitionMap

-}

-

-// funcName gets the handler function name

-func funcName(f interface{}) string {

-    p := reflect.ValueOf(f).Pointer()

-    rf := runtime.FuncForPC(p)

-    return rf.Name()

-}

-

-// isValidTransition checks for the new state transition is valid from current state

-func (tMap *TransitionMap) isValidTransition(trigger Trigger) bool {

-    // Validate the state transition

-    for _, state := range tMap.transitions[trigger].previousState {

-        if tMap.currentDeviceState == state {

-            return true

-        }

-    }

-    return false

-}

-

-// Handle moves the state machine to next state based on the trigger and invokes the before and

-//         after handlers

-func (tMap *TransitionMap) Handle(trigger Trigger) {

-

-    // Check whether the transtion is valid from current state

-    if !tMap.isValidTransition(trigger) {

-        log.Errorw("Invalid transition triggered ", log.Fields{"CurrentState": tMap.currentDeviceState, "Trigger": trigger})

-        return

-    }

-

-    // Invoke the before handlers

-    beforeHandlers := tMap.transitions[trigger].before

-    if beforeHandlers != nil {

-        for _, handler := range beforeHandlers {

-            log.Debugw("running-before-handler", log.Fields{"handler": funcName(handler)})

-            if err := handler(); err != nil {

-                // TODO handle error

-                return

-            }

-        }

-    } else {

-        log.Debugw("No handlers for before", log.Fields{"trigger": trigger})

-    }

-

-    // Update the state

-    tMap.currentDeviceState = tMap.transitions[trigger].currentState

-    log.Debugw("Updated device state ", log.Fields{"CurrentDeviceState": tMap.currentDeviceState})

-

-    // Invoke the after handlers

-    afterHandlers := tMap.transitions[trigger].after

-    if afterHandlers != nil {

-        for _, handler := range afterHandlers {

-            log.Debugw("running-after-handler", log.Fields{"handler": funcName(handler)})

-            if err := handler(); err != nil {

-                // TODO handle error

-                return

-            }

-        }

-    } else {

-        log.Debugw("No handlers for after", log.Fields{"trigger": trigger})

-    }

-}

+/*
+ * 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 adaptercore
+
+import (
+	"reflect"
+	"runtime"
+
+	"github.com/opencord/voltha-go/common/log"
+)
+
+// DeviceState OLT Device state
+type DeviceState int
+
+const (
+	// deviceStateNull OLT is not instantiated
+	deviceStateNull DeviceState = iota
+	// deviceStateInit OLT is instantiated
+	deviceStateInit
+	// deviceStateConnected Grpc session established with OLT
+	deviceStateConnected
+	// deviceStateUp Admin state of OLT is UP
+	deviceStateUp
+	// deviceStateDown Admin state of OLT is down
+	deviceStateDown
+)
+
+// Trigger for changing the state
+type Trigger int
+
+const (
+	// DeviceInit Go to Device init state
+	DeviceInit Trigger = iota
+	// GrpcConnected Go to connected state
+	GrpcConnected
+	// DeviceUpInd Go to Device up state
+	DeviceUpInd
+	// DeviceDownInd Go to Device down state
+	DeviceDownInd
+	// GrpcDisconnected Go to Device init state
+	GrpcDisconnected
+)
+
+// TransitionHandler function type for handling transition
+type TransitionHandler func() error
+
+// Transition to store state machine
+type Transition struct {
+	previousState []DeviceState
+	currentState  DeviceState
+	before        []TransitionHandler
+	after         []TransitionHandler
+}
+
+// TransitionMap to store all the states and current device state
+type TransitionMap struct {
+	transitions        map[Trigger]Transition
+	currentDeviceState DeviceState
+}
+
+//    OpenoltDevice state machine:
+//
+//        null ----> init ------> connected -----> up -----> down
+//                   ^ ^             |             ^         | |
+//                   | |             |             |         | |
+//                   | +-------------+             +---------+ |
+//                   |                                         |
+//                   +-----------------------------------------+
+
+// NewTransitionMap create a new state machine with all the transitions
+func NewTransitionMap(dh *DeviceHandler) *TransitionMap {
+	var transitionMap TransitionMap
+	transitionMap.currentDeviceState = deviceStateNull
+	transitionMap.transitions = make(map[Trigger]Transition)
+	// In doInit establish the grpc session
+	transitionMap.transitions[DeviceInit] =
+		Transition{
+			previousState: []DeviceState{deviceStateNull},
+			currentState:  deviceStateInit,
+			before:        []TransitionHandler{dh.doStateInit},
+			after:         []TransitionHandler{dh.postInit}}
+	// If gRpc session fails, re-establish the grpc session
+	transitionMap.transitions[GrpcDisconnected] =
+		Transition{
+			previousState: []DeviceState{deviceStateConnected, deviceStateDown},
+			currentState:  deviceStateInit,
+			before:        []TransitionHandler{dh.doStateInit},
+			after:         []TransitionHandler{dh.postInit}}
+	// in doConnected, create logical device and read the indications
+	transitionMap.transitions[GrpcConnected] =
+		Transition{
+			previousState: []DeviceState{deviceStateInit},
+			currentState:  deviceStateConnected,
+			before:        []TransitionHandler{dh.doStateConnected}}
+
+	// Once the olt UP is indication received, then do state up
+	transitionMap.transitions[DeviceUpInd] =
+		Transition{
+			previousState: []DeviceState{deviceStateConnected, deviceStateDown},
+			currentState:  deviceStateUp,
+			before:        []TransitionHandler{dh.doStateUp}}
+	// If olt DOWN indication comes then do sate down
+	transitionMap.transitions[DeviceDownInd] =
+		Transition{
+			previousState: []DeviceState{deviceStateUp},
+			currentState:  deviceStateDown,
+			before:        []TransitionHandler{dh.doStateDown}}
+
+	return &transitionMap
+}
+
+// funcName gets the handler function name
+func funcName(f interface{}) string {
+	p := reflect.ValueOf(f).Pointer()
+	rf := runtime.FuncForPC(p)
+	return rf.Name()
+}
+
+// isValidTransition checks for the new state transition is valid from current state
+func (tMap *TransitionMap) isValidTransition(trigger Trigger) bool {
+	// Validate the state transition
+	for _, state := range tMap.transitions[trigger].previousState {
+		if tMap.currentDeviceState == state {
+			return true
+		}
+	}
+	return false
+}
+
+// Handle moves the state machine to next state based on the trigger and invokes the before and
+//         after handlers
+func (tMap *TransitionMap) Handle(trigger Trigger) {
+
+	// Check whether the transtion is valid from current state
+	if !tMap.isValidTransition(trigger) {
+		log.Errorw("Invalid transition triggered ", log.Fields{"CurrentState": tMap.currentDeviceState, "Trigger": trigger})
+		return
+	}
+
+	// Invoke the before handlers
+	beforeHandlers := tMap.transitions[trigger].before
+	if beforeHandlers != nil {
+		for _, handler := range beforeHandlers {
+			log.Debugw("running-before-handler", log.Fields{"handler": funcName(handler)})
+			if err := handler(); err != nil {
+				// TODO handle error
+				return
+			}
+		}
+	} else {
+		log.Debugw("No handlers for before", log.Fields{"trigger": trigger})
+	}
+
+	// Update the state
+	tMap.currentDeviceState = tMap.transitions[trigger].currentState
+	log.Debugw("Updated device state ", log.Fields{"CurrentDeviceState": tMap.currentDeviceState})
+
+	// Invoke the after handlers
+	afterHandlers := tMap.transitions[trigger].after
+	if afterHandlers != nil {
+		for _, handler := range afterHandlers {
+			log.Debugw("running-after-handler", log.Fields{"handler": funcName(handler)})
+			if err := handler(); err != nil {
+				// TODO handle error
+				return
+			}
+		}
+	} else {
+		log.Debugw("No handlers for after", log.Fields{"trigger": trigger})
+	}
+}
diff --git a/adaptercore/openolt.go b/adaptercore/openolt.go
index 358d9f7..2678987 100644
--- a/adaptercore/openolt.go
+++ b/adaptercore/openolt.go
@@ -1,258 +1,258 @@
-/*

- * 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 adaptercore

-

-import (

-	"context"

-	"errors"

-	"fmt"

-	"sync"

-

-	com "github.com/opencord/voltha-go/adapters/common"

-	"github.com/opencord/voltha-go/common/log"

-	"github.com/opencord/voltha-go/kafka"

-	ic "github.com/opencord/voltha-protos/go/inter_container"

-	"github.com/opencord/voltha-protos/go/openflow_13"

-	"github.com/opencord/voltha-protos/go/voltha"

-)

-

-type OpenOLT struct {

-	deviceHandlers        map[string]*DeviceHandler

-	coreProxy             *com.CoreProxy

-	adapterProxy          *com.AdapterProxy

-	kafkaICProxy          *kafka.InterContainerProxy

-	numOnus               int

-	KVStoreHost           string

-        KVStorePort           int

-	KVStoreType           string

-	exitChannel           chan int

-	lockDeviceHandlersMap sync.RWMutex

-}

-

-func NewOpenOLT(ctx context.Context, kafkaICProxy *kafka.InterContainerProxy, coreProxy *com.CoreProxy, adapterProxy *com.AdapterProxy, onuNumber int, kvStoreHost string, kvStorePort int, KVStoreType string) *OpenOLT {

-	var openOLT OpenOLT

-	openOLT.exitChannel = make(chan int, 1)

-	openOLT.deviceHandlers = make(map[string]*DeviceHandler)

-	openOLT.kafkaICProxy = kafkaICProxy

-	openOLT.numOnus = onuNumber

-	openOLT.coreProxy = coreProxy

-	openOLT.adapterProxy = adapterProxy

-	openOLT.KVStoreHost = kvStoreHost

-	openOLT.KVStorePort = kvStorePort

-	openOLT.KVStoreType = KVStoreType

-	openOLT.lockDeviceHandlersMap = sync.RWMutex{}

-	return &openOLT

-}

-

-func (oo *OpenOLT) Start(ctx context.Context) error {

-	log.Info("starting-device-manager")

-	log.Info("device-manager-started")

-	return nil

-}

-

-func (oo *OpenOLT) Stop(ctx context.Context) error {

-	log.Info("stopping-device-manager")

-	oo.exitChannel <- 1

-	log.Info("device-manager-stopped")

-	return nil

-}

-

-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 (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) {

-    oo.lockDeviceHandlersMap.Lock()

-    defer oo.lockDeviceHandlersMap.Unlock()

-	if _, exist := oo.deviceHandlers[agent.deviceId]; !exist {

-		oo.deviceHandlers[agent.deviceId] = agent

-    }

-}

-

-func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) {

-    oo.lockDeviceHandlersMap.Lock()

-    defer oo.lockDeviceHandlersMap.Unlock()

-	delete(oo.deviceHandlers, agent.deviceId)

-}

-

-func (oo *OpenOLT) getDeviceHandler(deviceId string) *DeviceHandler {

-	oo.lockDeviceHandlersMap.Lock()

-	defer oo.lockDeviceHandlersMap.Unlock()

-	if agent, ok := oo.deviceHandlers[deviceId]; ok {

-		return agent

-	}

-	return nil

-}

-

-func (oo *OpenOLT) createDeviceTopic(device *voltha.Device) error {

-	log.Infow("create-device-topic", log.Fields{"deviceId": device.Id})

-	deviceTopic := kafka.Topic{Name: oo.kafkaICProxy.DefaultTopic.Name + "_" + device.Id}

-	// TODO for the offset

-	if err := oo.kafkaICProxy.SubscribeWithDefaultRequestHandler(deviceTopic, 0); err != nil {

-		log.Infow("create-device-topic-failed", log.Fields{"deviceId": device.Id, "error": err})

-		return err

-	}

-	return nil

-}

-

-func (oo *OpenOLT) Adopt_device(device *voltha.Device) error {

-    if device == nil {

-        log.Warn("device-is-nil")

-        return errors.New("nil-device")

-    }

-    log.Infow("adopt-device", log.Fields{"deviceId": device.Id})

-    var handler *DeviceHandler

-    if handler = oo.getDeviceHandler(device.Id); handler == nil {

-		handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, device, oo)

-        oo.addDeviceHandlerToMap(handler)

-        go handler.AdoptDevice(device)

-        // Launch the creation of the device topic

-		// go oo.createDeviceTopic(device)

-    }

-    return nil

-}

-

-func (oo *OpenOLT) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {

-	log.Infow("Get_ofp_device_info", log.Fields{"deviceId": device.Id})

-	if handler := oo.getDeviceHandler(device.Id); handler != nil {

-		return handler.GetOfpDeviceInfo(device)

-	}

-	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})

-	return nil, errors.New("device-handler-not-set")

-}

-

-func (oo *OpenOLT) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {

-	log.Infow("Get_ofp_port_info", log.Fields{"deviceId": device.Id})

-	if handler := oo.getDeviceHandler(device.Id); handler != nil {

-		return handler.GetOfpPortInfo(device, port_no)

-	}

-	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})

-	return nil, errors.New("device-handler-not-set")

-}

-

-func (oo *OpenOLT) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {

-	log.Infow("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})

-	targetDevice := msg.Header.ProxyDeviceId // Request?

-	if targetDevice == "" && msg.Header.ToDeviceId != "" {

-		// Typical response

-		targetDevice = msg.Header.ToDeviceId

-	}

-	if handler := oo.getDeviceHandler(targetDevice); handler != nil {

-		return handler.Process_inter_adapter_message(msg)

-	}

-	return errors.New(fmt.Sprintf("handler-not-found-%s", targetDevice))

-}

-

-func (oo *OpenOLT) Adapter_descriptor() error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Device_types() (*voltha.DeviceTypes, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Health() (*voltha.HealthStatus, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Reconcile_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Abandon_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Disable_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Reenable_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Reboot_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Self_test_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Gelete_device(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Get_device_details(device *voltha.Device) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Update_flows_incrementally(device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges) error {

-    log.Debugw("Update_flows_incrementally", log.Fields{"deviceId": device.Id,"flows":flows})

-    if handler := oo.getDeviceHandler(device.Id); handler != nil {

-        return handler.UpdateFlowsIncrementally(device, flows, groups)

-    }

-    log.Errorw("Update_flows_incrementally failed-device-handler-not-set", log.Fields{"deviceId": device.Id})

-    return errors.New("device-handler-not-set")

-}

-

-func (oo *OpenOLT) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Receive_packet_out(device *voltha.Device, egress_port_no int, msg openflow_13.PacketOut) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Suppress_alarm(filter *voltha.AlarmFilter) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Unsuppress_alarm(filter *voltha.AlarmFilter) error {

-    return errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {

-    return nil, errors.New("UnImplemented")

-}

-

-func (oo *OpenOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {

-    return nil, errors.New("UnImplemented")

-}

+/*
+ * 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 adaptercore
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"sync"
+
+	com "github.com/opencord/voltha-go/adapters/common"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/kafka"
+	ic "github.com/opencord/voltha-protos/go/inter_container"
+	"github.com/opencord/voltha-protos/go/openflow_13"
+	"github.com/opencord/voltha-protos/go/voltha"
+)
+
+type OpenOLT struct {
+	deviceHandlers        map[string]*DeviceHandler
+	coreProxy             *com.CoreProxy
+	adapterProxy          *com.AdapterProxy
+	kafkaICProxy          *kafka.InterContainerProxy
+	numOnus               int
+	KVStoreHost           string
+	KVStorePort           int
+	KVStoreType           string
+	exitChannel           chan int
+	lockDeviceHandlersMap sync.RWMutex
+}
+
+func NewOpenOLT(ctx context.Context, kafkaICProxy *kafka.InterContainerProxy, coreProxy *com.CoreProxy, adapterProxy *com.AdapterProxy, onuNumber int, kvStoreHost string, kvStorePort int, KVStoreType string) *OpenOLT {
+	var openOLT OpenOLT
+	openOLT.exitChannel = make(chan int, 1)
+	openOLT.deviceHandlers = make(map[string]*DeviceHandler)
+	openOLT.kafkaICProxy = kafkaICProxy
+	openOLT.numOnus = onuNumber
+	openOLT.coreProxy = coreProxy
+	openOLT.adapterProxy = adapterProxy
+	openOLT.KVStoreHost = kvStoreHost
+	openOLT.KVStorePort = kvStorePort
+	openOLT.KVStoreType = KVStoreType
+	openOLT.lockDeviceHandlersMap = sync.RWMutex{}
+	return &openOLT
+}
+
+func (oo *OpenOLT) Start(ctx context.Context) error {
+	log.Info("starting-device-manager")
+	log.Info("device-manager-started")
+	return nil
+}
+
+func (oo *OpenOLT) Stop(ctx context.Context) error {
+	log.Info("stopping-device-manager")
+	oo.exitChannel <- 1
+	log.Info("device-manager-stopped")
+	return nil
+}
+
+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 (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) {
+	oo.lockDeviceHandlersMap.Lock()
+	defer oo.lockDeviceHandlersMap.Unlock()
+	if _, exist := oo.deviceHandlers[agent.deviceId]; !exist {
+		oo.deviceHandlers[agent.deviceId] = agent
+	}
+}
+
+func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) {
+	oo.lockDeviceHandlersMap.Lock()
+	defer oo.lockDeviceHandlersMap.Unlock()
+	delete(oo.deviceHandlers, agent.deviceId)
+}
+
+func (oo *OpenOLT) getDeviceHandler(deviceId string) *DeviceHandler {
+	oo.lockDeviceHandlersMap.Lock()
+	defer oo.lockDeviceHandlersMap.Unlock()
+	if agent, ok := oo.deviceHandlers[deviceId]; ok {
+		return agent
+	}
+	return nil
+}
+
+func (oo *OpenOLT) createDeviceTopic(device *voltha.Device) error {
+	log.Infow("create-device-topic", log.Fields{"deviceId": device.Id})
+	deviceTopic := kafka.Topic{Name: oo.kafkaICProxy.DefaultTopic.Name + "_" + device.Id}
+	// TODO for the offset
+	if err := oo.kafkaICProxy.SubscribeWithDefaultRequestHandler(deviceTopic, 0); err != nil {
+		log.Infow("create-device-topic-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return err
+	}
+	return nil
+}
+
+func (oo *OpenOLT) Adopt_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("adopt-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	if handler = oo.getDeviceHandler(device.Id); handler == nil {
+		handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, device, oo)
+		oo.addDeviceHandlerToMap(handler)
+		go handler.AdoptDevice(device)
+		// Launch the creation of the device topic
+		// go oo.createDeviceTopic(device)
+	}
+	return nil
+}
+
+func (oo *OpenOLT) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+	log.Infow("Get_ofp_device_info", log.Fields{"deviceId": device.Id})
+	if handler := oo.getDeviceHandler(device.Id); handler != nil {
+		return handler.GetOfpDeviceInfo(device)
+	}
+	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})
+	return nil, errors.New("device-handler-not-set")
+}
+
+func (oo *OpenOLT) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+	log.Infow("Get_ofp_port_info", log.Fields{"deviceId": device.Id})
+	if handler := oo.getDeviceHandler(device.Id); handler != nil {
+		return handler.GetOfpPortInfo(device, port_no)
+	}
+	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})
+	return nil, errors.New("device-handler-not-set")
+}
+
+func (oo *OpenOLT) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+	log.Infow("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})
+	targetDevice := msg.Header.ProxyDeviceId // Request?
+	if targetDevice == "" && msg.Header.ToDeviceId != "" {
+		// Typical response
+		targetDevice = msg.Header.ToDeviceId
+	}
+	if handler := oo.getDeviceHandler(targetDevice); handler != nil {
+		return handler.Process_inter_adapter_message(msg)
+	}
+	return errors.New(fmt.Sprintf("handler-not-found-%s", targetDevice))
+}
+
+func (oo *OpenOLT) Adapter_descriptor() error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Device_types() (*voltha.DeviceTypes, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Health() (*voltha.HealthStatus, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Reconcile_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Abandon_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Disable_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Reenable_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Reboot_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Self_test_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Gelete_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Get_device_details(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Update_flows_incrementally(device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges) error {
+	log.Debugw("Update_flows_incrementally", log.Fields{"deviceId": device.Id, "flows": flows})
+	if handler := oo.getDeviceHandler(device.Id); handler != nil {
+		return handler.UpdateFlowsIncrementally(device, flows, groups)
+	}
+	log.Errorw("Update_flows_incrementally failed-device-handler-not-set", log.Fields{"deviceId": device.Id})
+	return errors.New("device-handler-not-set")
+}
+
+func (oo *OpenOLT) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Receive_packet_out(device *voltha.Device, egress_port_no int, msg openflow_13.PacketOut) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Suppress_alarm(filter *voltha.AlarmFilter) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
+	return errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (oo *OpenOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
diff --git a/adaptercore/openolt_flowmgr.go b/adaptercore/openolt_flowmgr.go
index dc250c1..03fa739 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/adaptercore/openolt_flowmgr.go
@@ -877,24 +877,24 @@
 	log.Debugw("Got child device from OLT device handler", log.Fields{"device": *onuDevice})
 	/* TODO: uncomment once voltha-proto is ready with changes */
 	/*
-	        tpPath := f.getTPpath(intfId, uni)
-	        tpDownloadMsg := &ic.TechProfileDownload{UniId: uniId, Path: tpPath}
-	        var tpDownloadMsg interface{}
-	        log.Infow("Sending Load-tech-profile-request-to-brcm-onu-adapter",log.Fields{"msg": *tpDownloadMsg})
-	        sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(context.Background(),
-	                                                           tpDownloadMsg,
-	                                                           //ic.InterAdapterMessageType_TECH_PROFILE_DOWNLOAD_REQUEST,
-	                                                           ic.InterAdapterMessageType_OMCI_REQUEST,
-	                                                           f.deviceHandler.deviceType,
-	                                                           onuDevice.Type,
-			                                           onuDevice.Id,
-	                                                           onuDevice.ProxyAddress.DeviceId, "")
-	        if sendErr != nil {
-	            log.Errorw("send techprofile-download request error", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
-	                                          "toAdapter": onuDevice.Type, "onuId": onuDevice.Id,
-	                                          "proxyDeviceId": onuDevice.ProxyAddress.DeviceId})
-	            return sendErr
-	       }
-	       log.Debugw("success Sending Load-tech-profile-request-to-brcm-onu-adapter",log.Fields{"msg":tpDownloadMsg})*/
+		        tpPath := f.getTPpath(intfId, uni)
+		        tpDownloadMsg := &ic.TechProfileDownload{UniId: uniId, Path: tpPath}
+		        var tpDownloadMsg interface{}
+		        log.Infow("Sending Load-tech-profile-request-to-brcm-onu-adapter",log.Fields{"msg": *tpDownloadMsg})
+		        sendErr := f.deviceHandler.AdapterProxy.SendInterAdapterMessage(context.Background(),
+		                                                           tpDownloadMsg,
+		                                                           //ic.InterAdapterMessageType_TECH_PROFILE_DOWNLOAD_REQUEST,
+		                                                           ic.InterAdapterMessageType_OMCI_REQUEST,
+		                                                           f.deviceHandler.deviceType,
+		                                                           onuDevice.Type,
+				                                           onuDevice.Id,
+		                                                           onuDevice.ProxyAddress.DeviceId, "")
+		        if sendErr != nil {
+		            log.Errorw("send techprofile-download request error", log.Fields{"fromAdapter": f.deviceHandler.deviceType,
+		                                          "toAdapter": onuDevice.Type, "onuId": onuDevice.Id,
+		                                          "proxyDeviceId": onuDevice.ProxyAddress.DeviceId})
+		            return sendErr
+		       }
+		       log.Debugw("success Sending Load-tech-profile-request-to-brcm-onu-adapter",log.Fields{"msg":tpDownloadMsg})*/
 	return nil
 }
diff --git a/adaptercore/resourcemanager/resourcemanager.go b/adaptercore/resourcemanager/resourcemanager.go
index 7ed1d2c..2006315 100644
--- a/adaptercore/resourcemanager/resourcemanager.go
+++ b/adaptercore/resourcemanager/resourcemanager.go
@@ -17,291 +17,291 @@
 package resourcemanager
 
 import (
-    "encoding/json"
-    "errors"
-    "fmt"
-    "strconv"
-    "strings"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"strconv"
+	"strings"
 
-    ponrmgr "github.com/opencord/voltha-go/common/ponresourcemanager"
-    "github.com/opencord/voltha-go/common/log"
-    "github.com/opencord/voltha-go/db/kvstore"
-    "github.com/opencord/voltha-go/db/model"
-    "github.com/opencord/voltha-protos/go/openolt"
+	"github.com/opencord/voltha-go/common/log"
+	ponrmgr "github.com/opencord/voltha-go/common/ponresourcemanager"
+	"github.com/opencord/voltha-go/db/kvstore"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-protos/go/openolt"
 )
 
 const KVSTORE_TIMEOUT = 5
 const BASE_PATH_KV_STORE = "service/voltha/openolt/{%s}" // service/voltha/openolt/<device_id>
 
 type OpenOltResourceMgr struct {
-    DeviceID    string         //OLT device id
-    HostAndPort string         // Host and port of the kv store to connect to
-    Args        string         // args
-    KVStore     *model.Backend // backend kv store connection handle
-    DeviceType  string
-    Host        string        // Host ip of the kv store
-    Port        int           // port of the kv store
-    DevInfo     *openolt.DeviceInfo // device information
-    // array of pon resource managers per interface technology
-    ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
+	DeviceID    string         //OLT device id
+	HostAndPort string         // Host and port of the kv store to connect to
+	Args        string         // args
+	KVStore     *model.Backend // backend kv store connection handle
+	DeviceType  string
+	Host        string              // Host ip of the kv store
+	Port        int                 // port of the kv store
+	DevInfo     *openolt.DeviceInfo // device information
+	// array of pon resource managers per interface technology
+	ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
 }
 
 func newKVClient(storeType string, address string, timeout uint32) (kvstore.Client, error) {
-    log.Infow("kv-store-type", log.Fields{"store": storeType})
-    switch storeType {
-    case "consul":
-        return kvstore.NewConsulClient(address, int(timeout))
-    case "etcd":
-        return kvstore.NewEtcdClient(address, int(timeout))
-    }
-    return nil, errors.New("unsupported-kv-store")
+	log.Infow("kv-store-type", log.Fields{"store": storeType})
+	switch storeType {
+	case "consul":
+		return kvstore.NewConsulClient(address, int(timeout))
+	case "etcd":
+		return kvstore.NewEtcdClient(address, int(timeout))
+	}
+	return nil, errors.New("unsupported-kv-store")
 }
 
 func SetKVClient(Backend string, Host string, Port int, DeviceID string) *model.Backend {
-    addr := Host + ":" + strconv.Itoa(Port)
-    // TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
-    // issue between kv store and backend , core is not calling NewBackend directly
-    kvClient, err := newKVClient(Backend, addr, KVSTORE_TIMEOUT) 
-    if err != nil {
-        log.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
-        return nil
-    }
-    kvbackend := &model.Backend{
-        Client:     kvClient,
-        StoreType:  Backend,
-        Host:       Host,
-        Port:       Port,
-        Timeout:    KVSTORE_TIMEOUT,
-        PathPrefix: fmt.Sprintf(BASE_PATH_KV_STORE, DeviceID)}
+	addr := Host + ":" + strconv.Itoa(Port)
+	// TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
+	// issue between kv store and backend , core is not calling NewBackend directly
+	kvClient, err := newKVClient(Backend, addr, KVSTORE_TIMEOUT)
+	if err != nil {
+		log.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
+		return nil
+	}
+	kvbackend := &model.Backend{
+		Client:     kvClient,
+		StoreType:  Backend,
+		Host:       Host,
+		Port:       Port,
+		Timeout:    KVSTORE_TIMEOUT,
+		PathPrefix: fmt.Sprintf(BASE_PATH_KV_STORE, DeviceID)}
 
-    return kvbackend
+	return kvbackend
 }
 
 func NewResourceMgr(DeviceID string, HostPort string, DeviceType string, DevInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
 
-    /* init a New resource maanger instance which in turn instantiates pon resource manager
-       instances according to technology. Initializes the default resource ranges for all
-       the reources.
-    */
-    var ResourceMgr OpenOltResourceMgr
-    log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", HostPort, DeviceID)
-    ResourceMgr.HostAndPort = HostPort
-    ResourceMgr.DeviceType = DeviceType  
-    ResourceMgr.DevInfo = DevInfo
-    IpPort := strings.Split(HostPort, ":")
-    ResourceMgr.Host = IpPort[0]
-    ResourceMgr.Port, _ = strconv.Atoi(IpPort[1])
+	/* init a New resource maanger instance which in turn instantiates pon resource manager
+	   instances according to technology. Initializes the default resource ranges for all
+	   the reources.
+	*/
+	var ResourceMgr OpenOltResourceMgr
+	log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", HostPort, DeviceID)
+	ResourceMgr.HostAndPort = HostPort
+	ResourceMgr.DeviceType = DeviceType
+	ResourceMgr.DevInfo = DevInfo
+	IpPort := strings.Split(HostPort, ":")
+	ResourceMgr.Host = IpPort[0]
+	ResourceMgr.Port, _ = strconv.Atoi(IpPort[1])
 
-    Backend := "etcd" /* TODO  remove this once we get backend store from registry*/
-    ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
-        ResourceMgr.Port, DeviceID)
-    if ResourceMgr.KVStore == nil {
-        log.Error("Failed to setup KV store")
-    }
-    Ranges := make(map[string]*openolt.DeviceInfo_DeviceResourceRanges)
-    RsrcMgrsByTech := make(map[string]*ponrmgr.PONResourceManager)
-    ResourceMgr.ResourceMgrs = make(map[uint32]*ponrmgr.PONResourceManager)
+	Backend := "etcd" /* TODO  remove this once we get backend store from registry*/
+	ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
+		ResourceMgr.Port, DeviceID)
+	if ResourceMgr.KVStore == nil {
+		log.Error("Failed to setup KV store")
+	}
+	Ranges := make(map[string]*openolt.DeviceInfo_DeviceResourceRanges)
+	RsrcMgrsByTech := make(map[string]*ponrmgr.PONResourceManager)
+	ResourceMgr.ResourceMgrs = make(map[uint32]*ponrmgr.PONResourceManager)
 
-    // TODO self.args = registry('main').get_args()
+	// TODO self.args = registry('main').get_args()
 
-    /*
-       If a legacy driver returns protobuf without any ranges,s synthesize one from
-       the legacy global per-device informaiton. This, in theory, is temporary until
-       the legacy drivers are upgrade to support pool ranges.
-    */
-    if DevInfo.Ranges == nil {
-        var ranges openolt.DeviceInfo_DeviceResourceRanges
-        ranges.Technology = DevInfo.GetTechnology()
+	/*
+	   If a legacy driver returns protobuf without any ranges,s synthesize one from
+	   the legacy global per-device informaiton. This, in theory, is temporary until
+	   the legacy drivers are upgrade to support pool ranges.
+	*/
+	if DevInfo.Ranges == nil {
+		var ranges openolt.DeviceInfo_DeviceResourceRanges
+		ranges.Technology = DevInfo.GetTechnology()
 
-        NumPONPorts := DevInfo.GetPonPorts()
-        var index uint32
-        for index = 0; index < NumPONPorts; index++ {
-            ranges.IntfIds = append(ranges.IntfIds, index)
-        }
+		NumPONPorts := DevInfo.GetPonPorts()
+		var index uint32
+		for index = 0; index < NumPONPorts; index++ {
+			ranges.IntfIds = append(ranges.IntfIds, index)
+		}
 
-        var Pool *openolt.DeviceInfo_DeviceResourceRanges_Pool
-        Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID
-        Pool.Start = DevInfo.OnuIdStart
-        Pool.End = DevInfo.OnuIdEnd
-        Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
-        ranges.Pools = append(ranges.Pools, Pool)
+		var Pool *openolt.DeviceInfo_DeviceResourceRanges_Pool
+		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID
+		Pool.Start = DevInfo.OnuIdStart
+		Pool.End = DevInfo.OnuIdEnd
+		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
+		ranges.Pools = append(ranges.Pools, Pool)
 
-        Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID
-        Pool.Start = DevInfo.AllocIdStart
-        Pool.End = DevInfo.AllocIdEnd
-        Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
-        ranges.Pools = append(ranges.Pools, Pool)
+		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID
+		Pool.Start = DevInfo.AllocIdStart
+		Pool.End = DevInfo.AllocIdEnd
+		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
+		ranges.Pools = append(ranges.Pools, Pool)
 
-        Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID
-        Pool.Start = DevInfo.GemportIdStart
-        Pool.End = DevInfo.GemportIdEnd
-        Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
-        ranges.Pools = append(ranges.Pools, Pool)
+		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID
+		Pool.Start = DevInfo.GemportIdStart
+		Pool.End = DevInfo.GemportIdEnd
+		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
+		ranges.Pools = append(ranges.Pools, Pool)
 
-        Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID
-        Pool.Start = DevInfo.FlowIdStart
-        Pool.End = DevInfo.FlowIdEnd
-        Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
-        ranges.Pools = append(ranges.Pools, Pool)
-    }
+		Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID
+		Pool.Start = DevInfo.FlowIdStart
+		Pool.End = DevInfo.FlowIdEnd
+		Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
+		ranges.Pools = append(ranges.Pools, Pool)
+	}
 
-    //Create a separate Resource Manager instance for each range. This assumes that
-    // each technology is represented by only a single range
-    var GlobalPONRsrcMgr *ponrmgr.PONResourceManager
-    var err error
-    for _, TechRange := range DevInfo.Ranges {
-        technology := TechRange.Technology
-        log.Debugf("Device info technology %s", technology)
-        Ranges[technology] = TechRange
-        RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, DeviceType, DeviceID,
-            Backend, ResourceMgr.Host, ResourceMgr.Port)
-        if err != nil {
-            log.Errorf("Failed to create pon resource manager instacnce for technology %s", technology)
-            return nil
-        }
-        //resource_mgrs_by_tech[technology] = resource_mgr
-        if GlobalPONRsrcMgr == nil {
-            GlobalPONRsrcMgr = RsrcMgrsByTech[technology]
-        }
-        for IntfId := range TechRange.IntfIds {
-            ResourceMgr.ResourceMgrs[uint32(IntfId)] = RsrcMgrsByTech[technology]
-        }
-        //self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
-        InitializeDeviceResourceRangeAndPool(RsrcMgrsByTech[technology], GlobalPONRsrcMgr,
-            TechRange, DevInfo)
-    }
-    // After we have initialized resource ranges, initialize the
-    // resource pools accordingly.
-    for _, PONRMgr := range RsrcMgrsByTech {
-        PONRMgr.InitDeviceResourcePool()
-    }
-    return &ResourceMgr
+	//Create a separate Resource Manager instance for each range. This assumes that
+	// each technology is represented by only a single range
+	var GlobalPONRsrcMgr *ponrmgr.PONResourceManager
+	var err error
+	for _, TechRange := range DevInfo.Ranges {
+		technology := TechRange.Technology
+		log.Debugf("Device info technology %s", technology)
+		Ranges[technology] = TechRange
+		RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, DeviceType, DeviceID,
+			Backend, ResourceMgr.Host, ResourceMgr.Port)
+		if err != nil {
+			log.Errorf("Failed to create pon resource manager instacnce for technology %s", technology)
+			return nil
+		}
+		//resource_mgrs_by_tech[technology] = resource_mgr
+		if GlobalPONRsrcMgr == nil {
+			GlobalPONRsrcMgr = RsrcMgrsByTech[technology]
+		}
+		for IntfId := range TechRange.IntfIds {
+			ResourceMgr.ResourceMgrs[uint32(IntfId)] = RsrcMgrsByTech[technology]
+		}
+		//self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
+		InitializeDeviceResourceRangeAndPool(RsrcMgrsByTech[technology], GlobalPONRsrcMgr,
+			TechRange, DevInfo)
+	}
+	// After we have initialized resource ranges, initialize the
+	// resource pools accordingly.
+	for _, PONRMgr := range RsrcMgrsByTech {
+		PONRMgr.InitDeviceResourcePool()
+	}
+	return &ResourceMgr
 }
 
 func InitializeDeviceResourceRangeAndPool(PONRMgr *ponrmgr.PONResourceManager, GlobalPONRMgr *ponrmgr.PONResourceManager,
-    TechRange *openolt.DeviceInfo_DeviceResourceRanges, DevInfo *openolt.DeviceInfo) {
+	TechRange *openolt.DeviceInfo_DeviceResourceRanges, DevInfo *openolt.DeviceInfo) {
 
-    // init the resource range pool according to the sharing type
+	// init the resource range pool according to the sharing type
 
-    log.Debugf("Resource range pool init for technology %s", PONRMgr.Technology)
-    //first load from KV profiles
-    status := PONRMgr.InitResourceRangesFromKVStore()
-    if status == false {
-        log.Debugf("Failed to load resource ranges from KV store for tech %s", PONRMgr.Technology)
-    }
+	log.Debugf("Resource range pool init for technology %s", PONRMgr.Technology)
+	//first load from KV profiles
+	status := PONRMgr.InitResourceRangesFromKVStore()
+	if status == false {
+		log.Debugf("Failed to load resource ranges from KV store for tech %s", PONRMgr.Technology)
+	}
 
-    /*
-       Then apply device specific information. If KV doesn't exist
-       or is broader than the device, the device's informationw ill
-       dictate the range limits
-    */
-    log.Debugf("Using device info to init pon resource ranges for tech", PONRMgr.Technology)
+	/*
+	   Then apply device specific information. If KV doesn't exist
+	   or is broader than the device, the device's informationw ill
+	   dictate the range limits
+	*/
+	log.Debugf("Using device info to init pon resource ranges for tech", PONRMgr.Technology)
 
-    ONUIDStart := DevInfo.OnuIdStart
-    ONUIDEnd := DevInfo.OnuIdEnd
-    ONUIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
-    ONUIDSharedPoolID := uint32(0)
-    AllocIDStart := DevInfo.AllocIdStart
-    AllocIDEnd := DevInfo.AllocIdEnd
-    AllocIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
-    AllocIDSharedPoolID := uint32(0)
-    GEMPortIDStart := DevInfo.GemportIdStart
-    GEMPortIDEnd := DevInfo.GemportIdEnd
-    GEMPortIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
-    GEMPortIDSharedPoolID := uint32(0)
-    FlowIDStart := DevInfo.FlowIdStart
-    FlowIDEnd := DevInfo.FlowIdEnd
-    FlowIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
-    FlowIDSharedPoolID := uint32(0)
+	ONUIDStart := DevInfo.OnuIdStart
+	ONUIDEnd := DevInfo.OnuIdEnd
+	ONUIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
+	ONUIDSharedPoolID := uint32(0)
+	AllocIDStart := DevInfo.AllocIdStart
+	AllocIDEnd := DevInfo.AllocIdEnd
+	AllocIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
+	AllocIDSharedPoolID := uint32(0)
+	GEMPortIDStart := DevInfo.GemportIdStart
+	GEMPortIDEnd := DevInfo.GemportIdEnd
+	GEMPortIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
+	GEMPortIDSharedPoolID := uint32(0)
+	FlowIDStart := DevInfo.FlowIdStart
+	FlowIDEnd := DevInfo.FlowIdEnd
+	FlowIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
+	FlowIDSharedPoolID := uint32(0)
 
-    var GlobalPoolID uint32
-    var FirstIntfPoolID uint32
-    var SharedPoolID uint32
+	var GlobalPoolID uint32
+	var FirstIntfPoolID uint32
+	var SharedPoolID uint32
 
-    for _, FirstIntfPoolID = range TechRange.IntfIds {
-        break
-    }
+	for _, FirstIntfPoolID = range TechRange.IntfIds {
+		break
+	}
 
-    for _, RangePool := range TechRange.Pools {
-        if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-            SharedPoolID = GlobalPoolID
-        } else if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_SAME_TECH {
-            SharedPoolID = FirstIntfPoolID
-        } else {
-            SharedPoolID = 0
-        }
-        if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID {
-            ONUIDStart = RangePool.Start
-            ONUIDEnd = RangePool.End
-            ONUIDShared = RangePool.Sharing
-            ONUIDSharedPoolID = SharedPoolID
-        } else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID {
-            AllocIDStart = RangePool.Start
-            AllocIDEnd = RangePool.End
-            AllocIDShared = RangePool.Sharing
-            AllocIDSharedPoolID = SharedPoolID
-        } else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID {
-            GEMPortIDStart = RangePool.Start
-            GEMPortIDEnd = RangePool.End
-            GEMPortIDShared = RangePool.Sharing
-            GEMPortIDSharedPoolID = SharedPoolID
-        } else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID {
-            FlowIDStart = RangePool.Start
-            FlowIDEnd = RangePool.End
-            FlowIDShared = RangePool.Sharing
-            FlowIDSharedPoolID = SharedPoolID
-        }
-    }
+	for _, RangePool := range TechRange.Pools {
+		if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
+			SharedPoolID = GlobalPoolID
+		} else if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_SAME_TECH {
+			SharedPoolID = FirstIntfPoolID
+		} else {
+			SharedPoolID = 0
+		}
+		if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID {
+			ONUIDStart = RangePool.Start
+			ONUIDEnd = RangePool.End
+			ONUIDShared = RangePool.Sharing
+			ONUIDSharedPoolID = SharedPoolID
+		} else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID {
+			AllocIDStart = RangePool.Start
+			AllocIDEnd = RangePool.End
+			AllocIDShared = RangePool.Sharing
+			AllocIDSharedPoolID = SharedPoolID
+		} else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID {
+			GEMPortIDStart = RangePool.Start
+			GEMPortIDEnd = RangePool.End
+			GEMPortIDShared = RangePool.Sharing
+			GEMPortIDSharedPoolID = SharedPoolID
+		} else if RangePool.Type == openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID {
+			FlowIDStart = RangePool.Start
+			FlowIDEnd = RangePool.End
+			FlowIDShared = RangePool.Sharing
+			FlowIDSharedPoolID = SharedPoolID
+		}
+	}
 
-    log.Debugw("Device info init", log.Fields{"technology": TechRange.Technology,
-        "onu_id_start": ONUIDStart, "onu_id_end": ONUIDEnd, "onu_id_shared_pool_id": ONUIDSharedPoolID,
-        "alloc_id_start": AllocIDStart, "alloc_id_end": AllocIDEnd,
-        "alloc_id_shared_pool_id": AllocIDSharedPoolID,
-        "gemport_id_start":        GEMPortIDStart, "gemport_id_end": GEMPortIDEnd,
-        "gemport_id_shared_pool_id": GEMPortIDSharedPoolID,
-        "flow_id_start":             FlowIDStart,
-        "flow_id_end_idx":           FlowIDEnd,
-        "flow_id_shared_pool_id":    FlowIDSharedPoolID,
-        "intf_ids":                  TechRange.IntfIds,
-        "uni_id_start":              0,
-        "uni_id_end_idx":/*MaxUNIIDperONU()*/ 1})
+	log.Debugw("Device info init", log.Fields{"technology": TechRange.Technology,
+		"onu_id_start": ONUIDStart, "onu_id_end": ONUIDEnd, "onu_id_shared_pool_id": ONUIDSharedPoolID,
+		"alloc_id_start": AllocIDStart, "alloc_id_end": AllocIDEnd,
+		"alloc_id_shared_pool_id": AllocIDSharedPoolID,
+		"gemport_id_start":        GEMPortIDStart, "gemport_id_end": GEMPortIDEnd,
+		"gemport_id_shared_pool_id": GEMPortIDSharedPoolID,
+		"flow_id_start":             FlowIDStart,
+		"flow_id_end_idx":           FlowIDEnd,
+		"flow_id_shared_pool_id":    FlowIDSharedPoolID,
+		"intf_ids":                  TechRange.IntfIds,
+		"uni_id_start":              0,
+		"uni_id_end_idx":/*MaxUNIIDperONU()*/ 1})
 
-    PONRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
-        AllocIDStart, AllocIDEnd, AllocIDSharedPoolID,
-        GEMPortIDStart, GEMPortIDEnd, GEMPortIDSharedPoolID,
-        FlowIDStart, FlowIDEnd, FlowIDSharedPoolID, 0, 1,
-        DevInfo.PonPorts, TechRange.IntfIds)
+	PONRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
+		AllocIDStart, AllocIDEnd, AllocIDSharedPoolID,
+		GEMPortIDStart, GEMPortIDEnd, GEMPortIDSharedPoolID,
+		FlowIDStart, FlowIDEnd, FlowIDSharedPoolID, 0, 1,
+		DevInfo.PonPorts, TechRange.IntfIds)
 
-    // For global sharing, make sure to refresh both local and global resource manager instances' range
+	// For global sharing, make sure to refresh both local and global resource manager instances' range
 
-    if ONUIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-        GlobalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
-            "", 0, nil)
-        PONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
-            "", 0, GlobalPONRMgr)
-    }
-    if AllocIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-        GlobalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
-            "", 0, nil)
+	if ONUIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
+		GlobalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+			"", 0, nil)
+		PONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+			"", 0, GlobalPONRMgr)
+	}
+	if AllocIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
+		GlobalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+			"", 0, nil)
 
-        PONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
-            "", 0, GlobalPONRMgr)
-    }
-    if GEMPortIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-        GlobalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
-            "", 0, nil)
-        PONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
-            "", 0, GlobalPONRMgr)
-    }
-    if FlowIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
-        GlobalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
-            "", 0, nil)
-        PONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
-            "", 0, GlobalPONRMgr)
-    }
+		PONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+			"", 0, GlobalPONRMgr)
+	}
+	if GEMPortIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
+		GlobalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+			"", 0, nil)
+		PONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+			"", 0, GlobalPONRMgr)
+	}
+	if FlowIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
+		GlobalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+			"", 0, nil)
+		PONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+			"", 0, GlobalPONRMgr)
+	}
 
-    // Make sure loaded range fits the platform bit encoding ranges
-    PONRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
+	// Make sure loaded range fits the platform bit encoding ranges
+	PONRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
 }
 
 /* TODO
@@ -328,293 +328,293 @@
 
 func (RsrcMgr *OpenOltResourceMgr) GetONUID(PONIntfID uint32) (uint32, error) {
 
-    // Get ONU id for a provided pon interface ID.
+	// Get ONU id for a provided pon interface ID.
 
-    ONUID, err := RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
-        ponrmgr.ONU_ID, 1)
-    if err != nil {
-        log.Errorf("Failed to get resource for interface %d for type %s",
-            PONIntfID, ponrmgr.ONU_ID)
-        return ONUID[0], err
-    }
-    if ONUID != nil {
-        RsrcMgr.ResourceMgrs[PONIntfID].InitResourceMap(fmt.Sprintf("%d,%d", PONIntfID, ONUID))
-    }
+	ONUID, err := RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+		ponrmgr.ONU_ID, 1)
+	if err != nil {
+		log.Errorf("Failed to get resource for interface %d for type %s",
+			PONIntfID, ponrmgr.ONU_ID)
+		return ONUID[0], err
+	}
+	if ONUID != nil {
+		RsrcMgr.ResourceMgrs[PONIntfID].InitResourceMap(fmt.Sprintf("%d,%d", PONIntfID, ONUID))
+	}
 
-    return ONUID[0], err
+	return ONUID[0], err
 }
 
 func (RsrcMgr *OpenOltResourceMgr) GetFlowID(PONIntfID uint32, ONUID uint32, UNIID uint32,
-    FlowStoreCookie interface{},
-    FlowCategory interface{}) (uint32, error) {
+	FlowStoreCookie interface{},
+	FlowCategory interface{}) (uint32, error) {
 
-    // Get flow ID for a given pon interface id, onu id and uni id.
+	// Get flow ID for a given pon interface id, onu id and uni id.
 
-    var err error
-    FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
-    FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
-    if FlowIDs != nil {
-        /* TODO once the flow id info structure is known
-                for Flow := range FlowIDs {
-                    FlowInfo := RsrcMgr.ResourceMgrs[PONIntfID].GetFlowIDInfo(FlowPath, Flow)
-                    for Info := range FlowInfo {
-                        if FlowCategory != nil &&
-                            Info[FlowCategory] == FlowCategory {
-                            return 0, Flow
-                        }
-                        if FlowStoreCookie != nil &&
-                            Info[FlowStoreCookie] == FlowStoreCookie {
-                            return 0, Flow
-                        }
-                    }
-                }
-        */
-    }
-    FlowIDs, err = RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
-        ponrmgr.FLOW_ID, 1)
-    if err != nil {
-        log.Errorf("Failed to get resource for interface %d for type %s",
-            PONIntfID, ponrmgr.FLOW_ID)
-        return FlowIDs[0], err
-    }
-    if FlowIDs != nil {
-        RsrcMgr.ResourceMgrs[PONIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
-    }
+	var err error
+	FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
+	FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
+	if FlowIDs != nil {
+		/* TODO once the flow id info structure is known
+		   for Flow := range FlowIDs {
+		       FlowInfo := RsrcMgr.ResourceMgrs[PONIntfID].GetFlowIDInfo(FlowPath, Flow)
+		       for Info := range FlowInfo {
+		           if FlowCategory != nil &&
+		               Info[FlowCategory] == FlowCategory {
+		               return 0, Flow
+		           }
+		           if FlowStoreCookie != nil &&
+		               Info[FlowStoreCookie] == FlowStoreCookie {
+		               return 0, Flow
+		           }
+		       }
+		   }
+		*/
+	}
+	FlowIDs, err = RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+		ponrmgr.FLOW_ID, 1)
+	if err != nil {
+		log.Errorf("Failed to get resource for interface %d for type %s",
+			PONIntfID, ponrmgr.FLOW_ID)
+		return FlowIDs[0], err
+	}
+	if FlowIDs != nil {
+		RsrcMgr.ResourceMgrs[PONIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
+	}
 
-    return FlowIDs[0], err
+	return FlowIDs[0], err
 }
 
 func (RsrcMgr *OpenOltResourceMgr) GetAllocID(IntfID uint32, ONUID uint32) uint32 {
 
-    // Get alloc id for a given pon interface id and onu id.
-    var err error
-    IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
-    AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
-    if AllocID != nil {
-        // Since we support only one alloc_id for the ONU at the moment,
-        // return the first alloc_id in the list, if available, for that
-        // ONU.
-        return AllocID[0]
-    }
-    AllocID, err = RsrcMgr.ResourceMgrs[IntfID].GetResourceID(IntfID,
-        ponrmgr.ALLOC_ID, 1)
+	// Get alloc id for a given pon interface id and onu id.
+	var err error
+	IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
+	AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
+	if AllocID != nil {
+		// Since we support only one alloc_id for the ONU at the moment,
+		// return the first alloc_id in the list, if available, for that
+		// ONU.
+		return AllocID[0]
+	}
+	AllocID, err = RsrcMgr.ResourceMgrs[IntfID].GetResourceID(IntfID,
+		ponrmgr.ALLOC_ID, 1)
 
-    if AllocID == nil || err != nil {
-        log.Error("Failed to allocate alloc id")
-        return 0
-    }
-    // update the resource map on KV store with the list of alloc_id
-    // allocated for the pon_intf_onu_id tuple
-    err = RsrcMgr.ResourceMgrs[IntfID].UpdateAllocIdsForOnu(IntfONUID, AllocID)
-    if err != nil {
-        log.Error("Failed to update Alloc ID")
-        return 0
-    }
-    return AllocID[0]
+	if AllocID == nil || err != nil {
+		log.Error("Failed to allocate alloc id")
+		return 0
+	}
+	// update the resource map on KV store with the list of alloc_id
+	// allocated for the pon_intf_onu_id tuple
+	err = RsrcMgr.ResourceMgrs[IntfID].UpdateAllocIdsForOnu(IntfONUID, AllocID)
+	if err != nil {
+		log.Error("Failed to update Alloc ID")
+		return 0
+	}
+	return AllocID[0]
 }
 
 func (RsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(PONPort uint32, ONUID uint32,
-    UNIID uint32, AllocID []uint32) error {
+	UNIID uint32, AllocID []uint32) error {
 
-    /* update alloc ids in kv store for a given pon interface id,
-       onu id and uni id.
-    */
-    IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
-    return RsrcMgr.ResourceMgrs[PONPort].UpdateAllocIdsForOnu(IntfONUID,
-        AllocID)
+	/* update alloc ids in kv store for a given pon interface id,
+	   onu id and uni id.
+	*/
+	IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
+	return RsrcMgr.ResourceMgrs[PONPort].UpdateAllocIdsForOnu(IntfONUID,
+		AllocID)
 }
 func (RsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(IntfID uint32, ONUID uint32,
-    UNIID uint32) []uint32 {
+	UNIID uint32) []uint32 {
 
-    /* Get gem ports for given pon interface , onu id and uni id. */
+	/* Get gem ports for given pon interface , onu id and uni id. */
 
-    IntfONUID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-    GEMPortID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfONUID)
-    if GEMPortID != nil {
-        // Since we support only one alloc_id for the ONU at the moment,
-        // return the first alloc_id in the list, if available, for that
-        // ONU.
-        return GEMPortID
-    }
-    return nil
+	IntfONUID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+	GEMPortID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfONUID)
+	if GEMPortID != nil {
+		// Since we support only one alloc_id for the ONU at the moment,
+		// return the first alloc_id in the list, if available, for that
+		// ONU.
+		return GEMPortID
+	}
+	return nil
 }
 
 func (RsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDForOnu(IntfID uint32, ONUID uint32) uint32 {
 
-    /* Get alloc ids for given pon interface and onu id. */
+	/* Get alloc ids for given pon interface and onu id. */
 
-    IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
-    AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
-    if AllocID != nil {
-        // Since we support only one alloc_id for the ONU at the moment,
-        // return the first alloc_id in the list, if available, for that
-        // ONU.
-        return AllocID[0]
-    }
-    return 0
+	IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
+	AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
+	if AllocID != nil {
+		// Since we support only one alloc_id for the ONU at the moment,
+		// return the first alloc_id in the list, if available, for that
+		// ONU.
+		return AllocID[0]
+	}
+	return 0
 }
 
 func (RsrcMgr *OpenOltResourceMgr) UpdateGEMportsPonportToOnuMapOnKVStore(GEMPorts []uint32, PonPort uint32,
-    ONUID uint32, UNIID uint32) error {
+	ONUID uint32, UNIID uint32) error {
 
-    /* Update onu and uni id associated with the gem port to the kv store. */
-    var IntfGEMPortPath string
-    Data := fmt.Sprintf("%d %d", ONUID, UNIID)
-    for _, GEM := range GEMPorts {
-        IntfGEMPortPath = fmt.Sprintf("%d,%d", PonPort, GEM)
-        Val, err := json.Marshal(Data)
-        if err != nil {
-            log.Error("failed to Marshal")
-            return err
-        }
-        // This information is used when packet_indication is received and
-        // we need to derive the ONU Id for which the packet arrived based
-        // on the pon_intf and gemport available in the packet_indication
-        if err = RsrcMgr.KVStore.Put(IntfGEMPortPath, Val); err != nil {
-            log.Errorf("Failed to update resource %s", IntfGEMPortPath)
-            return err
-        }
-    }
-    return nil
+	/* Update onu and uni id associated with the gem port to the kv store. */
+	var IntfGEMPortPath string
+	Data := fmt.Sprintf("%d %d", ONUID, UNIID)
+	for _, GEM := range GEMPorts {
+		IntfGEMPortPath = fmt.Sprintf("%d,%d", PonPort, GEM)
+		Val, err := json.Marshal(Data)
+		if err != nil {
+			log.Error("failed to Marshal")
+			return err
+		}
+		// This information is used when packet_indication is received and
+		// we need to derive the ONU Id for which the packet arrived based
+		// on the pon_intf and gemport available in the packet_indication
+		if err = RsrcMgr.KVStore.Put(IntfGEMPortPath, Val); err != nil {
+			log.Errorf("Failed to update resource %s", IntfGEMPortPath)
+			return err
+		}
+	}
+	return nil
 }
 
 func (RsrcMgr *OpenOltResourceMgr) GetONUUNIfromPONPortGEMPort(PONPort uint32, GEMPort uint32) []uint32 {
 
-    /* get the onu and uni id for a given gem port. */
-    IntfGEMPortPath := fmt.Sprintf("%d,%d", PONPort, GEMPort)
-    var GEMPortIDs []uint32
-    var Data string
-    Value, err := RsrcMgr.KVStore.Get(IntfGEMPortPath)
-    if err == nil {
-        if Value != nil {
-            Val, _ := kvstore.ToByte(Value.Value)
-            if err = json.Unmarshal(Val, &Data); err != nil {
-                log.Error("Failed to unmarshal")
-                return nil
-            }
-            IDs := strings.Split(Data, " ")
-            for _, port := range IDs {
-                Intport, _ := strconv.Atoi(port)
-                GEMPortIDs = append(GEMPortIDs, uint32(Intport))
-            }
-        }
-    }
-    return GEMPortIDs
+	/* get the onu and uni id for a given gem port. */
+	IntfGEMPortPath := fmt.Sprintf("%d,%d", PONPort, GEMPort)
+	var GEMPortIDs []uint32
+	var Data string
+	Value, err := RsrcMgr.KVStore.Get(IntfGEMPortPath)
+	if err == nil {
+		if Value != nil {
+			Val, _ := kvstore.ToByte(Value.Value)
+			if err = json.Unmarshal(Val, &Data); err != nil {
+				log.Error("Failed to unmarshal")
+				return nil
+			}
+			IDs := strings.Split(Data, " ")
+			for _, port := range IDs {
+				Intport, _ := strconv.Atoi(port)
+				GEMPortIDs = append(GEMPortIDs, uint32(Intport))
+			}
+		}
+	}
+	return GEMPortIDs
 }
 
 func (RsrcMgr *OpenOltResourceMgr) GetGEMPortID(PONPort uint32, ONUID uint32,
-    UNIID uint32, NumOfPorts uint32) ([]uint32, error) {
+	UNIID uint32, NumOfPorts uint32) ([]uint32, error) {
 
-    /* Get gem port id for a particular pon port, onu id
-       and uni id.
-    */
+	/* Get gem port id for a particular pon port, onu id
+	   and uni id.
+	*/
 
-    var err error
-    IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
+	var err error
+	IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
 
-    GEMPortList := RsrcMgr.ResourceMgrs[PONPort].GetCurrentGEMPortIDsForOnu(IntfONUID)
-    if GEMPortList != nil {
-        return GEMPortList, nil
-    }
+	GEMPortList := RsrcMgr.ResourceMgrs[PONPort].GetCurrentGEMPortIDsForOnu(IntfONUID)
+	if GEMPortList != nil {
+		return GEMPortList, nil
+	}
 
-    GEMPortList, err = RsrcMgr.ResourceMgrs[PONPort].GetResourceID(PONPort,
-        ponrmgr.GEMPORT_ID, NumOfPorts)
-    if err != nil && GEMPortList == nil {
-        log.Errorf("Failed to get gem port id for %s", IntfONUID)
-        return nil, err
-    }
+	GEMPortList, err = RsrcMgr.ResourceMgrs[PONPort].GetResourceID(PONPort,
+		ponrmgr.GEMPORT_ID, NumOfPorts)
+	if err != nil && GEMPortList == nil {
+		log.Errorf("Failed to get gem port id for %s", IntfONUID)
+		return nil, err
+	}
 
-    // update the resource map on KV store with the list of gemport_id
-    // allocated for the pon_intf_onu_id tuple
-    err = RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfONUID,
-        GEMPortList)
-    if err != nil {
-        log.Errorf("Failed to update GEM ports to kv store for %s", IntfONUID)
-        return nil, err
-    }
-    RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, PONPort,
-        ONUID, UNIID)
-    return GEMPortList, err
+	// update the resource map on KV store with the list of gemport_id
+	// allocated for the pon_intf_onu_id tuple
+	err = RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfONUID,
+		GEMPortList)
+	if err != nil {
+		log.Errorf("Failed to update GEM ports to kv store for %s", IntfONUID)
+		return nil, err
+	}
+	RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, PONPort,
+		ONUID, UNIID)
+	return GEMPortList, err
 }
 
 func (RsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(PONPort uint32, ONUID uint32,
-    UNIID uint32, GEMPortList []uint32) error {
+	UNIID uint32, GEMPortList []uint32) error {
 
-    /* Update gemport ids on to kv store for a given pon port,
-       onu id and uni id.
-    */
-    IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
-    return RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfONUID,
-        GEMPortList)
+	/* Update gemport ids on to kv store for a given pon port,
+	   onu id and uni id.
+	*/
+	IntfONUID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
+	return RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfONUID,
+		GEMPortList)
 
 }
 func (RsrcMgr *OpenOltResourceMgr) FreeONUID(IntfID uint32, ONUID []uint32) {
 
-    /* Free onu id for a particular interface.*/
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.ONU_ID, ONUID)
+	/* Free onu id for a particular interface.*/
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.ONU_ID, ONUID)
 
-    var IntfONUID string
-    for _, onu := range ONUID {
-        IntfONUID = fmt.Sprintf("%d,%d", IntfID, onu)
-        RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
-    }
-    return
+	var IntfONUID string
+	for _, onu := range ONUID {
+		IntfONUID = fmt.Sprintf("%d,%d", IntfID, onu)
+		RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
+	}
+	return
 }
 
 func (RsrcMgr *OpenOltResourceMgr) FreeFlowID(IntfID uint32, ONUID uint32,
-    UNIID uint32, FlowID []uint32) {
+	UNIID uint32, FlowID []uint32) {
 
-    /* Free flow id for a given interface, onu id and uni id.*/
+	/* Free flow id for a given interface, onu id and uni id.*/
 
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.FLOW_ID, FlowID)
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.FLOW_ID, FlowID)
 
-    var IntfONUID string
-    var err error
-    for _, flow := range FlowID {
-        IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
-        err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, flow, false)
-        if err != nil {
-            log.Error("Failed to Update flow id infor for %s", IntfONUID)
-        }
-        RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, flow)
-    }
-    return
+	var IntfONUID string
+	var err error
+	for _, flow := range FlowID {
+		IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+		err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, flow, false)
+		if err != nil {
+			log.Error("Failed to Update flow id infor for %s", IntfONUID)
+		}
+		RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, flow)
+	}
+	return
 }
 
 func (RsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(IntfID uint32, ONUID uint32) {
 
-    /* Free pon resources for a given pon interface and onu id. */
+	/* Free pon resources for a given pon interface and onu id. */
 
-    var ONUIDs []uint32
-    ONUIDs = append(ONUIDs, ONUID)
-    IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
+	var ONUIDs []uint32
+	ONUIDs = append(ONUIDs, ONUID)
+	IntfONUID := fmt.Sprintf("%d,%d", IntfID, ONUID)
 
-    AllocIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
+	AllocIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfONUID)
 
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
-        ponrmgr.ALLOC_ID,
-        AllocIDs)
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+		ponrmgr.ALLOC_ID,
+		AllocIDs)
 
-    GEMPortIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfONUID)
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
-        ponrmgr.GEMPORT_ID,
-        GEMPortIDs)
+	GEMPortIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfONUID)
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+		ponrmgr.GEMPORT_ID,
+		GEMPortIDs)
 
-    FlowIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentFlowIDsForOnu(IntfONUID)
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
-        ponrmgr.FLOW_ID,
-        FlowIDs)
-    RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
-        ponrmgr.ONU_ID,
-        ONUIDs)
+	FlowIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentFlowIDsForOnu(IntfONUID)
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+		ponrmgr.FLOW_ID,
+		FlowIDs)
+	RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+		ponrmgr.ONU_ID,
+		ONUIDs)
 
-    // Clear resource map associated with (pon_intf_id, gemport_id) tuple.
-    RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
+	// Clear resource map associated with (pon_intf_id, gemport_id) tuple.
+	RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
 
-    // Clear the ONU Id associated with the (pon_intf_id, gemport_id) tuple.
-    for _, GEM := range GEMPortIDs {
-        RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", IntfID, GEM))
-    }
+	// Clear the ONU Id associated with the (pon_intf_id, gemport_id) tuple.
+	for _, GEM := range GEMPortIDs {
+		RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", IntfID, GEM))
+	}
 }
 
 /* TODO once the flow id info structure is known
@@ -639,4 +639,3 @@
 
   return False
 */
-
diff --git a/config/config.go b/config/config.go
index 4f30e65..7eaaeb6 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1,143 +1,143 @@
-/*

- * 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 config

-

-import (

-    "flag"

-    "fmt"

-    "github.com/opencord/voltha-go/common/log"

-    "os"

-)

-

-// Open OLT default constants

-const (

-    EtcdStoreName            = "etcd"

-    default_InstanceID       = "openOlt001"

-    default_KafkaAdapterHost = "127.0.0.1"

-    default_KafkaAdapterPort = 9092

-    default_KafkaClusterHost = "127.0.0.1"

-    default_KafkaClusterPort = 9094

-    default_KVStoreType      = EtcdStoreName

-    default_KVStoreTimeout   = 5 //in seconds

-    default_KVStoreHost      = "127.0.0.1"

-    default_KVStorePort      = 2379 // Consul = 8500; Etcd = 2379

-    default_LogLevel         = 0

-    default_Banner           = false

-    default_Topic            = "openolt"

-    default_CoreTopic        = "rwcore"

-    default_OnuNumber        = 1

-)

-

-// AdapterFlags represents the set of configurations used by the read-write adaptercore service

-type AdapterFlags struct {

-    // Command line parameters

-    InstanceID       string

-    KafkaAdapterHost string

-    KafkaAdapterPort int

-    KafkaClusterHost string

-    KafkaClusterPort int

-    KVStoreType      string

-    KVStoreTimeout   int // in seconds

-    KVStoreHost      string

-    KVStorePort      int

-    Topic            string

-    CoreTopic        string

-    LogLevel         int

-    OnuNumber        int

-    Banner           bool

-}

-

-func init() {

-    log.AddPackage(log.JSON, log.WarnLevel, nil)

-}

-

-// NewRWCoreFlags returns a new RWCore config

-func NewAdapterFlags() *AdapterFlags {

-    var adapterFlags = AdapterFlags{ // Default values

-        InstanceID:       default_InstanceID,

-        KafkaAdapterHost: default_KafkaAdapterHost,

-        KafkaAdapterPort: default_KafkaAdapterPort,

-        KafkaClusterHost: default_KafkaClusterHost,

-        KafkaClusterPort: default_KafkaClusterPort,

-        KVStoreType:      default_KVStoreType,

-        KVStoreTimeout:   default_KVStoreTimeout,

-        KVStoreHost:      default_KVStoreHost,

-        KVStorePort:      default_KVStorePort,

-        Topic:            default_Topic,

-        CoreTopic:        default_CoreTopic,

-        LogLevel:         default_LogLevel,

-        OnuNumber:        default_OnuNumber,

-        Banner:           default_Banner,

-    }

-    return &adapterFlags

-}

-

-// ParseCommandArguments parses the arguments when running read-write adaptercore service

-func (so *AdapterFlags) ParseCommandArguments() {

-

-    var help string

-

-    help = fmt.Sprintf("Kafka - Adapter messaging host")

-    flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", default_KafkaAdapterHost, help)

-

-    help = fmt.Sprintf("Kafka - Adapter messaging port")

-    flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", default_KafkaAdapterPort, help)

-

-    help = fmt.Sprintf("Kafka - Cluster messaging host")

-    flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", default_KafkaClusterHost, help)

-

-    help = fmt.Sprintf("Kafka - Cluster messaging port")

-    flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", default_KafkaClusterPort, help)

-

-    help = fmt.Sprintf("Open OLT topic")

-    flag.StringVar(&(so.Topic), "adapter_topic", default_Topic, help)

-

-    help = fmt.Sprintf("Core topic")

-    flag.StringVar(&(so.CoreTopic), "core_topic", default_CoreTopic, help)

-

-    help = fmt.Sprintf("KV store type")

-    flag.StringVar(&(so.KVStoreType), "kv_store_type", default_KVStoreType, help)

-

-    help = fmt.Sprintf("The default timeout when making a kv store request")

-    flag.IntVar(&(so.KVStoreTimeout), "kv_store_request_timeout", default_KVStoreTimeout, help)

-

-    help = fmt.Sprintf("KV store host")

-    flag.StringVar(&(so.KVStoreHost), "kv_store_host", default_KVStoreHost, help)

-

-    help = fmt.Sprintf("KV store port")

-    flag.IntVar(&(so.KVStorePort), "kv_store_port", default_KVStorePort, help)

-

-    help = fmt.Sprintf("Log level")

-    flag.IntVar(&(so.LogLevel), "log_level", default_LogLevel, help)

-

-    help = fmt.Sprintf("Number of ONUs")

-    flag.IntVar(&(so.OnuNumber), "onu_number", default_OnuNumber, help)

-

-    help = fmt.Sprintf("Show startup banner log lines")

-    flag.BoolVar(&so.Banner, "banner", default_Banner, help)

-

-    flag.Parse()

-

-    containerName := getContainerInfo()

-    if len(containerName) > 0 {

-        so.InstanceID = containerName

-    }

-

-}

-

-func getContainerInfo() string {

-    return os.Getenv("HOSTNAME")

-}

+/*
+ * 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 config
+
+import (
+	"flag"
+	"fmt"
+	"github.com/opencord/voltha-go/common/log"
+	"os"
+)
+
+// Open OLT default constants
+const (
+	EtcdStoreName            = "etcd"
+	default_InstanceID       = "openOlt001"
+	default_KafkaAdapterHost = "127.0.0.1"
+	default_KafkaAdapterPort = 9092
+	default_KafkaClusterHost = "127.0.0.1"
+	default_KafkaClusterPort = 9094
+	default_KVStoreType      = EtcdStoreName
+	default_KVStoreTimeout   = 5 //in seconds
+	default_KVStoreHost      = "127.0.0.1"
+	default_KVStorePort      = 2379 // Consul = 8500; Etcd = 2379
+	default_LogLevel         = 0
+	default_Banner           = false
+	default_Topic            = "openolt"
+	default_CoreTopic        = "rwcore"
+	default_OnuNumber        = 1
+)
+
+// AdapterFlags represents the set of configurations used by the read-write adaptercore service
+type AdapterFlags struct {
+	// Command line parameters
+	InstanceID       string
+	KafkaAdapterHost string
+	KafkaAdapterPort int
+	KafkaClusterHost string
+	KafkaClusterPort int
+	KVStoreType      string
+	KVStoreTimeout   int // in seconds
+	KVStoreHost      string
+	KVStorePort      int
+	Topic            string
+	CoreTopic        string
+	LogLevel         int
+	OnuNumber        int
+	Banner           bool
+}
+
+func init() {
+	log.AddPackage(log.JSON, log.WarnLevel, nil)
+}
+
+// NewRWCoreFlags returns a new RWCore config
+func NewAdapterFlags() *AdapterFlags {
+	var adapterFlags = AdapterFlags{ // Default values
+		InstanceID:       default_InstanceID,
+		KafkaAdapterHost: default_KafkaAdapterHost,
+		KafkaAdapterPort: default_KafkaAdapterPort,
+		KafkaClusterHost: default_KafkaClusterHost,
+		KafkaClusterPort: default_KafkaClusterPort,
+		KVStoreType:      default_KVStoreType,
+		KVStoreTimeout:   default_KVStoreTimeout,
+		KVStoreHost:      default_KVStoreHost,
+		KVStorePort:      default_KVStorePort,
+		Topic:            default_Topic,
+		CoreTopic:        default_CoreTopic,
+		LogLevel:         default_LogLevel,
+		OnuNumber:        default_OnuNumber,
+		Banner:           default_Banner,
+	}
+	return &adapterFlags
+}
+
+// ParseCommandArguments parses the arguments when running read-write adaptercore service
+func (so *AdapterFlags) ParseCommandArguments() {
+
+	var help string
+
+	help = fmt.Sprintf("Kafka - Adapter messaging host")
+	flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", default_KafkaAdapterHost, help)
+
+	help = fmt.Sprintf("Kafka - Adapter messaging port")
+	flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", default_KafkaAdapterPort, help)
+
+	help = fmt.Sprintf("Kafka - Cluster messaging host")
+	flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", default_KafkaClusterHost, help)
+
+	help = fmt.Sprintf("Kafka - Cluster messaging port")
+	flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", default_KafkaClusterPort, help)
+
+	help = fmt.Sprintf("Open OLT topic")
+	flag.StringVar(&(so.Topic), "adapter_topic", default_Topic, help)
+
+	help = fmt.Sprintf("Core topic")
+	flag.StringVar(&(so.CoreTopic), "core_topic", default_CoreTopic, help)
+
+	help = fmt.Sprintf("KV store type")
+	flag.StringVar(&(so.KVStoreType), "kv_store_type", default_KVStoreType, help)
+
+	help = fmt.Sprintf("The default timeout when making a kv store request")
+	flag.IntVar(&(so.KVStoreTimeout), "kv_store_request_timeout", default_KVStoreTimeout, help)
+
+	help = fmt.Sprintf("KV store host")
+	flag.StringVar(&(so.KVStoreHost), "kv_store_host", default_KVStoreHost, help)
+
+	help = fmt.Sprintf("KV store port")
+	flag.IntVar(&(so.KVStorePort), "kv_store_port", default_KVStorePort, help)
+
+	help = fmt.Sprintf("Log level")
+	flag.IntVar(&(so.LogLevel), "log_level", default_LogLevel, help)
+
+	help = fmt.Sprintf("Number of ONUs")
+	flag.IntVar(&(so.OnuNumber), "onu_number", default_OnuNumber, help)
+
+	help = fmt.Sprintf("Show startup banner log lines")
+	flag.BoolVar(&so.Banner, "banner", default_Banner, help)
+
+	flag.Parse()
+
+	containerName := getContainerInfo()
+	if len(containerName) > 0 {
+		so.InstanceID = containerName
+	}
+
+}
+
+func getContainerInfo() string {
+	return os.Getenv("HOSTNAME")
+}
diff --git a/main.go b/main.go
index e4f22fa..9c0bd8c 100644
--- a/main.go
+++ b/main.go
@@ -21,11 +21,11 @@
 	"fmt"
 	"github.com/opencord/voltha-go/adapters"
 	com "github.com/opencord/voltha-go/adapters/common"
-	ac "github.com/opencord/voltha-openolt-adapter/adaptercore"
-	"github.com/opencord/voltha-openolt-adapter/config"
 	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/db/kvstore"
 	"github.com/opencord/voltha-go/kafka"
+	ac "github.com/opencord/voltha-openolt-adapter/adaptercore"
+	"github.com/opencord/voltha-openolt-adapter/config"
 	ic "github.com/opencord/voltha-protos/go/inter_container"
 	"github.com/opencord/voltha-protos/go/voltha"
 	"os"
@@ -236,12 +236,12 @@
 
 func (a *adapter) registerWithCore(retries int) error {
 	log.Info("registering-with-core")
-    adapterDescription := &voltha.Adapter{Id: "openolt", // Unique name for the device type
-                                          Vendor: "simulation Enterprise Inc"}
-    types := []*voltha.DeviceType{{Id: "openolt",
-                                   Adapter: "openolt",//Name of the adapter that handles device type
-                                   AcceptsBulkFlowUpdate: false,  // Currently openolt adapter does not support bulk flow handling
-                                   AcceptsAddRemoveFlowUpdates: true}}
+	adapterDescription := &voltha.Adapter{Id: "openolt", // Unique name for the device type
+		Vendor: "simulation Enterprise Inc"}
+	types := []*voltha.DeviceType{{Id: "openolt",
+		Adapter:                     "openolt", //Name of the adapter that handles device type
+		AcceptsBulkFlowUpdate:       false,     // Currently openolt adapter does not support bulk flow handling
+		AcceptsAddRemoveFlowUpdates: true}}
 	deviceTypes := &voltha.DeviceTypes{Items: types}
 	count := 0
 	for {