[VOL-2736]:host and port should be specified as a single argument not as two separate arguments

Change-Id: I14b59b4e42b1cf0821807cdb3dd6eef2094077da
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 8f6271d..8ab03f0 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -24,7 +24,6 @@
 	"fmt"
 	"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
 	"strconv"
-	"strings"
 	"sync"
 	"time"
 
@@ -100,14 +99,12 @@
 
 // OpenOltResourceMgr holds resource related information as provided below for each field
 type OpenOltResourceMgr struct {
-	DeviceID    string      // OLT device id
-	HostAndPort string      // Host and port of the kv store to connect to
-	Args        string      // args
-	KVStore     *db.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
+	DeviceID   string      // OLT device id
+	Address    string      // Host and port of the kv store to connect to
+	Args       string      // args
+	KVStore    *db.Backend // backend kv store connection handle
+	DeviceType string
+	DevInfo    *openolt.DeviceInfo // device information
 	// array of pon resource managers per interface technology
 	ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
 
@@ -137,8 +134,7 @@
 }
 
 // SetKVClient sets the KV client and return a kv backend
-func SetKVClient(backend string, Host string, Port int, DeviceID string) *db.Backend {
-	addr := Host + ":" + strconv.Itoa(Port)
+func SetKVClient(backend string, addr string, DeviceID string) *db.Backend {
 	// 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, KvstoreTimeout)
@@ -150,8 +146,7 @@
 	kvbackend := &db.Backend{
 		Client:     kvClient,
 		StoreType:  backend,
-		Host:       Host,
-		Port:       Port,
+		Address:    addr,
 		Timeout:    KvstoreTimeout,
 		PathPrefix: fmt.Sprintf(BasePathKvStore, DeviceID)}
 
@@ -161,20 +156,16 @@
 // NewResourceMgr init a New resource manager instance which in turn instantiates pon resource manager
 // instances according to technology. Initializes the default resource ranges for all
 // the resources.
-func NewResourceMgr(ctx context.Context, deviceID string, KVStoreHostPort string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
+func NewResourceMgr(ctx context.Context, deviceID string, KVStoreAddress string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
 	var ResourceMgr OpenOltResourceMgr
-	logger.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, deviceID)
-	ResourceMgr.HostAndPort = KVStoreHostPort
+	logger.Debugf("Init new resource manager , address: %s, deviceid: %s", KVStoreAddress, deviceID)
+	ResourceMgr.Address = KVStoreAddress
 	ResourceMgr.DeviceType = deviceType
 	ResourceMgr.DevInfo = devInfo
-	IPPort := strings.Split(KVStoreHostPort, ":")
-	ResourceMgr.Host = IPPort[0]
-	ResourceMgr.Port, _ = strconv.Atoi(IPPort[1])
 	NumPONPorts := devInfo.GetPonPorts()
 
 	Backend := kvStoreType
-	ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
-		ResourceMgr.Port, deviceID)
+	ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Address, deviceID)
 	if ResourceMgr.KVStore == nil {
 		logger.Error("Failed to setup KV store")
 	}
@@ -242,7 +233,7 @@
 		logger.Debugf("Device info technology %s", technology)
 		Ranges[technology] = TechRange
 		RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, deviceType, deviceID,
-			Backend, ResourceMgr.Host, ResourceMgr.Port)
+			Backend, ResourceMgr.Address)
 		if err != nil {
 			logger.Errorf("Failed to create pon resource manager instance for technology %s", technology)
 			return nil
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 2dd75ef..5b2ee29 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -70,12 +70,10 @@
 // fields mocks  OpenOltResourceMgr struct.
 type fields struct {
 	DeviceID      string
-	HostAndPort   string
+	Address       string
 	Args          string
 	KVStore       *db.Backend
 	DeviceType    string
-	Host          string
-	Port          int
 	DevInfo       *openolt.DeviceInfo
 	ResourceMgrs  map[uint32]*ponrmgr.PONResourceManager
 	NumOfPonPorts uint32
@@ -253,12 +251,10 @@
 func testResMgrObject(testResMgr *fields) *OpenOltResourceMgr {
 	var rsrMgr = OpenOltResourceMgr{
 		DeviceID:     testResMgr.DeviceID,
-		HostAndPort:  testResMgr.HostAndPort,
 		Args:         testResMgr.Args,
 		KVStore:      testResMgr.KVStore,
 		DeviceType:   testResMgr.DeviceType,
-		Host:         testResMgr.Host,
-		Port:         testResMgr.Port,
+		Address:      testResMgr.Address,
 		DevInfo:      testResMgr.DevInfo,
 		ResourceMgrs: testResMgr.ResourceMgrs,
 	}
@@ -272,11 +268,11 @@
 
 func TestNewResourceMgr(t *testing.T) {
 	type args struct {
-		deviceID        string
-		KVStoreHostPort string
-		kvStoreType     string
-		deviceType      string
-		devInfo         *openolt.DeviceInfo
+		deviceID       string
+		KVStoreAddress string
+		kvStoreType    string
+		deviceType     string
+		devInfo        *openolt.DeviceInfo
 	}
 	tests := []struct {
 		name string
@@ -292,7 +288,7 @@
 		t.Run(tt.name, func(t *testing.T) {
 			ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 			defer cancel()
-			if got := NewResourceMgr(ctx, tt.args.deviceID, tt.args.KVStoreHostPort, tt.args.kvStoreType, tt.args.deviceType, tt.args.devInfo); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+			if got := NewResourceMgr(ctx, tt.args.deviceID, tt.args.KVStoreAddress, tt.args.kvStoreType, tt.args.deviceType, tt.args.devInfo); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
 				t.Errorf("NewResourceMgr() = %v, want %v", got, tt.want)
 			}
 		})
@@ -942,8 +938,7 @@
 func TestSetKVClient(t *testing.T) {
 	type args struct {
 		backend  string
-		Host     string
-		Port     int
+		address  string
 		DeviceID string
 	}
 	tests := []struct {
@@ -951,12 +946,12 @@
 		args args
 		want *db.Backend
 	}{
-		{"setKVClient-1", args{"consul", "1.1.1.1", 1, "olt1"}, &db.Backend{}},
-		{"setKVClient-1", args{"etcd", "2.2.2.2", 2, "olt2"}, &db.Backend{}},
+		{"setKVClient-1", args{"consul", "1.1.1.1:1", "olt1"}, &db.Backend{}},
+		{"setKVClient-1", args{"etcd", "2.2.2.2:2", "olt2"}, &db.Backend{}},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			if got := SetKVClient(tt.args.backend, tt.args.Host, tt.args.Port, tt.args.DeviceID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+			if got := SetKVClient(tt.args.backend, tt.args.address, tt.args.DeviceID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
 				t.Errorf("SetKVClient() = %v, want %v", got, tt.want)
 			}
 		})