VOL-2154: Removed db/model from vendor folder
- Only kept reference to backend structure
Amendments:
- Adjusted imports to voltha-lib-go
- Adjusted vendor version for voltha-lib-go
Change-Id: I7e5ca9f2df7642d18e5a1835e20aa9062a8a3bd1
diff --git a/adaptercore/resourcemanager/resourcemanager.go b/adaptercore/resourcemanager/resourcemanager.go
index e412bb6..3dbbec8 100755
--- a/adaptercore/resourcemanager/resourcemanager.go
+++ b/adaptercore/resourcemanager/resourcemanager.go
@@ -24,8 +24,8 @@
"strconv"
"strings"
+ "github.com/opencord/voltha-lib-go/v2/pkg/db"
"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v2/pkg/db/model"
"github.com/opencord/voltha-lib-go/v2/pkg/log"
ponrmgr "github.com/opencord/voltha-lib-go/v2/pkg/ponresourcemanager"
ofp "github.com/opencord/voltha-protos/v2/go/openflow_13"
@@ -52,10 +52,10 @@
// 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 *model.Backend // backend kv store connection handle
+ 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
@@ -76,7 +76,7 @@
}
// SetKVClient sets the KV client and return a kv backend
-func SetKVClient(backend string, Host string, Port int, DeviceID string) *model.Backend {
+func SetKVClient(backend string, Host string, Port int, DeviceID string) *db.Backend {
addr := Host + ":" + strconv.Itoa(Port)
// 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
@@ -85,7 +85,7 @@
log.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
return nil
}
- kvbackend := &model.Backend{
+ kvbackend := &db.Backend{
Client: kvClient,
StoreType: backend,
Host: Host,
diff --git a/adaptercore/resourcemanager/resourcemanager_test.go b/adaptercore/resourcemanager/resourcemanager_test.go
index 0212cf6..3c45df5 100644
--- a/adaptercore/resourcemanager/resourcemanager_test.go
+++ b/adaptercore/resourcemanager/resourcemanager_test.go
@@ -26,8 +26,8 @@
import (
"encoding/json"
"errors"
+ "github.com/opencord/voltha-lib-go/v2/pkg/db"
"github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v2/pkg/db/model"
"github.com/opencord/voltha-lib-go/v2/pkg/log"
ponrmgr "github.com/opencord/voltha-lib-go/v2/pkg/ponresourcemanager"
ofp "github.com/opencord/voltha-protos/v2/go/openflow_13"
@@ -68,7 +68,7 @@
DeviceID string
HostAndPort string
Args string
- KVStore *model.Backend
+ KVStore *db.Backend
DeviceType string
Host string
Port int
@@ -83,7 +83,7 @@
// getResMgr mocks OpenOltResourceMgr struct.
func getResMgr() *fields {
var resMgr fields
- resMgr.KVStore = &model.Backend{
+ resMgr.KVStore = &db.Backend{
Client: &MockResKVClient{},
}
resMgr.ResourceMgrs = make(map[uint32]*ponrmgr.PONResourceManager)
@@ -104,7 +104,7 @@
ponMgr := &ponrmgr.PONResourceManager{
DeviceID: "onu-1",
IntfIDs: []uint32{1, 2},
- KVStore: &model.Backend{
+ KVStore: &db.Backend{
Client: &MockResKVClient{},
},
PonResourceRanges: ranges,
@@ -116,12 +116,12 @@
}
// List function implemented for KVClient.
-func (kvclient *MockResKVClient) List(key string, timeout int, lock ...bool) (map[string]*kvstore.KVPair, error) {
+func (kvclient *MockResKVClient) List(key string, timeout int) (map[string]*kvstore.KVPair, error) {
return nil, errors.New("key didn't find")
}
// Get mock function implementation for KVClient
-func (kvclient *MockResKVClient) Get(key string, timeout int, lock ...bool) (*kvstore.KVPair, error) {
+func (kvclient *MockResKVClient) Get(key string, timeout int) (*kvstore.KVPair, error) {
log.Debugw("Warning Warning Warning: Get of MockKVClient called", log.Fields{"key": key})
if key != "" {
if strings.Contains(key, MeterConfig) {
@@ -169,7 +169,7 @@
}
// Put mock function implementation for KVClient
-func (kvclient *MockResKVClient) Put(key string, value interface{}, timeout int, lock ...bool) error {
+func (kvclient *MockResKVClient) Put(key string, value interface{}, timeout int) error {
if key != "" {
return nil
}
@@ -177,7 +177,7 @@
}
// Delete mock function implementation for KVClient
-func (kvclient *MockResKVClient) Delete(key string, timeout int, lock ...bool) error {
+func (kvclient *MockResKVClient) Delete(key string, timeout int) error {
return nil
}
@@ -874,10 +874,10 @@
tests := []struct {
name string
args args
- want *model.Backend
+ want *db.Backend
}{
- {"setKVClient-1", args{"consul", "1.1.1.1", 1, "olt1"}, &model.Backend{}},
- {"setKVClient-1", args{"etcd", "2.2.2.2", 2, "olt2"}, &model.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) {