[VOL-3666] Reading TP template from default locations, write the instance using the per-stack prefix
Change-Id: I35eee9d9f5d405b08bfa97a54274f44124a0f1a3
diff --git a/go.mod b/go.mod
index bb4a98b..a651297 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.2
+ github.com/opencord/voltha-lib-go/v4 v4.0.3
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 cd1ff18..6d361f7 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.2 h1:RQoNMXQ4uYmSO2v406AzgCgr7BJk3++OhSmtehX+Uic=
-github.com/opencord/voltha-lib-go/v4 v4.0.2/go.mod h1:QgdIa7PlU0jhZT3qCPtcVt8/CpingKm4dUEROBrUBZg=
+github.com/opencord/voltha-lib-go/v4 v4.0.3 h1:bOb6T+8EsO37MPgU7i3pF81Yj2fUU43rFwv1hQsUVis=
+github.com/opencord/voltha-lib-go/v4 v4.0.3/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/pkg/mocks/mockTechprofile.go b/pkg/mocks/mockTechprofile.go
index 548a6fd..1bdbbe4 100644
--- a/pkg/mocks/mockTechprofile.go
+++ b/pkg/mocks/mockTechprofile.go
@@ -31,7 +31,7 @@
}
// SetKVClient to mock techprofile SetKVClient method
-func (m MockTechProfile) SetKVClient(ctx context.Context) *db.Backend {
+func (m MockTechProfile) SetKVClient(ctx context.Context, pathPrefix string) *db.Backend {
return &db.Backend{Client: &MockKVClient{}}
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/config.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/config.go
index 07926c5..438ea4a 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/config.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/config.go
@@ -32,7 +32,11 @@
defaultKVStoreTimeout = 5 * time.Second //in seconds
- // Tech profile path prefix in kv store
+ // Tech profile path prefix in kv store (for the TP template)
+ // NOTE that this hardcoded to service/voltha as the TP template is shared across stacks
+ defaultTpKvPathPrefix = "service/voltha/technology_profiles"
+
+ // Tech profile path prefix in kv store (for TP instances)
defaultKVPathPrefix = "%s/technology_profiles"
// Tech profile path in kv store
@@ -94,38 +98,41 @@
// TechprofileFlags represents the set of configurations used
type TechProfileFlags struct {
- KVStoreAddress string
- KVStoreType string
- KVStoreTimeout time.Duration
- KVBackend *db.Backend
- TPKVPathPrefix string
- TPFileKVPath string
- TPInstanceKVPath string
- DefaultTPName string
- TPVersion int
- NumGemPorts uint32
- DefaultPbits []string
- LogLevel int
- DefaultTechProfileID uint32
- DefaultNumGemPorts uint32
+ KVStoreAddress string
+ KVStoreType string
+ KVStoreTimeout time.Duration
+ KVBackend *db.Backend // this is the backend used to store TP instances
+ DefaultTpKVBackend *db.Backend // this is the backend used to read the TP profile
+ TPKVPathPrefix string
+ defaultTpKvPathPrefix string
+ TPFileKVPath string
+ TPInstanceKVPath string
+ DefaultTPName string
+ TPVersion int
+ NumGemPorts uint32
+ DefaultPbits []string
+ LogLevel int
+ DefaultTechProfileID uint32
+ DefaultNumGemPorts uint32
}
func NewTechProfileFlags(KVStoreType string, KVStoreAddress string, basePathKvStore string) *TechProfileFlags {
// initialize with default values
var techProfileFlags = TechProfileFlags{
- KVBackend: nil,
- KVStoreAddress: KVStoreAddress,
- KVStoreType: KVStoreType,
- KVStoreTimeout: defaultKVStoreTimeout,
- DefaultTPName: defaultTechProfileName,
- TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
- TPVersion: defaultVersion,
- TPFileKVPath: defaultTechProfileKVPath,
- TPInstanceKVPath: defaultTPInstanceKVPath,
- DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
- DefaultNumGemPorts: defaultGemportsCount,
- DefaultPbits: []string{defaultPbits},
- LogLevel: defaultLogLevel,
+ KVBackend: nil,
+ KVStoreAddress: KVStoreAddress,
+ KVStoreType: KVStoreType,
+ KVStoreTimeout: defaultKVStoreTimeout,
+ DefaultTPName: defaultTechProfileName,
+ TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
+ defaultTpKvPathPrefix: defaultTpKvPathPrefix,
+ TPVersion: defaultVersion,
+ TPFileKVPath: defaultTechProfileKVPath,
+ TPInstanceKVPath: defaultTPInstanceKVPath,
+ DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
+ DefaultNumGemPorts: defaultGemportsCount,
+ DefaultPbits: []string{defaultPbits},
+ LogLevel: defaultLogLevel,
}
return &techProfileFlags
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile.go
index c066542..e21de45 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile.go
@@ -382,13 +382,13 @@
epon = "EPON"
)
-func (t *TechProfileMgr) SetKVClient(ctx context.Context) *db.Backend {
+func (t *TechProfileMgr) SetKVClient(ctx context.Context, pathPrefix string) *db.Backend {
kvClient, err := newKVClient(ctx, t.config.KVStoreType, t.config.KVStoreAddress, t.config.KVStoreTimeout)
if err != nil {
logger.Errorw(ctx, "failed-to-create-kv-client",
log.Fields{
"type": t.config.KVStoreType, "address": t.config.KVStoreAddress,
- "timeout": t.config.KVStoreTimeout, "prefix": t.config.TPKVPathPrefix,
+ "timeout": t.config.KVStoreTimeout, "prefix": pathPrefix,
"error": err.Error(),
})
return nil
@@ -398,7 +398,7 @@
StoreType: t.config.KVStoreType,
Address: t.config.KVStoreAddress,
Timeout: t.config.KVStoreTimeout,
- PathPrefix: t.config.TPKVPathPrefix}
+ PathPrefix: pathPrefix}
/* 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
@@ -423,7 +423,8 @@
var techprofileObj TechProfileMgr
logger.Debug(ctx, "Initializing techprofile Manager")
techprofileObj.config = NewTechProfileFlags(KVStoreType, KVStoreAddress, basePathKvStore)
- techprofileObj.config.KVBackend = techprofileObj.SetKVClient(ctx)
+ techprofileObj.config.KVBackend = techprofileObj.SetKVClient(ctx, techprofileObj.config.TPKVPathPrefix)
+ techprofileObj.config.DefaultTpKVBackend = techprofileObj.SetKVClient(ctx, techprofileObj.config.defaultTpKvPathPrefix)
if techprofileObj.config.KVBackend == nil {
logger.Error(ctx, "Failed to initialize KV backend\n")
return nil, errors.New("KV backend init failed")
@@ -510,7 +511,7 @@
var kvtechprofile DefaultTechProfile
key := fmt.Sprintf(t.config.TPFileKVPath, t.resourceMgr.GetTechnology(), techProfiletblID)
logger.Debugw(ctx, "Getting techprofile from KV store", log.Fields{"techProfiletblID": techProfiletblID, "Key": key})
- kvresult, err := t.config.KVBackend.Get(ctx, key)
+ kvresult, err := t.config.DefaultTpKVBackend.Get(ctx, key)
if err != nil {
logger.Errorw(ctx, "Error while fetching value from KV store", log.Fields{"key": key})
return nil
@@ -534,7 +535,7 @@
var kvtechprofile DefaultEponProfile
key := fmt.Sprintf(t.config.TPFileKVPath, t.resourceMgr.GetTechnology(), techProfiletblID)
logger.Debugw(ctx, "Getting techprofile from KV store", log.Fields{"techProfiletblID": techProfiletblID, "Key": key})
- kvresult, err := t.config.KVBackend.Get(ctx, key)
+ kvresult, err := t.config.DefaultTpKVBackend.Get(ctx, key)
if err != nil {
logger.Errorw(ctx, "Error while fetching value from KV store", log.Fields{"key": key})
return nil
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile_if.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile_if.go
index 0c5e273..ee67d2c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile_if.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/techprofile/tech_profile_if.go
@@ -24,7 +24,7 @@
)
type TechProfileIf interface {
- SetKVClient(ctx context.Context) *db.Backend
+ SetKVClient(ctx context.Context, pathPrefix string) *db.Backend
GetTechProfileInstanceKVPath(ctx context.Context, techProfiletblID uint32, uniPortName string) string
GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (interface{}, error)
CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfId uint32) (interface{}, error)
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 4271568..89cfc50 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.2
+# github.com/opencord/voltha-lib-go/v4 v4.0.3
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