[VOL-4291] OfAgent changes for gRPC migration

Change-Id: I8da1db6df49d478ef24ec8f9bd719e9692f48a7f
diff --git a/internal/pkg/ofagent/changeEvent.go b/internal/pkg/ofagent/changeEvent.go
index f9fa98e..6ea7f12 100644
--- a/internal/pkg/ofagent/changeEvent.go
+++ b/internal/pkg/ofagent/changeEvent.go
@@ -24,7 +24,7 @@
 	"github.com/golang/protobuf/ptypes/empty"
 	ofp "github.com/opencord/goloxi/of13"
 	"github.com/opencord/ofagent-go/internal/pkg/openflow"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 	"google.golang.org/grpc"
 )
 
@@ -45,7 +45,12 @@
 	opt := grpc.EmptyCallOption{}
 	streamCtx, streamDone := context.WithCancel(log.WithSpanFromContext(context.Background(), ctx))
 	defer streamDone()
-	stream, err := ofa.volthaClient.Get().ReceiveChangeEvents(streamCtx, &empty.Empty{}, opt)
+	vc := ofa.volthaClient.Get()
+	if vc == nil {
+		logger.Error(ctx, "No client found to establish Receive Change Event Stream")
+		return
+	}
+	stream, err := vc.ReceiveChangeEvents(streamCtx, &empty.Empty{}, opt)
 	if err != nil {
 		logger.Errorw(ctx, "Unable to establish Receive Change Event Stream",
 			log.Fields{"error": err})
diff --git a/internal/pkg/ofagent/common.go b/internal/pkg/ofagent/common.go
index 9e4b78b..8e826fa 100644
--- a/internal/pkg/ofagent/common.go
+++ b/internal/pkg/ofagent/common.go
@@ -18,7 +18,7 @@
 package ofagent
 
 import (
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 )
 
 var logger log.CLogger
diff --git a/internal/pkg/ofagent/connection.go b/internal/pkg/ofagent/connection.go
index 0589fb9..0b1dab0 100644
--- a/internal/pkg/ofagent/connection.go
+++ b/internal/pkg/ofagent/connection.go
@@ -23,9 +23,9 @@
 	"github.com/golang/protobuf/ptypes/empty"
 	grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
 	grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
-	"github.com/opencord/voltha-lib-go/v5/pkg/probe"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
 	"google.golang.org/grpc"
 )
 
diff --git a/internal/pkg/ofagent/ofagent.go b/internal/pkg/ofagent/ofagent.go
index 298911d..efaf39c 100644
--- a/internal/pkg/ofagent/ofagent.go
+++ b/internal/pkg/ofagent/ofagent.go
@@ -23,10 +23,10 @@
 
 	"github.com/opencord/ofagent-go/internal/pkg/holder"
 	"github.com/opencord/ofagent-go/internal/pkg/openflow"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
-	"github.com/opencord/voltha-lib-go/v5/pkg/probe"
-	"github.com/opencord/voltha-protos/v4/go/openflow_13"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
+	"github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
 	"google.golang.org/grpc"
 )
 
diff --git a/internal/pkg/ofagent/packetIn.go b/internal/pkg/ofagent/packetIn.go
index 0b5b604..375e84f 100644
--- a/internal/pkg/ofagent/packetIn.go
+++ b/internal/pkg/ofagent/packetIn.go
@@ -24,9 +24,9 @@
 	"github.com/opencord/goloxi"
 	ofp "github.com/opencord/goloxi/of13"
 	"github.com/opencord/ofagent-go/internal/pkg/openflow"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
-	"github.com/opencord/voltha-protos/v4/go/openflow_13"
-	"github.com/opencord/voltha-protos/v4/go/voltha"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	"github.com/opencord/voltha-protos/v5/go/openflow_13"
+	"github.com/opencord/voltha-protos/v5/go/voltha"
 	"google.golang.org/grpc"
 )
 
@@ -47,7 +47,12 @@
 	opt := grpc.EmptyCallOption{}
 	streamCtx, streamDone := context.WithCancel(log.WithSpanFromContext(context.Background(), ctx))
 	defer streamDone()
-	stream, err := ofa.volthaClient.Get().ReceivePacketsIn(streamCtx, &empty.Empty{}, opt)
+	vc := ofa.volthaClient.Get()
+	if vc == nil {
+		logger.Error(ctx, "No client found to establish Receive PacketIn Stream")
+		return
+	}
+	stream, err := vc.ReceivePacketsIn(streamCtx, &empty.Empty{}, opt)
 	if err != nil {
 		logger.Errorw(ctx, "Unable to establish Receive PacketIn Stream",
 			log.Fields{"error": err})
diff --git a/internal/pkg/ofagent/packetOut.go b/internal/pkg/ofagent/packetOut.go
index 6764260..dbb908b 100644
--- a/internal/pkg/ofagent/packetOut.go
+++ b/internal/pkg/ofagent/packetOut.go
@@ -20,7 +20,7 @@
 	"context"
 	"encoding/json"
 
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 	"google.golang.org/grpc"
 )
 
@@ -40,8 +40,13 @@
 	}
 	opt := grpc.EmptyCallOption{}
 	streamCtx, streamDone := context.WithCancel(context.Background())
-	outClient, err := ofa.volthaClient.Get().StreamPacketsOut(log.WithSpanFromContext(streamCtx, ctx), opt)
 	defer streamDone()
+	vc := ofa.volthaClient.Get()
+	if vc == nil {
+		logger.Error(ctx, "No client found to create packetout stream")
+		return
+	}
+	outClient, err := vc.StreamPacketsOut(log.WithSpanFromContext(streamCtx, ctx), opt)
 	if err != nil {
 		logger.Errorw(ctx, "streamPacketOut Error creating packetout stream ", log.Fields{"error": err})
 		return
diff --git a/internal/pkg/ofagent/refresh.go b/internal/pkg/ofagent/refresh.go
index 69ab0aa..d88d68b 100644
--- a/internal/pkg/ofagent/refresh.go
+++ b/internal/pkg/ofagent/refresh.go
@@ -22,7 +22,7 @@
 
 	"github.com/golang/protobuf/ptypes/empty"
 	"github.com/opencord/ofagent-go/internal/pkg/openflow"
-	"github.com/opencord/voltha-lib-go/v5/pkg/log"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 )
 
 func (ofa *OFAgent) synchronizeDeviceList(ctx context.Context) {
@@ -52,7 +52,13 @@
 		ofa.events <- ofaEventVolthaDisconnected
 		return
 	}
-	deviceList, err := ofa.volthaClient.Get().ListLogicalDevices(log.WithSpanFromContext(context.Background(), ctx), &empty.Empty{})
+	vc := ofa.volthaClient.Get()
+	if vc == nil {
+		logger.Error(ctx, "No client found to query device list from voltha")
+		ofa.events <- ofaEventVolthaDisconnected
+		return
+	}
+	deviceList, err := vc.ListLogicalDevices(log.WithSpanFromContext(context.Background(), ctx), &empty.Empty{})
 	if err != nil {
 		logger.Errorw(ctx, "ofagent failed to query device list from voltha",
 			log.Fields{"error": err})