[VOL-3624] Parametrizing the KV-Store path
Change-Id: I44d8d72e12f83ee6c79020dd98ace4d2f1155def
diff --git a/cmd/openolt-adapter/main.go b/cmd/openolt-adapter/main.go
index 7f0c182..86e9549 100644
--- a/cmd/openolt-adapter/main.go
+++ b/cmd/openolt-adapter/main.go
@@ -98,6 +98,7 @@
// Setup Log Config
cm := conf.NewConfigManager(ctx, a.kvClient, a.config.KVStoreType, a.config.KVStoreAddress, a.config.KVStoreTimeout)
+
go conf.StartLogLevelConfigProcessing(cm, ctx)
go conf.StartLogFeaturesConfigProcessing(cm, ctx)
@@ -127,7 +128,7 @@
a.eventProxy = com.NewEventProxy(com.MsgClient(a.kafkaClient), com.MsgTopic(kafka.Topic{Name: a.config.EventTopic}))
// Create the open OLT adapter
- if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy, a.config); err != nil {
+ if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy, a.config, cm); err != nil {
logger.Fatalw(ctx, "error-starting-openolt", log.Fields{"error": err})
}
@@ -345,10 +346,10 @@
func (a *adapter) startOpenOLT(ctx context.Context, kip kafka.InterContainerProxy,
cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy,
- cfg *config.AdapterFlags) (*ac.OpenOLT, error) {
+ cfg *config.AdapterFlags, cm *conf.ConfigManager) (*ac.OpenOLT, error) {
logger.Info(ctx, "starting-open-olt")
var err error
- sOLT := ac.NewOpenOLT(ctx, a.kip, cp, ap, ep, cfg)
+ sOLT := ac.NewOpenOLT(ctx, a.kip, cp, ap, ep, cfg, cm)
if err = sOLT.Start(ctx); err != nil {
return nil, err
diff --git a/cmd/openolt-adapter/main_test.go b/cmd/openolt-adapter/main_test.go
index 6b6ea7e..3f029b6 100644
--- a/cmd/openolt-adapter/main_test.go
+++ b/cmd/openolt-adapter/main_test.go
@@ -18,6 +18,7 @@
import (
"context"
"errors"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
"testing"
"time"
@@ -104,12 +105,13 @@
func Test_startOpenOLT(t *testing.T) {
a, _ := mockserver.StartMockServers(1)
+ cm := &conf.ConfigManager{}
_ = a.StartAt(0)
defer a.StopAt(0)
ad := newMockAdapter()
oolt, err := ad.startOpenOLT(context.TODO(), nil,
- ad.coreProxy, ad.adapterProxy, ad.eventProxy, ad.config)
+ ad.coreProxy, ad.adapterProxy, ad.eventProxy, ad.config, cm)
if oolt != nil {
t.Log("Open OLT ", oolt)
}
@@ -151,6 +153,7 @@
func Test_adapter_setupRequestHandler(t *testing.T) {
ad := newMockAdapter()
+ cm := &conf.ConfigManager{}
kip := kafka.NewInterContainerProxy(
kafka.InterContainerAddress(ad.config.KafkaAdapterAddress),
@@ -161,7 +164,7 @@
_ = ad.kip.Start(context.Background())
oolt, _ := ad.startOpenOLT(context.TODO(), nil,
- ad.coreProxy, ad.adapterProxy, ad.eventProxy, ad.config)
+ ad.coreProxy, ad.adapterProxy, ad.eventProxy, ad.config, cm)
printBanner()
printVersion()
ctx := context.TODO()
diff --git a/go.mod b/go.mod
index 8cccee9..8c21d44 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
- github.com/opencord/voltha-lib-go/v4 v4.0.0
+ github.com/opencord/voltha-lib-go/v4 v4.0.1
github.com/opencord/voltha-protos/v4 v4.0.2
go.etcd.io/etcd v0.0.0-20190930204107-236ac2a90522
google.golang.org/grpc v1.25.1
diff --git a/go.sum b/go.sum
index bb10b31..e0fc267 100644
--- a/go.sum
+++ b/go.sum
@@ -202,8 +202,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v4 v4.0.0 h1:D5dK5LQ6Z/UbUEsuQuP9OoAODQuNSY1qQnuF2PsxTKw=
-github.com/opencord/voltha-lib-go/v4 v4.0.0/go.mod h1:QgdIa7PlU0jhZT3qCPtcVt8/CpingKm4dUEROBrUBZg=
+github.com/opencord/voltha-lib-go/v4 v4.0.1 h1:fSPUqOan3oXNRE1FSROq3T4KTk4sPtDQsTRrv5PLCks=
+github.com/opencord/voltha-lib-go/v4 v4.0.1/go.mod h1:QgdIa7PlU0jhZT3qCPtcVt8/CpingKm4dUEROBrUBZg=
github.com/opencord/voltha-protos/v4 v4.0.2 h1:SI25ljqftc8Tc28CgfqSE4IGCLJ5MgCmBQlE96hl9X8=
github.com/opencord/voltha-protos/v4 v4.0.2/go.mod h1:W/OIFIyvFh/C0vchRUuarIsMylEhzCRM9pNxLvkPtKc=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index a19f2ef..e720890 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -60,7 +60,8 @@
// AdapterFlags represents the set of configurations used by the read-write adaptercore service
type AdapterFlags struct {
// Command line parameters
- InstanceID string
+ AdapterName string
+ InstanceID string // NOTE what am I used for? why not cli but only ENV? TODO expose in the chart
KafkaAdapterAddress string
KafkaClusterAddress string
KVStoreType string
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 95b0a74..66ca4bb 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -34,10 +34,13 @@
"github.com/golang/protobuf/ptypes"
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/v4/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v4/pkg/config"
"github.com/opencord/voltha-lib-go/v4/pkg/flows"
"github.com/opencord/voltha-lib-go/v4/pkg/log"
"github.com/opencord/voltha-lib-go/v4/pkg/pmmetrics"
+
"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
"github.com/opencord/voltha-protos/v4/go/common"
@@ -57,6 +60,7 @@
//DeviceHandler will interact with the OLT device.
type DeviceHandler struct {
+ cm *config.ConfigManager
device *voltha.Device
coreProxy adapterif.CoreProxy
AdapterProxy adapterif.AdapterProxy
@@ -122,8 +126,9 @@
}
//NewDeviceHandler creates a new device handler
-func NewDeviceHandler(cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, device *voltha.Device, adapter *OpenOLT) *DeviceHandler {
+func NewDeviceHandler(cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, device *voltha.Device, adapter *OpenOLT, cm *config.ConfigManager) *DeviceHandler {
var dh DeviceHandler
+ dh.cm = cm
dh.coreProxy = cp
dh.AdapterProxy = ap
dh.EventProxy = ep
@@ -764,7 +769,7 @@
dh.totalPonPorts = deviceInfo.GetPonPorts()
// Instantiate resource manager
- if dh.resourceMgr = rsrcMgr.NewResourceMgr(ctx, dh.device.Id, dh.openOLT.KVStoreAddress, dh.openOLT.KVStoreType, dh.device.Type, deviceInfo); dh.resourceMgr == nil {
+ if dh.resourceMgr = rsrcMgr.NewResourceMgr(ctx, dh.device.Id, dh.openOLT.KVStoreAddress, dh.openOLT.KVStoreType, dh.device.Type, deviceInfo, dh.cm.Backend.PathPrefix); dh.resourceMgr == nil {
return olterrors.ErrResourceManagerInstantiating
}
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 68309ad..bba8601 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -19,6 +19,7 @@
import (
"context"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
"net"
"reflect"
"sync"
@@ -156,9 +157,10 @@
cp := newMockCoreProxy()
ap := &mocks.MockAdapterProxy{}
ep := &mocks.MockEventProxy{}
+ cm := &conf.ConfigManager{}
cfg := &config.AdapterFlags{OmccEncryption: true}
openOLT := &OpenOLT{coreProxy: cp, adapterProxy: ap, eventProxy: ep, config: cfg}
- dh := NewDeviceHandler(cp, ap, ep, device, openOLT)
+ dh := NewDeviceHandler(cp, ap, ep, device, openOLT, cm)
oopRanges := []*oop.DeviceInfo_DeviceResourceRanges{{
IntfIds: []uint32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
Technology: "xgs-pon",
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index d1f94ce..11317b9 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -23,6 +23,7 @@
"time"
"github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
"github.com/opencord/voltha-lib-go/v4/pkg/log"
"github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
@@ -34,6 +35,7 @@
//OpenOLT structure holds the OLT information
type OpenOLT struct {
+ configManager *conf.ConfigManager
deviceHandlers map[string]*DeviceHandler
coreProxy adapterif.CoreProxy
adapterProxy adapterif.AdapterProxy
@@ -53,7 +55,7 @@
//NewOpenOLT returns a new instance of OpenOLT
func NewOpenOLT(ctx context.Context, kafkaICProxy kafka.InterContainerProxy,
coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy,
- eventProxy adapterif.EventProxy, cfg *config.AdapterFlags) *OpenOLT {
+ eventProxy adapterif.EventProxy, cfg *config.AdapterFlags, cm *conf.ConfigManager) *OpenOLT {
var openOLT OpenOLT
openOLT.exitChannel = make(chan int, 1)
openOLT.deviceHandlers = make(map[string]*DeviceHandler)
@@ -69,6 +71,7 @@
openOLT.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
openOLT.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
openOLT.lockDeviceHandlersMap = sync.RWMutex{}
+ openOLT.configManager = cm
return &openOLT
}
@@ -118,7 +121,7 @@
logger.Infow(ctx, "adopt-device", log.Fields{"device-id": device.Id})
var handler *DeviceHandler
if handler = oo.getDeviceHandler(device.Id); handler == nil {
- handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
+ handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo, oo.configManager)
oo.addDeviceHandlerToMap(handler)
go handler.AdoptDevice(ctx, device)
// Launch the creation of the device topic
@@ -173,7 +176,7 @@
logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id})
var handler *DeviceHandler
if handler = oo.getDeviceHandler(device.Id); handler == nil {
- handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
+ handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo, oo.configManager)
oo.addDeviceHandlerToMap(handler)
handler.transitionMap = NewTransitionMap(handler)
handler.transitionMap.Handle(ctx, DeviceInit)
diff --git a/internal/pkg/core/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
index d8caa38..a7c671d 100644
--- a/internal/pkg/core/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -64,7 +64,7 @@
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- rsrMgr := resourcemanager.NewResourceMgr(ctx, "olt", "127.0.0.1:2379", "etcd", "olt", deviceinfo)
+ rsrMgr := resourcemanager.NewResourceMgr(ctx, "olt", "127.0.0.1:2379", "etcd", "olt", deviceinfo, "service/voltha")
for key := range rsrMgr.ResourceMgrs {
rsrMgr.ResourceMgrs[key].KVStore = &db.Backend{}
rsrMgr.ResourceMgrs[key].KVStore.Client = &mocks.MockKVClient{}
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index cf08161..8f83f61 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -25,6 +25,7 @@
import (
"context"
"errors"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
"reflect"
"testing"
@@ -99,19 +100,20 @@
name string
fields *fields
configFlags *config.AdapterFlags
+ cm *conf.ConfigManager
want *OpenOLT
}{
- {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"},
+ {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"}, &conf.ConfigManager{},
&OpenOLT{numOnus: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"}},
- {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"},
+ {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}, &conf.ConfigManager{},
&OpenOLT{numOnus: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}},
- {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"},
+ {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"}, &conf.ConfigManager{},
&OpenOLT{numOnus: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewOpenOLT(tt.fields.ctx, tt.fields.kafkaICProxy, tt.fields.coreProxy, tt.fields.adapterProxy,
- tt.fields.eventProxy, tt.configFlags); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
+ tt.fields.eventProxy, tt.configFlags, tt.cm); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
t.Errorf("NewOpenOLT() error = %v, wantErr %v", got, tt.want)
}
})
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index abfb73d..612ee8c 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -40,8 +40,8 @@
const (
// KvstoreTimeout specifies the time out for KV Store Connection
KvstoreTimeout = 5 * time.Second
- // BasePathKvStore - service/voltha/openolt/<device_id>
- BasePathKvStore = "service/voltha/openolt/{%s}"
+ // BasePathKvStore - <pathPrefix>/openolt/<device_id>
+ BasePathKvStore = "%s/openolt/{%s}"
// TpIDPathSuffix - <(pon_id, onu_id, uni_id)>/tp_id
TpIDPathSuffix = "{%d,%d,%d}/tp_id"
//MeterIDPathSuffix - <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction>
@@ -140,7 +140,7 @@
}
// SetKVClient sets the KV client and return a kv backend
-func SetKVClient(ctx context.Context, backend string, addr string, DeviceID string) *db.Backend {
+func SetKVClient(ctx context.Context, backend string, addr string, DeviceID string, basePathKvStore 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(ctx, backend, addr, KvstoreTimeout)
@@ -154,7 +154,7 @@
StoreType: backend,
Address: addr,
Timeout: KvstoreTimeout,
- PathPrefix: fmt.Sprintf(BasePathKvStore, DeviceID)}
+ PathPrefix: fmt.Sprintf(BasePathKvStore, basePathKvStore, DeviceID)}
return kvbackend
}
@@ -162,7 +162,7 @@
// 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, KVStoreAddress 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, basePathKvStore string) *OpenOltResourceMgr {
var ResourceMgr OpenOltResourceMgr
logger.Debugf(ctx, "Init new resource manager , address: %s, device-id: %s", KVStoreAddress, deviceID)
ResourceMgr.DeviceID = deviceID
@@ -172,7 +172,7 @@
NumPONPorts := devInfo.GetPonPorts()
Backend := kvStoreType
- ResourceMgr.KVStore = SetKVClient(ctx, Backend, ResourceMgr.Address, deviceID)
+ ResourceMgr.KVStore = SetKVClient(ctx, Backend, ResourceMgr.Address, deviceID, basePathKvStore)
if ResourceMgr.KVStore == nil {
logger.Error(ctx, "Failed to setup KV store")
}
@@ -241,7 +241,7 @@
Ranges[technology] = TechRange
RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(ctx, technology, deviceType, deviceID,
- Backend, ResourceMgr.Address)
+ Backend, ResourceMgr.Address, basePathKvStore)
if err != nil {
logger.Errorf(ctx, "Failed to create pon resource manager instance for technology %s", technology)
return nil
@@ -1213,7 +1213,7 @@
//remove them one by one
for key := range value {
// Formulate the right key path suffix ti be delete
- stringToBeReplaced := fmt.Sprintf(BasePathKvStore, RsrcMgr.DeviceID) + "/"
+ stringToBeReplaced := fmt.Sprintf(BasePathKvStore, RsrcMgr.KVStore.PathPrefix, RsrcMgr.DeviceID) + "/"
replacedWith := ""
key = strings.Replace(key, stringToBeReplaced, replacedWith, 1)
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 5901c7c..50fcf4a 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -274,6 +274,7 @@
kvStoreType string
deviceType string
devInfo *openolt.DeviceInfo
+ kvStorePrefix string
}
tests := []struct {
name string
@@ -281,15 +282,15 @@
want *OpenOltResourceMgr
}{
{"NewResourceMgr-1", args{"olt1", "1:2", "consul",
- "onu", &openolt.DeviceInfo{OnuIdStart: 1, OnuIdEnd: 1}}, &OpenOltResourceMgr{}},
+ "onu", &openolt.DeviceInfo{OnuIdStart: 1, OnuIdEnd: 1}, "service/voltha"}, &OpenOltResourceMgr{}},
{"NewResourceMgr-2", args{"olt2", "3:4", "etcd",
- "onu", &openolt.DeviceInfo{OnuIdStart: 1, OnuIdEnd: 1}}, &OpenOltResourceMgr{}},
+ "onu", &openolt.DeviceInfo{OnuIdStart: 1, OnuIdEnd: 1}, "service/voltha"}, &OpenOltResourceMgr{}},
}
for _, tt := range tests {
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.KVStoreAddress, 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, tt.args.kvStorePrefix); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("NewResourceMgr() = %v, want %v", got, tt.want)
}
})
@@ -827,21 +828,22 @@
func TestSetKVClient(t *testing.T) {
type args struct {
- backend string
- address string
- DeviceID string
+ backend string
+ address string
+ DeviceID string
+ kvStorePrefix string
}
tests := []struct {
name string
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", "service/voltha"}, &db.Backend{}},
+ {"setKVClient-1", args{"etcd", "2.2.2.2:2", "olt2", "service/voltha"}, &db.Backend{}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := SetKVClient(context.Background(), tt.args.backend, tt.args.address, tt.args.DeviceID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+ if got := SetKVClient(context.Background(), tt.args.backend, tt.args.address, tt.args.DeviceID, tt.args.kvStorePrefix); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("SetKVClient() = %v, want %v", got, tt.want)
}
})
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/ponresourcemanager/ponresourcemanager.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/ponresourcemanager/ponresourcemanager.go
index bbfebe3..b4c2fec 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/ponresourcemanager/ponresourcemanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/ponresourcemanager/ponresourcemanager.go
@@ -41,7 +41,8 @@
//Constants for passing command line arugments
OLT_MODEL_ARG = "--olt_model"
- PATH_PREFIX = "service/voltha/resource_manager/{%s}"
+
+ PATH_PREFIX = "%s/resource_manager/{%s}"
/*The path under which configuration data is stored is defined as technology/device agnostic.
That means the path does not include any specific technology/device variable. Using technology/device
@@ -51,7 +52,8 @@
Default kv client of PonResourceManager reads from/writes to PATH_PREFIX defined above.
That is why, an additional kv client (named KVStoreForConfig) is defined to read from the config path.
*/
- PATH_PREFIX_FOR_CONFIG = "service/voltha/resource_manager/config"
+
+ PATH_PREFIX_FOR_CONFIG = "%s/resource_manager/config"
/*The resource ranges for a given device model should be placed
at 'resource_manager/<technology>/resource_ranges/<olt_model_type>'
path on the KV store.
@@ -165,7 +167,7 @@
return nil, errors.New("unsupported-kv-store")
}
-func SetKVClient(ctx context.Context, Technology string, Backend string, Addr string, configClient bool) *db.Backend {
+func SetKVClient(ctx context.Context, Technology string, Backend string, Addr string, configClient bool, basePathKvStore 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(ctx, Backend, Addr, KVSTORE_RETRY_TIMEOUT)
@@ -176,9 +178,9 @@
var pathPrefix string
if configClient {
- pathPrefix = PATH_PREFIX_FOR_CONFIG
+ pathPrefix = fmt.Sprintf(PATH_PREFIX_FOR_CONFIG, basePathKvStore)
} else {
- pathPrefix = fmt.Sprintf(PATH_PREFIX, Technology)
+ pathPrefix = fmt.Sprintf(PATH_PREFIX, basePathKvStore, Technology)
}
kvbackend := &db.Backend{
@@ -192,20 +194,20 @@
}
// NewPONResourceManager creates a new PON resource manager.
-func NewPONResourceManager(ctx context.Context, Technology string, DeviceType string, DeviceID string, Backend string, Address string) (*PONResourceManager, error) {
+func NewPONResourceManager(ctx context.Context, Technology string, DeviceType string, DeviceID string, Backend string, Address string, basePathKvStore string) (*PONResourceManager, error) {
var PONMgr PONResourceManager
PONMgr.Technology = Technology
PONMgr.DeviceType = DeviceType
PONMgr.DeviceID = DeviceID
PONMgr.Backend = Backend
PONMgr.Address = Address
- PONMgr.KVStore = SetKVClient(ctx, Technology, Backend, Address, false)
+ PONMgr.KVStore = SetKVClient(ctx, Technology, Backend, Address, false, basePathKvStore)
if PONMgr.KVStore == nil {
logger.Error(ctx, "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(ctx, Technology, Backend, Address, true)
+ PONMgr.KVStoreForConfig = SetKVClient(ctx, Technology, Backend, Address, true, basePathKvStore)
if PONMgr.KVStoreForConfig == nil {
logger.Error(ctx, "KV Config Client initilization failed")
return nil, errors.New("Failed to init KV Config client")
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 181b84c..ea4f9cd 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -70,7 +70,7 @@
github.com/mitchellh/go-homedir
# github.com/mitchellh/mapstructure v1.1.2
github.com/mitchellh/mapstructure
-# github.com/opencord/voltha-lib-go/v4 v4.0.0
+# github.com/opencord/voltha-lib-go/v4 v4.0.1
github.com/opencord/voltha-lib-go/v4/pkg/adapters
github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v4/pkg/adapters/common