[VOL-1703]:
While adding flow for a device, adapter makes sync call to core to fetch
the OLT device structure. The NNI Intf ID was then fetched from the OLT
device structure.
This sync call during flow processing takes more seconds (2-3~ secs),
but core has default timeout 500ms and used to timeout. On failure it
used to re-initiate the whole procedure again. This was going on in an
endless loop.
To fix this problem, the NNI Intf ID is cached locally in the adapter,
and there is no query initiated to Core.

Change-Id: I0f9a333f44ec528517d23342c5eb7fdf1affd2e2
diff --git a/adaptercore/openolt_flowmgr.go b/adaptercore/openolt_flowmgr.go
index 570fff6..19abc26 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/adaptercore/openolt_flowmgr.go
@@ -380,11 +380,7 @@
 		return
 	}
 	log.Debugw("Created action proto", log.Fields{"action": *actionProto})
-	networkIntfId, err := f.getNniIntfID()
-	if err != nil {
-		log.Error("Error in getting NNI interface ID, Failed to add HSIA flow")
-		return
-	}
+	networkIntfId := f.deviceHandler.nniIntfId
 	flow := openolt_pb2.Flow{AccessIntfId: int32(intfId),
 		OnuId:         int32(onuId),
 		UniId:         int32(uniId),
@@ -447,11 +443,7 @@
 		log.Error("Error in making action protobuf for ul flow")
 		return
 	}
-	networkIntfId, err := f.getNniIntfID()
-	if err != nil {
-		log.Error("Error in getting NNI interface ID, Failed to add DHCP Trap Flow")
-		return
-	}
+	networkIntfId := f.deviceHandler.nniIntfId
 
 	dhcpFlow = openolt_pb2.Flow{AccessIntfId: int32(intfId),
 		OnuId:         int32(onuId),
@@ -520,11 +512,7 @@
 		return
 	}
 	log.Debugw("Created action proto", log.Fields{"action": *actionProto})
-	networkIntfId, err := f.getNniIntfID()
-	if err != nil {
-		log.Error("Error in getting NNI interface ID, Failed to add EAPOL Flow")
-		return
-	}
+	networkIntfId := f.deviceHandler.nniIntfId
 	upstreamFlow = openolt_pb2.Flow{AccessIntfId: int32(intfId),
 		OnuId:         int32(onuId),
 		UniId:         int32(uniId),
@@ -1224,11 +1212,7 @@
 	uniId := -1
 	gemPortId := -1
 	allocId := -1
-	networkInterfaceId, err := f.getNniIntfID()
-	if err != nil {
-		log.Error("Error in getting NNI interface ID, Failed to add DHCP Trap flow on NNI")
-		return
-	}
+	networkInterfaceId := f.deviceHandler.nniIntfId
 	flowStoreCookie := getFlowStoreCookie(classifier, uint32(0))
 	if present := f.resourceMgr.IsFlowCookieOnKVStore(uint32(networkInterfaceId), uint32(onuId), uint32(uniId), flowStoreCookie); present {
 		log.Debug("Flow-exists--not-re-adding")
@@ -1276,22 +1260,3 @@
 	}
 	return
 }
-
-func (f *OpenOltFlowMgr) getNniIntfID() (int32, error) {
-	device, err := f.deviceHandler.coreProxy.GetDevice(nil, f.deviceHandler.deviceId, f.deviceHandler.deviceId)
-	if err != nil {
-		log.Errorw("Failed to get device", log.Fields{"device-id": f.deviceHandler.deviceId})
-		return -1, err
-	}
-	var portNum uint32
-	for _, port := range device.Ports {
-		if port.Type == voltha.Port_ETHERNET_NNI {
-			portNum = port.PortNo
-			break
-		}
-	}
-
-	nniIntfId := IntfIdFromNniPortNum(portNum)
-	log.Debugw("NNI interface Id", log.Fields{"intf-id": nniIntfId})
-	return int32(nniIntfId), nil
-}