[VOL-2736]host and port should be specified as a single argument not as two separate arguments
Change-Id: I312fe753ac0fe62c942f335371e6449809ecfb85
diff --git a/pkg/ponresourcemanager/ponresourcemanager.go b/pkg/ponresourcemanager/ponresourcemanager.go
index 4cccb84..5c10b5e 100755
--- a/pkg/ponresourcemanager/ponresourcemanager.go
+++ b/pkg/ponresourcemanager/ponresourcemanager.go
@@ -22,7 +22,6 @@
"encoding/json"
"errors"
"fmt"
- "strconv"
"time"
bitmap "github.com/boljen/go-bitmap"
@@ -140,8 +139,7 @@
DeviceType string
DeviceID string
Backend string // ETCD, or consul
- Host string // host ip of the KV store
- Port int // port number for the KV store
+ Address string // address of the KV store
OLTModel string
KVStore *db.Backend
KVStoreForConfig *db.Backend
@@ -167,11 +165,10 @@
return nil, errors.New("unsupported-kv-store")
}
-func SetKVClient(Technology string, Backend string, Host string, Port int, configClient bool) *db.Backend {
- addr := Host + ":" + strconv.Itoa(Port)
+func SetKVClient(Technology string, Backend string, Addr string, configClient bool) *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, KVSTORE_RETRY_TIMEOUT)
+ kvClient, err := newKVClient(Backend, Addr, KVSTORE_RETRY_TIMEOUT)
if err != nil {
logger.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
return nil
@@ -187,8 +184,7 @@
kvbackend := &db.Backend{
Client: kvClient,
StoreType: Backend,
- Host: Host,
- Port: Port,
+ Address: Addr,
Timeout: KVSTORE_RETRY_TIMEOUT,
PathPrefix: pathPrefix}
@@ -196,27 +192,26 @@
}
// NewPONResourceManager creates a new PON resource manager.
-func NewPONResourceManager(Technology string, DeviceType string, DeviceID string, Backend string, Host string, Port int) (*PONResourceManager, error) {
+func NewPONResourceManager(Technology string, DeviceType string, DeviceID string, Backend string, Address string) (*PONResourceManager, error) {
var PONMgr PONResourceManager
PONMgr.Technology = Technology
PONMgr.DeviceType = DeviceType
PONMgr.DeviceID = DeviceID
PONMgr.Backend = Backend
- PONMgr.Host = Host
- PONMgr.Port = Port
- PONMgr.KVStore = SetKVClient(Technology, Backend, Host, Port, false)
+ PONMgr.Address = Address
+ PONMgr.KVStore = SetKVClient(Technology, Backend, Address, false)
if PONMgr.KVStore == nil {
logger.Error("KV Client initilization failed")
return nil, errors.New("Failed to init KV client")
}
// init kv client to read from the config path
- PONMgr.KVStoreForConfig = SetKVClient(Technology, Backend, Host, Port, true)
+ PONMgr.KVStoreForConfig = SetKVClient(Technology, Backend, Address, true)
if PONMgr.KVStoreForConfig == nil {
logger.Error("KV Config Client initilization failed")
return nil, errors.New("Failed to init KV Config client")
}
// Initialize techprofile for this technology
- if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr, Backend, Host, Port); PONMgr.TechProfileMgr == nil {
+ if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr, Backend, Address); PONMgr.TechProfileMgr == nil {
logger.Error("Techprofile initialization failed")
return nil, errors.New("Failed to init tech profile")
}
diff --git a/pkg/ponresourcemanager/ponresourcemanager_test.go b/pkg/ponresourcemanager/ponresourcemanager_test.go
index c2a651e..b91107c 100644
--- a/pkg/ponresourcemanager/ponresourcemanager_test.go
+++ b/pkg/ponresourcemanager/ponresourcemanager_test.go
@@ -138,7 +138,7 @@
func TestExcludeReservedGemPortIdFromThePool(t *testing.T) {
PONRMgr, err := NewPONResourceManager("gpon", "onu", "olt1",
- "etcd", "1", 1)
+ "etcd", "1:1")
if err != nil {
return
}