Techprofile module to receive KVStore config from adapter,
Re-tested openolt-adapter & openonu-adapter for EAPOL/DHCP/HSIA on Edgecore OLT & TWSH ONT kit
Change-Id: I9cdf0365d888bfa619e1c16cac01970cc5aba856
diff --git a/common/ponresourcemanager/ponresourcemanager.go b/common/ponresourcemanager/ponresourcemanager.go
index 2873dbc..b4f9130 100755
--- a/common/ponresourcemanager/ponresourcemanager.go
+++ b/common/ponresourcemanager/ponresourcemanager.go
@@ -182,7 +182,7 @@
return nil, errors.New("Failed to init KV client")
}
// Initialize techprofile for this technology
- if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr); PONMgr.TechProfileMgr == nil {
+ if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr, Backend, Host, Port); PONMgr.TechProfileMgr == nil {
log.Error("Techprofile initialization failed")
return nil, errors.New("Failed to init tech profile")
}
diff --git a/common/techprofile/config.go b/common/techprofile/config.go
index 5312dc0..9d521ed 100644
--- a/common/techprofile/config.go
+++ b/common/techprofile/config.go
@@ -30,9 +30,9 @@
defaultPbits = "0b11111111"
defaultKVStoreType = "etcd"
- defaultKVStoreTimeout = 5 //in seconds
- defaultKVStoreHost = "172.21.0.8" // TODO: Need to get IP from adapter
- defaultKVStorePort = 2379 // Consul = 8500; Etcd = 2379
+ defaultKVStoreTimeout = 5 //in seconds
+ defaultKVStoreHost = "127.0.0.1"
+ defaultKVStorePort = 2379 // Consul = 8500; Etcd = 2379
// Tech profile path prefix in kv store
defaultKVPathPrefix = "service/voltha/technology_profiles"
@@ -98,13 +98,13 @@
DefaultNumTconts uint32
}
-func NewTechProfileFlags() *TechProfileFlags {
+func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags {
// initialize with default values
var techProfileFlags = TechProfileFlags{
KVBackend: nil,
- KVStoreHost: defaultKVStoreHost,
- KVStorePort: defaultKVStorePort,
- KVStoreType: defaultKVStoreType,
+ KVStoreHost: KVStoreHost,
+ KVStorePort: KVStorePort,
+ KVStoreType: KVStoreType,
KVStoreTimeout: defaultKVStoreTimeout,
DefaultTPName: defaultTechProfileName,
TPKVPathPrefix: defaultKVPathPrefix,
diff --git a/common/techprofile/tech_profile.go b/common/techprofile/tech_profile.go
index 2879e99..e41e064 100644
--- a/common/techprofile/tech_profile.go
+++ b/common/techprofile/tech_profile.go
@@ -255,7 +255,7 @@
func newKVClient(storeType string, address string, timeout int) (kvstore.Client, error) {
- log.Infow("kv-store-type", log.Fields{"store": storeType})
+ log.Infow("kv-store", log.Fields{"storeType": storeType, "address": address})
switch storeType {
case "consul":
return kvstore.NewConsulClient(address, timeout)
@@ -265,10 +265,10 @@
return nil, errors.New("unsupported-kv-store")
}
-func NewTechProfile(resourceMgr iPonResourceMgr) (*TechProfileMgr, error) {
+func NewTechProfile(resourceMgr iPonResourceMgr, KVStoreType string, KVStoreHost string, KVStorePort int) (*TechProfileMgr, error) {
var techprofileObj TechProfileMgr
log.Debug("Initializing techprofile Manager")
- techprofileObj.config = NewTechProfileFlags()
+ techprofileObj.config = NewTechProfileFlags(KVStoreType, KVStoreHost, KVStorePort)
techprofileObj.config.KVBackend = techprofileObj.SetKVClient()
if techprofileObj.config.KVBackend == nil {
log.Error("Failed to initialize KV backend\n")