[VOL-5051] - Build and deploy voltctl
[VOL-5152]
[VOL-4961]
[VOL-5063]
[VOL-4966]
[VOL-4893]
[VOL-4906]
go.mod
go.sum
vendor/modules.txt
------------------
o Update voltha-lib-go dep to 7.5.3
o Update voltha-protos dep to 5.4.11
o make mod-update
Makefile
makefiles/
o Add more repo:onf-make makefile logic
o make LOCAL_FIX_PERMS=1 mod-update need to work around docker perm problems.
internal/
pkg/
vendor/
---------
o Update copyright ending date to span 2024.
o make mod-update to regenerate vendor/
Change-Id: Ib89fd6a9cc15c7e08b1274b110dd8141832557e9
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/LICENSE b/vendor/github.com/opencord/voltha-lib-go/v7/LICENSE
new file mode 100644
index 0000000..ab45a28
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/LICENSE
@@ -0,0 +1,204 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+This project bundles https://github.com/juanchopanza/cppblog/blob/master/Concurrency/Queue/Queue.h
+which is licensed under BSD 2-Clause License.
\ No newline at end of file
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/common.go
index 4813ba1..c07e737 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-present Open Networking Foundation
+ * Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/configmanager.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/configmanager.go
index c489407..747f239 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/configmanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/configmanager.go
@@ -1,17 +1,17 @@
/*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
*/
package config
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logcontroller.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logcontroller.go
index b58f999..8cc4e52 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logcontroller.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logcontroller.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-present Open Networking Foundation
+ * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logfeaturescontroller.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logfeaturescontroller.go
index 579c1de..8f4131e 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logfeaturescontroller.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/config/logfeaturescontroller.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-present Open Networking Foundation
+ * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
index 2e57a27..dc24fe6 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-present Open Networking Foundation
+ * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,6 +75,10 @@
func (b *Backend) newClient(ctx context.Context, address string, timeout time.Duration) (kvstore.Client, error) {
switch b.StoreType {
+ case "redis":
+ return kvstore.NewRedisClient(address, timeout, false)
+ case "redis-sentinel":
+ return kvstore.NewRedisClient(address, timeout, true)
case "etcd":
return kvstore.NewEtcdClient(ctx, address, timeout, log.WarnLevel)
}
@@ -176,7 +180,7 @@
// List retrieves one or more items that match the specified key
func (b *Backend) List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error) {
- span, ctx := log.CreateChildSpan(ctx, "etcd-list")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-list")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
@@ -191,7 +195,7 @@
// Get retrieves an item that matches the specified key
func (b *Backend) Get(ctx context.Context, key string) (*kvstore.KVPair, error) {
- span, ctx := log.CreateChildSpan(ctx, "etcd-get")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-get")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
@@ -206,7 +210,7 @@
// Put stores an item value under the specifed key
func (b *Backend) Put(ctx context.Context, key string, value interface{}) error {
- span, ctx := log.CreateChildSpan(ctx, "etcd-put")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-put")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
@@ -221,7 +225,7 @@
// Delete removes an item under the specified key
func (b *Backend) Delete(ctx context.Context, key string) error {
- span, ctx := log.CreateChildSpan(ctx, "etcd-delete")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-delete")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
@@ -234,9 +238,8 @@
return err
}
-// DeleteWithPrefix removes items having prefix key
func (b *Backend) DeleteWithPrefix(ctx context.Context, prefixKey string) error {
- span, ctx := log.CreateChildSpan(ctx, "etcd-delete-with-prefix")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-delete-with-prefix")
defer span.Finish()
formattedPath := b.makePath(ctx, prefixKey)
@@ -251,7 +254,7 @@
// CreateWatch starts watching events for the specified key
func (b *Backend) CreateWatch(ctx context.Context, key string, withPrefix bool) chan *kvstore.Event {
- span, ctx := log.CreateChildSpan(ctx, "etcd-create-watch")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-create-watch")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
@@ -262,7 +265,7 @@
// DeleteWatch stops watching events for the specified key
func (b *Backend) DeleteWatch(ctx context.Context, key string, ch chan *kvstore.Event) {
- span, ctx := log.CreateChildSpan(ctx, "etcd-delete-watch")
+ span, ctx := log.CreateChildSpan(ctx, "kvs-delete-watch")
defer span.Finish()
formattedPath := b.makePath(ctx, key)
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/common.go
index d8a0571..b6694de 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-present Open Networking Foundation
+ * Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
index e4b1fff..c59f4b3 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
@@ -1,17 +1,17 @@
/*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
*/
package kvstore
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/common.go
index 8ac2a4a..0617329 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-present Open Networking Foundation
+ * Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
index 6ca5329..8439afe 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
@@ -1,17 +1,17 @@
/*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
*/
package kvstore
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdpool.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdpool.go
index 4d33c27..6c7c838 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdpool.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdpool.go
@@ -1,17 +1,17 @@
/*
- * Copyright 2021-present Open Networking Foundation
+* Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
*/
package kvstore
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/kvutils.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/kvutils.go
index ca57542..28cd682 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/kvutils.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/kvutils.go
@@ -1,17 +1,17 @@
/*
- * Copyright 2018-present Open Networking Foundation
+* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+* http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
*/
package kvstore
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go
new file mode 100644
index 0000000..742916c
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go
@@ -0,0 +1,417 @@
+/*
+* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
+
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+
+* http://www.apache.org/licenses/LICENSE-2.0
+
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+package kvstore
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/go-redis/redis/v8"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+)
+
+type RedisClient struct {
+ redisAPI *redis.Client
+ keyReservations map[string]time.Duration
+ watchedChannels sync.Map
+ writeLock sync.Mutex
+ keyReservationsLock sync.RWMutex
+}
+
+func NewRedisClient(addr string, timeout time.Duration, useSentinel bool) (*RedisClient, error) {
+ var r *redis.Client
+ if !useSentinel {
+ r = redis.NewClient(&redis.Options{Addr: addr})
+ } else {
+ // Redis Master-Replicas with Sentinel, sentinel masterSet config
+ // should be set to sebaRedis
+ r = redis.NewFailoverClient(&redis.FailoverOptions{
+ MasterName: "sebaRedis",
+ SentinelAddrs: []string{addr},
+ })
+ }
+
+ reservations := make(map[string]time.Duration)
+ return &RedisClient{redisAPI: r, keyReservations: reservations}, nil
+}
+
+func (c *RedisClient) Get(ctx context.Context, key string) (*KVPair, error) {
+
+ val, err := c.redisAPI.Get(ctx, key).Result()
+ valBytes, _ := ToByte(val)
+ if err != nil {
+ return nil, nil
+ }
+ return NewKVPair(key, valBytes, "", 0, 0), nil
+}
+
+func (c *RedisClient) Put(ctx context.Context, key string, value interface{}) error {
+
+ // Validate that we can convert value to a string as etcd API expects a string
+ var val string
+ var er error
+ if val, er = ToString(value); er != nil {
+ return fmt.Errorf("unexpected-type-%T", value)
+ }
+
+ // Check if there is already a lease for this key - if there is then use it, otherwise a PUT will make
+ // that KV key permanent instead of automatically removing it after a lease expiration
+ setErr := c.redisAPI.Set(ctx, key, val, 0)
+ err := setErr.Err()
+
+ if err != nil {
+ switch setErr.Err() {
+ case context.Canceled:
+ logger.Warnw(ctx, "context-cancelled", log.Fields{"error": err})
+ case context.DeadlineExceeded:
+ logger.Warnw(ctx, "context-deadline-exceeded", log.Fields{"error": err})
+ default:
+ logger.Warnw(ctx, "bad-endpoints", log.Fields{"error": err})
+ }
+ return err
+ }
+ return nil
+}
+
+func (c *RedisClient) scanAllKeysWithPrefix(ctx context.Context, key string) ([]string, error) {
+ var err error
+ allkeys := []string{}
+ cont := true
+ cursor := uint64(0)
+ matchPrefix := key + "*"
+
+ for cont {
+ // search in the first 10000 entries starting from the point indicated by the cursor
+ logger.Debugw(ctx, "redis-scan", log.Fields{"matchPrefix": matchPrefix, "cursor": cursor})
+ var keys []string
+ keys, cursor, err = c.redisAPI.Scan(context.Background(), cursor, matchPrefix, 10000).Result()
+ if err != nil {
+ return nil, err
+ }
+ if cursor == 0 {
+ // all data searched. break the loop
+ logger.Debugw(ctx, "redis-scan-ended", log.Fields{"matchPrefix": matchPrefix, "cursor": cursor})
+ cont = false
+ }
+ if len(keys) == 0 {
+ // no matched data found in this cycle. Continue to search
+ logger.Debugw(ctx, "redis-scan-no-data-found-continue", log.Fields{"matchPrefix": matchPrefix, "cursor": cursor})
+ continue
+ }
+ allkeys = append(allkeys, keys...)
+ }
+ return allkeys, nil
+}
+
+func (c *RedisClient) List(ctx context.Context, key string) (map[string]*KVPair, error) {
+ var err error
+ var keys []string
+ m := make(map[string]*KVPair)
+ var values []interface{}
+
+ if keys, err = c.scanAllKeysWithPrefix(ctx, key); err != nil {
+ return nil, err
+ }
+
+ if len(keys) != 0 {
+ values, err = c.redisAPI.MGet(ctx, keys...).Result()
+ if err != nil {
+ return nil, err
+ }
+ }
+ for i, key := range keys {
+ if valBytes, err := ToByte(values[i]); err == nil {
+ m[key] = NewKVPair(key, interface{}(valBytes), "", 0, 0)
+ }
+ }
+ return m, nil
+}
+
+func (c *RedisClient) Delete(ctx context.Context, key string) error {
+ // delete the key
+ if _, err := c.redisAPI.Del(ctx, key).Result(); err != nil {
+ logger.Errorw(ctx, "failed-to-delete-key", log.Fields{"key": key, "error": err})
+ return err
+ }
+ logger.Debugw(ctx, "key(s)-deleted", log.Fields{"key": key})
+ return nil
+}
+
+func (c *RedisClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error {
+ var keys []string
+ var err error
+ if keys, err = c.scanAllKeysWithPrefix(ctx, prefixKey); err != nil {
+ return err
+ }
+ if len(keys) == 0 {
+ logger.Warn(ctx, "nothing-to-delete-from-kv", log.Fields{"key": prefixKey})
+ return nil
+ }
+ //call delete for keys
+ entryCount := int64(0)
+ start := 0
+ pageSize := 5000
+ length := len(keys)
+ for start < length {
+ end := start + pageSize
+ if end >= length {
+ end = length
+ }
+ keysToDelete := keys[start:end]
+ count := int64(0)
+ if count, err = c.redisAPI.Del(ctx, keysToDelete...).Result(); err != nil {
+ logger.Errorw(ctx, "DeleteWithPrefix method failed", log.Fields{"prefixKey": prefixKey, "numOfMatchedKeys": len(keysToDelete), "err": err})
+ return err
+ }
+ entryCount += count
+ start = end
+ }
+ logger.Debugf(ctx, "%d entries matching with the key prefix %s have been deleted successfully", entryCount, prefixKey)
+ return nil
+}
+
+func (c *RedisClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error) {
+ var val string
+ var er error
+ if val, er = ToString(value); er != nil {
+ return nil, fmt.Errorf("unexpected-type%T", value)
+ }
+
+ // SetNX -- Only set the key if it does not already exist.
+ c.redisAPI.SetNX(ctx, key, value, ttl)
+
+ // Check if set is successful
+ redisVal := c.redisAPI.Get(ctx, key).Val()
+ if redisVal == "" {
+ println("NULL")
+ return nil, nil
+ }
+
+ if val == redisVal {
+ // set is successful, return new reservation value
+ c.keyReservationsLock.Lock()
+ c.keyReservations[key] = ttl
+ c.keyReservationsLock.Unlock()
+ bytes, _ := ToByte(val)
+ return bytes, nil
+ } else {
+ // set is not successful, return existing reservation value
+ bytes, _ := ToByte(redisVal)
+ return bytes, nil
+ }
+
+}
+
+func (c *RedisClient) ReleaseReservation(ctx context.Context, key string) error {
+
+ redisVal := c.redisAPI.Get(ctx, key).Val()
+ if redisVal == "" {
+ return nil
+ }
+
+ // Override SetNX value with no TTL
+ _, err := c.redisAPI.Set(ctx, key, redisVal, 0).Result()
+ if err != nil {
+ delete(c.keyReservations, key)
+ } else {
+ return err
+ }
+ return nil
+
+}
+
+func (c *RedisClient) ReleaseAllReservations(ctx context.Context) error {
+ c.writeLock.Lock()
+ defer c.writeLock.Unlock()
+ for key := range c.keyReservations {
+ err := c.ReleaseReservation(ctx, key)
+ if err != nil {
+ logger.Errorw(ctx, "cannot-release-reservation", log.Fields{"key": key, "error": err})
+ return err
+ }
+ }
+ return nil
+}
+
+func (c *RedisClient) RenewReservation(ctx context.Context, key string) error {
+ c.writeLock.Lock()
+ defer c.writeLock.Unlock()
+
+ // Verify the key was reserved
+ ttl, ok := c.keyReservations[key]
+ if !ok {
+ return errors.New("key-not-reserved. Key not found")
+ }
+
+ redisVal := c.redisAPI.Get(ctx, key).Val()
+ if redisVal != "" {
+ c.redisAPI.Set(ctx, key, redisVal, ttl)
+ }
+ return nil
+}
+
+func (c *RedisClient) listenForKeyChange(ctx context.Context, redisCh <-chan *redis.Message, ch chan<- *Event, cancel context.CancelFunc) {
+ logger.Debug(ctx, "start-listening-on-channel ...")
+ defer cancel()
+ defer close(ch)
+ for msg := range redisCh {
+ words := strings.Split(msg.Channel, ":")
+ key := words[1]
+ msgType := getMessageType(msg.Payload)
+ var valBytes []byte
+ if msgType == PUT {
+ ev, _ := c.Get(ctx, key)
+ valBytes, _ = ToByte(ev.Value)
+ }
+ ch <- NewEvent(getMessageType(msg.Payload), []byte(key), valBytes, 0)
+ }
+ logger.Debug(ctx, "stop-listening-on-channel ...")
+}
+
+func getMessageType(msg string) int {
+ isPut := strings.HasSuffix(msg, "set")
+ isDel := strings.HasSuffix(msg, "del")
+ if isPut {
+ return PUT
+ } else if isDel {
+ return DELETE
+ } else {
+ return UNKNOWN
+ }
+}
+
+func (c *RedisClient) addChannelMap(key string, channelMap map[chan *Event]*redis.PubSub) []map[chan *Event]*redis.PubSub {
+
+ var channels interface{}
+ var exists bool
+
+ if channels, exists = c.watchedChannels.Load(key); exists {
+ channels = append(channels.([]map[chan *Event]*redis.PubSub), channelMap)
+ } else {
+ channels = []map[chan *Event]*redis.PubSub{channelMap}
+ }
+ c.watchedChannels.Store(key, channels)
+
+ return channels.([]map[chan *Event]*redis.PubSub)
+}
+
+func (c *RedisClient) removeChannelMap(key string, pos int) []map[chan *Event]*redis.PubSub {
+ var channels interface{}
+ var exists bool
+
+ if channels, exists = c.watchedChannels.Load(key); exists {
+ channels = append(channels.([]map[chan *Event]*redis.PubSub)[:pos], channels.([]map[chan *Event]*redis.PubSub)[pos+1:]...)
+ c.watchedChannels.Store(key, channels)
+ }
+
+ return channels.([]map[chan *Event]*redis.PubSub)
+}
+
+func (c *RedisClient) getChannelMaps(key string) ([]map[chan *Event]*redis.PubSub, bool) {
+ var channels interface{}
+ var exists bool
+
+ channels, exists = c.watchedChannels.Load(key)
+
+ if channels == nil {
+ return nil, exists
+ }
+
+ return channels.([]map[chan *Event]*redis.PubSub), exists
+}
+
+func (c *RedisClient) Watch(ctx context.Context, key string, withPrefix bool) chan *Event {
+
+ ctx, cancel := context.WithCancel(ctx)
+
+ var subscribePath string
+ subscribePath = "__key*__:" + key
+ if withPrefix {
+ subscribePath += "*"
+ }
+ pubsub := c.redisAPI.PSubscribe(ctx, subscribePath)
+ redisCh := pubsub.Channel()
+
+ // Create new channel
+ ch := make(chan *Event, maxClientChannelBufferSize)
+
+ // Keep track of the created channels so they can be closed when required
+ channelMap := make(map[chan *Event]*redis.PubSub)
+ channelMap[ch] = pubsub
+
+ channelMaps := c.addChannelMap(key, channelMap)
+ logger.Debugw(ctx, "watched-channels", log.Fields{"len": len(channelMaps)})
+
+ // Launch a go routine to listen for updates
+ go c.listenForKeyChange(ctx, redisCh, ch, cancel)
+ return ch
+}
+
+func (c *RedisClient) CloseWatch(ctx context.Context, key string, ch chan *Event) {
+ // Get the array of channels mapping
+ var watchedChannels []map[chan *Event]*redis.PubSub
+ var ok bool
+
+ if watchedChannels, ok = c.getChannelMaps(key); !ok {
+ logger.Warnw(ctx, "key-has-no-watched-channels", log.Fields{"key": key})
+ return
+ }
+ // Look for the channels
+ var pos = -1
+ for i, chMap := range watchedChannels {
+ if t, ok := chMap[ch]; ok {
+ logger.Debug(ctx, "channel-found")
+ // Close the Redis watcher before the client channel. This should close the etcd channel as well
+ if err := t.Close(); err != nil {
+ logger.Errorw(ctx, "watcher-cannot-be-closed", log.Fields{"key": key, "error": err})
+ }
+ pos = i
+ break
+ }
+ }
+
+ channelMaps, _ := c.getChannelMaps(key)
+ // Remove that entry if present
+ if pos >= 0 {
+ channelMaps = c.removeChannelMap(key, pos)
+ }
+ logger.Infow(ctx, "watcher-channel-exiting", log.Fields{"key": key, "channel": channelMaps})
+}
+func (c *RedisClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error {
+ return nil
+}
+
+func (c *RedisClient) ReleaseLock(lockName string) error {
+ return nil
+}
+
+func (c *RedisClient) IsConnectionUp(ctx context.Context) bool {
+ if _, err := c.redisAPI.Set(ctx, "connection-check", "1", 0).Result(); err != nil {
+ return false
+ }
+ return true
+
+}
+
+func (c *RedisClient) Close(ctx context.Context) {
+ if err := c.redisAPI.Close(); err != nil {
+ logger.Errorw(ctx, "error-closing-client", log.Fields{"error": err})
+ }
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/common.go
index b0ce81b..383cfc4 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-present Open Networking Foundation
+ * Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
index 7b1a123..af5821a 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-present Open Networking Foundation
+ * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -272,7 +272,7 @@
// outputType is JSON, level is the lowest level log to output with this logger and defaultFields is a map of
// key-value pairs to always add to the output.
// Note: AddPackage also returns a reference to the actual logger. If a calling package uses this reference directly
-//instead of using the publicly available functions in this log package then a number of functionalities will not
+// instead of using the publicly available functions in this log package then a number of functionalities will not
// be available to it, notably log tracing with filename.functionname.linenumber annotation.
//
// pkgNames parameter should be used for testing only as this function detects the caller's package.
@@ -312,7 +312,7 @@
return loggers[pkgName], nil
}
-//UpdateAllLoggers create new loggers for all registered pacakges with the defaultFields.
+// UpdateAllLoggers create new loggers for all registered pacakges with the defaultFields.
func UpdateAllLoggers(defaultFields Fields) error {
for pkgName, cfg := range cfgs {
for k, v := range defaultFields {
@@ -392,7 +392,7 @@
}
}
-//SetPackageLogLevel dynamically sets the log level of a given package to level. This is typically invoked at an
+// SetPackageLogLevel dynamically sets the log level of a given package to level. This is typically invoked at an
// application level during debugging
func SetPackageLogLevel(packageName string, level LogLevel) {
// Get proper config
@@ -401,7 +401,7 @@
}
}
-//SetAllLogLevel sets the log level of all registered packages to level
+// SetAllLogLevel sets the log level of all registered packages to level
func SetAllLogLevel(level LogLevel) {
// Get proper config
for _, cfg := range cfgs {
@@ -409,7 +409,7 @@
}
}
-//GetPackageLogLevel returns the current log level of a package.
+// GetPackageLogLevel returns the current log level of a package.
func GetPackageLogLevel(packageName ...string) (LogLevel, error) {
var name string
if len(packageName) == 1 {
@@ -423,12 +423,12 @@
return 0, fmt.Errorf("unknown-package-%s", name)
}
-//GetDefaultLogLevel gets the log level used for packages that don't have specific loggers
+// GetDefaultLogLevel gets the log level used for packages that don't have specific loggers
func GetDefaultLogLevel() LogLevel {
return levelToLogLevel(cfg.Level.Level())
}
-//SetLogLevel sets the log level for the logger corresponding to the caller's package
+// SetLogLevel sets the log level for the logger corresponding to the caller's package
func SetLogLevel(level LogLevel) error {
pkgName, _, _, _ := getCallerInfo()
if _, exist := cfgs[pkgName]; !exist {
@@ -439,7 +439,7 @@
return nil
}
-//SetDefaultLogLevel sets the log level used for packages that don't have specific loggers
+// SetDefaultLogLevel sets the log level used for packages that don't have specific loggers
func SetDefaultLogLevel(level LogLevel) {
setLevel(cfg, level)
}
@@ -660,3 +660,39 @@
func (l clogger) GetLogLevel() LogLevel {
return levelToLogLevel(cfgs[l.packageName].Level.Level())
}
+
+// UpdateCallerSkipLevel create new loggers for specified registered pacakges with the default updated caller skipltFields.
+// This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateCallerSkipLevel(skipLevel int) (CLogger, error) {
+ pkgName, _, _, _ := getCallerInfo()
+ if cfg, exist := cfgs[pkgName]; exist {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return loggers[pkgName], err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+
+ return loggers[pkgName], nil
+ }
+
+ return loggers[pkgName], errors.New("Package Not Found")
+}
+
+// UpdateAllCallerSkipLevel create new loggers for all registered pacakges with the default updated caller skipltFields.
+// This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateAllCallerSkipLevel(skipLevel int) error {
+ for pkgName, cfg := range cfgs {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+ }
+ return nil
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/utils.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/utils.go
index 82c3d7d..e21ce0c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/utils.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/utils.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-present Open Networking Foundation
+ * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/common.go
index 3aef492..2917226 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/meter_utils.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/meter_utils.go
index 56e8ecc..6dfb0c8 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/meter_utils.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/meters/meter_utils.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +29,14 @@
switch meterBandSize := len(meterConfig.Bands); {
case meterBandSize == 1:
band := meterConfig.Bands[0]
- if band.BurstSize == 0 { // GIR, tcont type 1
- return &tp_pb.TrafficShapingInfo{Gir: band.Rate}, nil
+ if band.BurstSize == 0 { // GIR = PIR, Burst Size = 0, tcont type 1
+ return &tp_pb.TrafficShapingInfo{Pir: band.Rate, Gir: band.Rate}, nil
}
return &tp_pb.TrafficShapingInfo{Pir: band.Rate, Pbs: band.BurstSize}, nil // PIR, tcont type 4
case meterBandSize == 2:
firstBand, secondBand := meterConfig.Bands[0], meterConfig.Bands[1]
if firstBand.BurstSize == 0 && secondBand.BurstSize == 0 &&
- firstBand.Rate == secondBand.Rate { // PIR == GIR, tcont type 1
+ firstBand.Rate == secondBand.Rate { // PIR = GIR, tcont type 1
return &tp_pb.TrafficShapingInfo{Pir: firstBand.Rate, Gir: secondBand.Rate}, nil
}
if firstBand.BurstSize > 0 && secondBand.BurstSize > 0 { // PIR, CIR, tcont type 2 or 3