FTTH-46910 - Changes to communicate with ETCD as default database instead of Radis DB

Change-Id: I4419b95f85998efb607aa55caf67d046db81824c
diff --git a/database/database.go b/database/database.go
index 75f4802..63125f6 100644
--- a/database/database.go
+++ b/database/database.go
@@ -56,6 +56,9 @@
 	case "redis":
 		database.kvc, err = kvstore.NewRedisClient(address, time.Duration(timeout), false)
 		return &database, err
+	case "etcd":
+		database.kvc, err = kvstore.NewEtcdClient(ctx, address, time.Duration(timeout), log.ErrorLevel)
+		return &database, err
 	}
 	return &database, errors.New("unsupported-kv-store")
 }
@@ -1061,14 +1064,15 @@
 	logger.Infow(ctx, "Deleting all the Update Vnet Requests for device", log.Fields{"device": deviceID})
 	return nil
 }
+
 // PutOltFlowService to add OltFlowService info
 func (db *Database) PutOltFlowService(ctx context.Context, value string) error {
 	key := GetKeyPath(OltFlowServicePath)
 
-        if err := db.kvc.Put(ctx, key, value); err != nil {
-                logger.Warnw(ctx, "Put OltFlowService failed", log.Fields{"key": key})
+	if err := db.kvc.Put(ctx, key, value); err != nil {
+		logger.Warnw(ctx, "Put OltFlowService failed", log.Fields{"key": key})
 		return err
-        }
+	}
 	return nil
 }
 
diff --git a/voltha-go-controller/config.go b/voltha-go-controller/config.go
index 496c17d..fc8c716 100644
--- a/voltha-go-controller/config.go
+++ b/voltha-go-controller/config.go
@@ -44,10 +44,10 @@
 	*/
 	defaultConnectionRetryDelay = 1
 	defaultConnectionMaxRetries = 120
-	defaultKVStoreType          = "redis"
+	defaultKVStoreType          = "etcd"
 	defaultKVStoreHost          = "127.0.0.1"
-	defaultKVStorePort          = 6379
-	defaultKVStoreTimeout       = 5
+	defaultKVStorePort          = 2379
+	defaultKVStoreTimeout       = 5000000000
 	defaultKafkaAdapterHost     = "127.0.0.1"
 	defaultKafkaAdapterPort     = 9092
 	defaultInstanceID           = "VGC-01"
diff --git a/voltha-go-controller/main.go b/voltha-go-controller/main.go
index 65c2845..8bd65f8 100644
--- a/voltha-go-controller/main.go
+++ b/voltha-go-controller/main.go
@@ -33,8 +33,9 @@
 	"voltha-go-controller/internal/pkg/vpagent"
 	"voltha-go-controller/voltha-go-controller/nbi"
 
-	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
 	"voltha-go-controller/log"
+
+	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v7/pkg/probe"
 )
 
@@ -73,11 +74,13 @@
 
 }
 
-func newKVClient(storeType, address string, timeout int) (kvstore.Client, error) {
+func newKVClient(ctx context.Context, storeType, address string, timeout int) (kvstore.Client, error) {
 	logger.Infow(ctx, "kv-store-type", log.Fields{"store": storeType})
 	switch storeType {
 	case "redis":
 		return kvstore.NewRedisClient(address, time.Duration(timeout), false)
+	case "etcd":
+		return kvstore.NewEtcdClient(ctx, address, time.Duration(timeout), log.ErrorLevel)
 	}
 	return nil, errors.New("unsupported-kv-store")
 }
@@ -119,7 +122,6 @@
 	p := &probe.Probe{}
 	ctx := context.WithValue(context.Background(), probe.ProbeContextKey, p)
 
-
 	pc.Init()
 
 	// Setup logging for the program
@@ -130,9 +132,9 @@
 	if logLevel, err = log.StringToLogLevel(config.LogLevel); err != nil {
 		logLevel = log.DebugLevel
 	}
-        if err := log.SetDefaultLogger(ctx, int(logLevel), log.Fields{"instanceId": config.InstanceID}); err != nil {
-                logger.With(ctx, log.Fields{"error": err}, "Cannot setup logging")
-        }
+	if err := log.SetDefaultLogger(ctx, int(logLevel), log.Fields{"instanceId": config.InstanceID}); err != nil {
+		logger.With(ctx, log.Fields{"error": err}, "Cannot setup logging")
+	}
 
 	// Update all loggers (provisionned via init) with a common field
 	if err := log.UpdateAllLoggers(log.Fields{"instanceId": config.InstanceID}); err != nil {
@@ -140,7 +142,7 @@
 	}
 	log.SetAllLogLevel(int(logLevel))
 
-	if vgcInfo.kvClient, err = newKVClient(config.KVStoreType, config.KVStoreEndPoint, config.KVStoreTimeout); err != nil {
+	if vgcInfo.kvClient, err = newKVClient(ctx, config.KVStoreType, config.KVStoreEndPoint, config.KVStoreTimeout); err != nil {
 		logger.Errorw(ctx, "KVClient Establishment Failure", log.Fields{"Reason": err})
 	}