[VOL-5054] - Triage build for voltha-openolt-adapter
cmd/*.go
internal/pkg/*.go
pkg/mocks/*.go
=================
o Run gofmt -w -s on all non-(vendor/) golang sources (~make lint).
o Release triage jobs have been failing on unrelated source problems.
config.mk
makefiles/docker/
makefiles/etc/
makefiles/targets/
makefiles/virtualenv.mk
=======================
o https://github.com/opencord/onf-make.git
o Copy in library makefiles, esp docker/include.mk
Makefile
========
o Refactor and replace inline GO= and docker macros with docker/include.
o Added manual flag LOCAL_FIX_PERMS=1 to grant docker image write access.
o Target: mod-update
- Split logic into targets mod-tidy and mod-vendor.
- Display a banner when target runs for readability.
- Target lint-mod now calls mod-update VS inlining make mod tidy & vendor
o Target: test
- Split logic into 3 distinct targets now that stdout/stderr handled.
- Improve error handling, fail early VS accumulating status then exit
- Display a banner when targets process for log readability.
- Define macros for *.out and *.xml to avoid repeating logfile paths.
Change-Id: Ia2eb999f6176ce2eb46e41f55aee74c05b5a4cd2
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 002c459..21106aa 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package config provides the Log, kvstore, Kafka configuration
+// Package config provides the Log, kvstore, Kafka configuration
package config
import (
diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go
index 4e89635..152db52 100644
--- a/internal/pkg/config/config_test.go
+++ b/internal/pkg/config/config_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package config provides the Log, kvstore, Kafka configuration
+// Package config provides the Log, kvstore, Kafka configuration
package config
import (
diff --git a/internal/pkg/core/common.go b/internal/pkg/core/common.go
index 3c8a826..d2d6f6e 100644
--- a/internal/pkg/core/common.go
+++ b/internal/pkg/core/common.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core Common Logger initialization
+// Package core Common Logger initialization
package core
import (
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 4c9a00f..8c41952 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -1147,7 +1147,6 @@
}
}
-//
func TestDeviceHandler_doStateUp(t *testing.T) {
dh1 := newMockDeviceHandler()
dh2 := newMockDeviceHandler()
@@ -1374,66 +1373,68 @@
}
}
-/* We are not using the adapterPreviouslyConnected and agentPreviouslyConnected flags now to check for reboots and reconnects
+/*
+ We are not using the adapterPreviouslyConnected and agentPreviouslyConnected flags now to check for reboots and reconnects
+
commenting out all the tests related to these
func TestDeviceHandler_TestReconcileStatus(t *testing.T) {
- // olt disconnect (not reboot)
- dh1 := newMockDeviceHandler()
- dh1.adapterPreviouslyConnected = false
- dh1.agentPreviouslyConnected = true
+ // olt disconnect (not reboot)
+ dh1 := newMockDeviceHandler()
+ dh1.adapterPreviouslyConnected = false
+ dh1.agentPreviouslyConnected = true
- // adapter restart
- dh2 := newMockDeviceHandler()
- dh2.Client = &mocks.MockOpenoltClient{}
- dh2.adapterPreviouslyConnected = true
- dh2.agentPreviouslyConnected = true
+ // adapter restart
+ dh2 := newMockDeviceHandler()
+ dh2.Client = &mocks.MockOpenoltClient{}
+ dh2.adapterPreviouslyConnected = true
+ dh2.agentPreviouslyConnected = true
- // first connection or olt restart
- dh3 := newMockDeviceHandler()
- dh3.Client = &mocks.MockOpenoltClient{}
- dh3.adapterPreviouslyConnected = false
- dh3.agentPreviouslyConnected = false
+ // first connection or olt restart
+ dh3 := newMockDeviceHandler()
+ dh3.Client = &mocks.MockOpenoltClient{}
+ dh3.adapterPreviouslyConnected = false
+ dh3.agentPreviouslyConnected = false
- // olt and adapter restart at the same time (first case)
- dh4 := newMockDeviceHandler()
- dh4.Client = &mocks.MockOpenoltClient{}
- dh4.adapterPreviouslyConnected = true
- dh4.agentPreviouslyConnected = false
+ // olt and adapter restart at the same time (first case)
+ dh4 := newMockDeviceHandler()
+ dh4.Client = &mocks.MockOpenoltClient{}
+ dh4.adapterPreviouslyConnected = true
+ dh4.agentPreviouslyConnected = false
- // adapter restart and olt disconnect at the same time
- dh5 := newMockDeviceHandler()
- dh5.Client = &mocks.MockOpenoltClient{}
- dh5.adapterPreviouslyConnected = true
- dh5.agentPreviouslyConnected = true
+ // adapter restart and olt disconnect at the same time
+ dh5 := newMockDeviceHandler()
+ dh5.Client = &mocks.MockOpenoltClient{}
+ dh5.adapterPreviouslyConnected = true
+ dh5.agentPreviouslyConnected = true
- tests := []struct {
- name string
- devicehandler *DeviceHandler
- expectedRestart bool
- wantErr bool
- }{
- {"dostateup-1", dh1, true, false},
- {"dostateup-2", dh2, false, false},
- {"dostateup-3", dh3, false, false},
- {"dostateup-4", dh4, true, false},
- {"dostateup-5", dh5, false, false},
+ tests := []struct {
+ name string
+ devicehandler *DeviceHandler
+ expectedRestart bool
+ wantErr bool
+ }{
+ {"dostateup-1", dh1, true, false},
+ {"dostateup-2", dh2, false, false},
+ {"dostateup-3", dh3, false, false},
+ {"dostateup-4", dh4, true, false},
+ {"dostateup-5", dh5, false, false},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
+ t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
+ isRestarted := tt.devicehandler.Client.(*mocks.MockOpenoltClient).IsRestarted
+ if tt.expectedRestart != isRestarted {
+ t.Errorf("olt-reboot-failed expected= %v, got= %v", tt.expectedRestart, isRestarted)
+ }
+ })
+ }
}
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- defer cancel()
- if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
- t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
- }
- tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
- isRestarted := tt.devicehandler.Client.(*mocks.MockOpenoltClient).IsRestarted
- if tt.expectedRestart != isRestarted {
- t.Errorf("olt-reboot-failed expected= %v, got= %v", tt.expectedRestart, isRestarted)
- }
- })
- }
-}
*/
func Test_UpdateFlowsIncrementallyNegativeTestCases(t *testing.T) {
dh1 := negativeDeviceHandlerNilFlowMgr()
diff --git a/internal/pkg/core/olt_state_transitions.go b/internal/pkg/core/olt_state_transitions.go
index 73f75f7..cd3fc5c 100644
--- a/internal/pkg/core/olt_state_transitions.go
+++ b/internal/pkg/core/olt_state_transitions.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/olt_state_transitions_test.go b/internal/pkg/core/olt_state_transitions_test.go
index cc3d1a2..6e8ba97 100644
--- a/internal/pkg/core/olt_state_transitions_test.go
+++ b/internal/pkg/core/olt_state_transitions_test.go
@@ -24,7 +24,8 @@
"time"
)
-/**
+/*
+*
Get's the transition Map with current state of the device.
*/
func getTranisitions() map[Trigger]Transition {
@@ -37,7 +38,8 @@
return transitions
}
-/**
+/*
+*
Get's the transition Map with after Transition func added.
*/
func getTranisitionsAfter() map[Trigger]Transition {
@@ -55,7 +57,8 @@
return transitions
}
-/**
+/*
+*
Get's the transition Map with before Transition func added.
*/
func getTranisitionsBefore() map[Trigger]Transition {
@@ -73,7 +76,8 @@
return transitions
}
-/**
+/*
+*
Check's Creation of transition Map, return's NewTransitionMap.
*/
func TestNewTransitionMap(t *testing.T) {
@@ -96,7 +100,8 @@
}
}
-/**
+/*
+*
Checks the different transition of the device handled properly.
*/
func TestTransitionMap_Handle(t *testing.T) {
@@ -130,7 +135,8 @@
}
}
-/**
+/*
+*
Check's if the transition is valid or not.
*/
func TestTransitionMap_isValidTransition(t *testing.T) {
@@ -167,7 +173,8 @@
}
}
-/**
+/*
+*
Get's the After/Before transition method's function name.
*/
func Test_funcName(t *testing.T) {
diff --git a/internal/pkg/core/openoltInterAdapter.go b/internal/pkg/core/openoltInterAdapter.go
index db9c70d..fb0d2a2 100644
--- a/internal/pkg/core/openoltInterAdapter.go
+++ b/internal/pkg/core/openoltInterAdapter.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -30,23 +30,23 @@
oltia "github.com/opencord/voltha-protos/v5/go/olt_inter_adapter_service"
)
-//OpenOLTInterAdapter structure holds a reference to the oltAdapter
+// OpenOLTInterAdapter structure holds a reference to the oltAdapter
type OpenOLTInterAdapter struct {
oltAdapter *OpenOLT
exitChannel chan struct{}
}
-//NewOpenOLTInterAdapter returns a new instance of OpenOLTInterAdapter
+// NewOpenOLTInterAdapter returns a new instance of OpenOLTInterAdapter
func NewOpenOLTInterAdapter(oltAdapter *OpenOLT) *OpenOLTInterAdapter {
return &OpenOLTInterAdapter{oltAdapter: oltAdapter, exitChannel: make(chan struct{})}
}
-//Start starts (logs) the device manager
+// Start starts (logs) the device manager
func (oo *OpenOLTInterAdapter) Start(ctx context.Context) error {
return nil
}
-//Stop terminates the session
+// Stop terminates the session
func (oo *OpenOLTInterAdapter) Stop(ctx context.Context) error {
close(oo.exitChannel)
return nil
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index 6ee538b..3740cf4 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -393,7 +393,7 @@
return nil
}
-//wasLosRaised checks whether los raised already. If already raised returns true else false
+// wasLosRaised checks whether los raised already. If already raised returns true else false
func (em *OpenOltEventMgr) wasLosRaised(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool {
onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId)
if onuInCache, ok := em.handler.onus.Load(onuKey); ok {
@@ -411,7 +411,7 @@
return true
}
-//wasLosCleared checks whether los cleared already. If already cleared returns true else false
+// wasLosCleared checks whether los cleared already. If already cleared returns true else false
func (em *OpenOltEventMgr) wasLosCleared(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool {
onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId)
if onuInCache, ok := em.handler.onus.Load(onuKey); ok {
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 087f234..c5899b0 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -198,7 +198,7 @@
errChan *chan error // channel to report the Flow handling error
}
-//OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
+// OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
type OpenOltFlowMgr struct {
ponPortIdx uint32 // Pon Port this FlowManager is responsible for
techprofile tp.TechProfileIf
@@ -223,7 +223,7 @@
}
}
-//NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
+// NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
func NewFlowManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr, grpMgr *OpenOltGroupMgr, ponPortIdx uint32) *OpenOltFlowMgr {
logger.Infow(ctx, "initializing-flow-manager", log.Fields{"device-id": dh.device.Id})
var flowMgr OpenOltFlowMgr
@@ -1225,13 +1225,13 @@
return nil
}
-//addIGMPTrapFlow creates IGMP trap-to-host flow
+// addIGMPTrapFlow creates IGMP trap-to-host flow
func (f *OpenOltFlowMgr) addIGMPTrapFlow(ctx context.Context, flowContext *flowContext) error {
delete(flowContext.classifier, VlanVid)
return f.addUpstreamTrapFlow(ctx, flowContext)
}
-//addUpstreamTrapFlow creates a trap-to-host flow
+// addUpstreamTrapFlow creates a trap-to-host flow
func (f *OpenOltFlowMgr) addUpstreamTrapFlow(ctx context.Context, flowContext *flowContext) error {
intfID := flowContext.intfID
@@ -1775,7 +1775,7 @@
return fmt.Sprintf("olt-{%s}/pon-{%d}/onu-{%d}/uni-{%d}", oltID, intfID, onuID, uniID)
}
-//getOnuDevice to fetch onu from cache or core.
+// getOnuDevice to fetch onu from cache or core.
func (f *OpenOltFlowMgr) getOnuDevice(ctx context.Context, intfID uint32, onuID uint32) (*OnuDevice, error) {
onuKey := f.deviceHandler.formOnuKey(intfID, onuID)
onuDev, ok := f.deviceHandler.onus.Load(onuKey)
@@ -1807,7 +1807,7 @@
return onuDev.(*OnuDevice), nil
}
-//getChildDevice to fetch onu
+// getChildDevice to fetch onu
func (f *OpenOltFlowMgr) getChildDevice(ctx context.Context, intfID uint32, onuID uint32) (*voltha.Device, error) {
logger.Infow(ctx, "GetChildDevice",
log.Fields{
@@ -1914,7 +1914,7 @@
return nil
}
-//clearResources clears pon resources in kv store and the device
+// clearResources clears pon resources in kv store and the device
// nolint: gocyclo
func (f *OpenOltFlowMgr) clearResources(ctx context.Context, intfID uint32, onuID int32, uniID int32,
flowID uint64, portNum uint32, tpID uint32, sendDeleteGemRequest bool) error {
@@ -2189,7 +2189,7 @@
return nil
}
-//RemoveFlow removes the flow from the device
+// RemoveFlow removes the flow from the device
func (f *OpenOltFlowMgr) RemoveFlow(ctx context.Context, flow *ofp.OfpFlowStats) error {
logger.Infow(ctx, "removing-flow", log.Fields{"flow": *flow})
@@ -2223,7 +2223,7 @@
return err
}
-//isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise
+// isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise
func isIgmpTrapDownstreamFlow(classifierInfo map[string]interface{}) bool {
if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_ETHERNET_NNI {
if ethType, ok := classifierInfo[EthType]; ok {
@@ -2497,7 +2497,7 @@
return nil
}
-//getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise
+// getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise
func (f *OpenOltFlowMgr) getNNIInterfaceIDOfMulticastFlow(ctx context.Context, classifierInfo map[string]interface{}) (uint32, error) {
if inPort, ok := classifierInfo[InPort]; ok {
nniInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, inPort.(uint32))
@@ -2511,7 +2511,7 @@
return 0, nil
}
-//sendTPDownloadMsgToChild send payload
+// sendTPDownloadMsgToChild send payload
func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uni string, TpID uint32, tpInst tp_pb.TechProfileInstance) error {
onuDev, err := f.getOnuDevice(ctx, intfID, onuID)
@@ -2547,7 +2547,7 @@
return nil
}
-//GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
+// GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
func (f *OpenOltFlowMgr) GetLogicalPortFromPacketIn(ctx context.Context, packetIn *openoltpb2.PacketIndication) (uint32, error) {
var logicalPortNum uint32
@@ -2579,7 +2579,7 @@
return logicalPortNum, nil
}
-//GetPacketOutGemPortID returns gemPortId
+// GetPacketOutGemPortID returns gemPortId
func (f *OpenOltFlowMgr) GetPacketOutGemPortID(ctx context.Context, intfID uint32, onuID uint32, portNum uint32, packet []byte) (uint32, error) {
var gemPortID uint32
@@ -2698,7 +2698,7 @@
return nil
}
-//getPacketTypeFromClassifiers finds and returns packet type of a flow by checking flow classifiers
+// getPacketTypeFromClassifiers finds and returns packet type of a flow by checking flow classifiers
func getPacketTypeFromClassifiers(classifierInfo map[string]interface{}) string {
var packetType string
ovid, ivid := false, false
@@ -2737,7 +2737,7 @@
return packetType
}
-//addIgmpTrapFlowOnNNI adds a trap-to-host flow on NNI
+// addIgmpTrapFlowOnNNI adds a trap-to-host flow on NNI
func (f *OpenOltFlowMgr) addIgmpTrapFlowOnNNI(ctx context.Context, logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) error {
logger.Infow(ctx, "adding-igmp-trap-of-nni-flow", log.Fields{"classifier-info": classifier})
action := make(map[string]interface{})
@@ -3290,7 +3290,7 @@
"gem": gemPort})
}
-//getCTagFromPacket retrieves and returns c-tag and priority value from a packet.
+// getCTagFromPacket retrieves and returns c-tag and priority value from a packet.
func getCTagFromPacket(ctx context.Context, packet []byte) (uint16, uint8, error) {
if packet == nil || len(packet) < 18 {
logger.Error(ctx, "unable-get-c-tag-from-the-packet--invalid-packet-length ")
@@ -3317,7 +3317,7 @@
return 0, 0, nil
}
-//clearMulticastFlowFromResourceManager removes a multicast flow from the KV store and
+// clearMulticastFlowFromResourceManager removes a multicast flow from the KV store and
// clears resources reserved for this multicast flow
func (f *OpenOltFlowMgr) clearMulticastFlowFromResourceManager(ctx context.Context, flow *ofp.OfpFlowStats) error {
removeFlowMessage := openoltpb2.Flow{FlowId: flow.Id, FlowType: Multicast}
diff --git a/internal/pkg/core/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
index 7dc83b7..a07fcd4 100644
--- a/internal/pkg/core/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/openolt_groupmgr.go b/internal/pkg/core/openolt_groupmgr.go
index 6490ebf..cc1ce00 100644
--- a/internal/pkg/core/openolt_groupmgr.go
+++ b/internal/pkg/core/openolt_groupmgr.go
@@ -11,7 +11,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows, groups and statistics
+// Package core provides the utility for olt devices, flows, groups and statistics
package core
import (
@@ -29,13 +29,13 @@
"google.golang.org/grpc/status"
)
-//QueueInfoBrief has information about gemPortID and service priority associated with Mcast group
+// QueueInfoBrief has information about gemPortID and service priority associated with Mcast group
type QueueInfoBrief struct {
gemPortID uint32
servicePriority uint32
}
-//OpenOltGroupMgr creates the Structure of OpenOltGroupMgr obj
+// OpenOltGroupMgr creates the Structure of OpenOltGroupMgr obj
type OpenOltGroupMgr struct {
deviceHandler *DeviceHandler
resourceMgr *rsrcMgr.OpenOltResourceMgr
@@ -47,7 +47,7 @@
// EXPORTED FUNCTIONS //
//////////////////////////////////////////////
-//NewGroupManager creates OpenOltGroupMgr object and initializes the parameters
+// NewGroupManager creates OpenOltGroupMgr object and initializes the parameters
func NewGroupManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr) *OpenOltGroupMgr {
logger.Infow(ctx, "initializing-group-manager", log.Fields{"device-id": dh.device.Id})
var grpMgr OpenOltGroupMgr
@@ -178,8 +178,8 @@
return nil
}
-//LoadInterfaceToMulticastQueueMap reads multicast queues per interface from the KV store
-//and put them into interfaceToMcastQueueMap.
+// LoadInterfaceToMulticastQueueMap reads multicast queues per interface from the KV store
+// and put them into interfaceToMcastQueueMap.
func (g *OpenOltGroupMgr) LoadInterfaceToMulticastQueueMap(ctx context.Context) {
storedMulticastQueueMap, err := g.resourceMgr.GetMcastQueuePerInterfaceMap(ctx)
if err != nil {
@@ -195,7 +195,7 @@
}
}
-//GetInterfaceToMcastQueueMap gets the mcast queue mapped to to the PON interface
+// GetInterfaceToMcastQueueMap gets the mcast queue mapped to to the PON interface
func (g *OpenOltGroupMgr) GetInterfaceToMcastQueueMap(intfID uint32) (*QueueInfoBrief, bool) {
g.interfaceToMcastQueueMapLock.RLock()
defer g.interfaceToMcastQueueMapLock.RUnlock()
@@ -203,19 +203,21 @@
return val, present
}
-//UpdateInterfaceToMcastQueueMap updates the mcast queue information mapped to a given PON interface
+// UpdateInterfaceToMcastQueueMap updates the mcast queue information mapped to a given PON interface
func (g *OpenOltGroupMgr) UpdateInterfaceToMcastQueueMap(intfID uint32, val *QueueInfoBrief) {
g.interfaceToMcastQueueMapLock.Lock()
defer g.interfaceToMcastQueueMapLock.Unlock()
g.interfaceToMcastQueueMap[intfID] = val
}
-////////////////////////////////////////////////
-// INTERNAL or UNEXPORTED FUNCTIONS //
-////////////////////////////////////////////////
-//getFlowGroupFromKVStore fetches and returns flow group from the KV store. Returns (nil, false, error) if any problem occurs during
-//fetching the data. Returns (group, true, nil) if the group is fetched and returned successfully.
-//Returns (nil, false, nil) if the group does not exists in the KV store.
+// //////////////////////////////////////////////
+//
+// INTERNAL or UNEXPORTED FUNCTIONS //
+//
+// //////////////////////////////////////////////
+// getFlowGroupFromKVStore fetches and returns flow group from the KV store. Returns (nil, false, error) if any problem occurs during
+// fetching the data. Returns (group, true, nil) if the group is fetched and returned successfully.
+// Returns (nil, false, nil) if the group does not exists in the KV store.
func (g *OpenOltGroupMgr) getFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) (*ofp.OfpGroupEntry, bool, error) {
exists, groupInfo, err := g.resourceMgr.GetFlowGroupFromKVStore(ctx, groupID, cached)
if err != nil {
@@ -245,7 +247,7 @@
return &groupEntry
}
-//buildGroupAction creates and returns a group action
+// buildGroupAction creates and returns a group action
func (g *OpenOltGroupMgr) buildGroupAction() *openoltpb2.Action {
var actionCmd openoltpb2.ActionCmd
var action openoltpb2.Action
@@ -255,7 +257,7 @@
return &action
}
-//callGroupAddRemove performs add/remove buckets operation for the indicated group
+// callGroupAddRemove performs add/remove buckets operation for the indicated group
func (g *OpenOltGroupMgr) callGroupAddRemove(ctx context.Context, group *openoltpb2.Group) error {
if err := g.performGroupOperation(ctx, group); err != nil {
st, _ := status.FromError(err)
@@ -267,7 +269,7 @@
return nil
}
-//findDiff compares group members and finds members which only exists in groups2
+// findDiff compares group members and finds members which only exists in groups2
func (g *OpenOltGroupMgr) findDiff(group1 *openoltpb2.Group, group2 *openoltpb2.Group) []*openoltpb2.GroupMember {
var members []*openoltpb2.GroupMember
for _, bucket := range group2.Members {
@@ -279,7 +281,7 @@
return members
}
-//contains returns true if the members list contains the given member; false otherwise
+// contains returns true if the members list contains the given member; false otherwise
func (g *OpenOltGroupMgr) contains(members []*openoltpb2.GroupMember, member *openoltpb2.GroupMember) bool {
for _, groupMember := range members {
if groupMember.InterfaceId == member.InterfaceId {
@@ -289,7 +291,7 @@
return false
}
-//performGroupOperation call performGroupOperation operation of openolt proto
+// performGroupOperation call performGroupOperation operation of openolt proto
func (g *OpenOltGroupMgr) performGroupOperation(ctx context.Context, group *openoltpb2.Group) error {
logger.Debugw(ctx, "sending-group-to-device",
log.Fields{
@@ -302,7 +304,7 @@
return nil
}
-//buildGroup build openoltpb2.Group from given group id and bucket list
+// buildGroup build openoltpb2.Group from given group id and bucket list
func (g *OpenOltGroupMgr) buildGroup(ctx context.Context, groupID uint32, buckets []*ofp.OfpBucket) *openoltpb2.Group {
group := openoltpb2.Group{
GroupId: groupID}
@@ -316,7 +318,7 @@
return &group
}
-//buildMember builds openoltpb2.GroupMember from an OpenFlow bucket
+// buildMember builds openoltpb2.GroupMember from an OpenFlow bucket
func (g *OpenOltGroupMgr) buildMember(ctx context.Context, ofBucket *ofp.OfpBucket) *openoltpb2.GroupMember {
var outPort uint32
outPortFound := false
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index 776fef4..cb70ea9 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -19,7 +19,7 @@
This file also implements the fields struct to mock the Openolt and few utility functions.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/statsmanager.go b/internal/pkg/core/statsmanager.go
index eedfa19..52a86e3 100755
--- a/internal/pkg/core/statsmanager.go
+++ b/internal/pkg/core/statsmanager.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -99,8 +99,8 @@
var onuStats = make(chan *openolt.OnuStatistics, 100)
var gemStats = make(chan *openolt.GemPortStatistics, 100)
-//statRegInfo is used to register for notifications
-//on receiving port stats and flow stats indication
+// statRegInfo is used to register for notifications
+// on receiving port stats and flow stats indication
type statRegInfo struct {
chn chan bool
portNo uint32
@@ -256,7 +256,7 @@
return &NNI
}
-//StatType defines portStatsType and flowStatsType types
+// StatType defines portStatsType and flowStatsType types
type StatType int
const (
@@ -741,7 +741,7 @@
logger.Debugw(ctx, "updateGetOltPortCountersResponse", log.Fields{"resp": singleValResp})
}
-//RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received
+// RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received
func (StatMgr *OpenOltStatisticsMgr) RegisterForStatIndication(ctx context.Context, t StatType, ch chan bool, portNo uint32, portType extension.GetOltPortCounters_PortType) {
statInd := statRegInfo{
chn: ch,
@@ -756,7 +756,7 @@
}
-//DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
+// DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
func (StatMgr *OpenOltStatisticsMgr) DeRegisterFromStatIndication(ctx context.Context, t StatType, ch chan bool) {
StatMgr.statIndListnerMu.Lock()
defer StatMgr.statIndListnerMu.Unlock()
diff --git a/internal/pkg/core/statsmanager_test.go b/internal/pkg/core/statsmanager_test.go
index ab6dfd7..537b3de 100644
--- a/internal/pkg/core/statsmanager_test.go
+++ b/internal/pkg/core/statsmanager_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/olterrors/olterrors.go b/internal/pkg/olterrors/olterrors.go
index 4d7aa26..8892be9 100644
--- a/internal/pkg/olterrors/olterrors.go
+++ b/internal/pkg/olterrors/olterrors.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package olterrors implements functions to manipulate OLT errors
+// Package olterrors implements functions to manipulate OLT errors
package olterrors
import (
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 26a73ad..e3d60d9 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package resourcemanager provides the utility for managing resources
+// Package resourcemanager provides the utility for managing resources
package resourcemanager
import (
@@ -262,7 +262,7 @@
return &ResourceMgr
}
-//InitLocalCache initializes local maps used for write-through-cache
+// InitLocalCache initializes local maps used for write-through-cache
func (rsrcMgr *OpenOltResourceMgr) InitLocalCache() {
rsrcMgr.allocIDsForOnu = make(map[string][]uint32)
rsrcMgr.gemPortIDsForOnu = make(map[string][]uint32)
@@ -275,7 +275,7 @@
rsrcMgr.groupInfo = make(map[string]*GroupInfo)
}
-//LoadLocalCacheFromKVStore loads local maps
+// LoadLocalCacheFromKVStore loads local maps
func (rsrcMgr *OpenOltResourceMgr) LoadLocalCacheFromKVStore(ctx context.Context) error {
//List all the keys for OnuGemInfo
@@ -890,7 +890,7 @@
return nil
}
-//AddGemToOnuGemInfo adds gemport to onugem info kvstore and also local cache
+// AddGemToOnuGemInfo adds gemport to onugem info kvstore and also local cache
func (rsrcMgr *OpenOltResourceMgr) AddGemToOnuGemInfo(ctx context.Context, onuID uint32, gemPort uint32) error {
onugem, err := rsrcMgr.GetOnuGemInfo(ctx, onuID)
if err != nil || onugem == nil || onugem.SerialNumber == "" {
@@ -919,7 +919,7 @@
return err
}
-//RemoveGemFromOnuGemInfo removes gemport from onugem info on kvstore and also local cache
+// RemoveGemFromOnuGemInfo removes gemport from onugem info on kvstore and also local cache
func (rsrcMgr *OpenOltResourceMgr) RemoveGemFromOnuGemInfo(ctx context.Context, onuID uint32, gemPort uint32) error {
onugem, err := rsrcMgr.GetOnuGemInfo(ctx, onuID)
if err != nil || onugem == nil || onugem.SerialNumber == "" {
@@ -952,7 +952,7 @@
return nil
}
-//GetOnuGemInfo gets onu gem info from the kvstore per interface
+// GetOnuGemInfo gets onu gem info from the kvstore per interface
func (rsrcMgr *OpenOltResourceMgr) GetOnuGemInfo(ctx context.Context, onuID uint32) (*OnuGemInfo, error) {
var err error
var Val []byte
@@ -991,7 +991,7 @@
return &onugem, nil
}
-//AddNewOnuGemInfoToCacheAndKvStore function adds a new onu gem info to cache and kvstore
+// AddNewOnuGemInfoToCacheAndKvStore function adds a new onu gem info to cache and kvstore
func (rsrcMgr *OpenOltResourceMgr) AddNewOnuGemInfoToCacheAndKvStore(ctx context.Context, onuID uint32, serialNum string) error {
Path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
@@ -1064,7 +1064,7 @@
return nil
}
-//DeleteAllOnuGemInfoForIntf deletes all the all onu gem info on the given pon interface
+// DeleteAllOnuGemInfoForIntf deletes all the all onu gem info on the given pon interface
func (rsrcMgr *OpenOltResourceMgr) DeleteAllOnuGemInfoForIntf(ctx context.Context) error {
path := fmt.Sprintf(OnuGemInfoPathPathPrefix, rsrcMgr.PonIntfID)
@@ -1110,7 +1110,7 @@
}
}
-//UpdateGemPortForPktIn updates gemport for pkt in path to kvstore, path being intfid, onuid, portno, vlan id, priority bit
+// UpdateGemPortForPktIn updates gemport for pkt in path to kvstore, path being intfid, onuid, portno, vlan id, priority bit
func (rsrcMgr *OpenOltResourceMgr) UpdateGemPortForPktIn(ctx context.Context, pktIn PacketInInfoKey, gemPort uint32) {
path := fmt.Sprintf(OnuPacketInPath, pktIn.IntfID, pktIn.OnuID, pktIn.LogicalPort, pktIn.VlanID, pktIn.Priority)
@@ -1174,7 +1174,7 @@
return gemPort, nil
}
-//DeletePacketInGemPortForOnu deletes the packet-in gemport for ONU
+// DeletePacketInGemPortForOnu deletes the packet-in gemport for ONU
func (rsrcMgr *OpenOltResourceMgr) DeletePacketInGemPortForOnu(ctx context.Context, onuID uint32, logicalPort uint32) error {
path := fmt.Sprintf(OnuPacketInPathPrefix, rsrcMgr.PonIntfID, onuID, logicalPort)
value, err := rsrcMgr.KVStore.List(ctx, path)
@@ -1207,7 +1207,7 @@
return nil
}
-//GetFlowIDsForGem gets the list of FlowIDs for the given gemport
+// GetFlowIDsForGem gets the list of FlowIDs for the given gemport
func (rsrcMgr *OpenOltResourceMgr) GetFlowIDsForGem(ctx context.Context, gem uint32) ([]uint64, error) {
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
@@ -1272,7 +1272,7 @@
return rsrcMgr.UpdateFlowIDsForGem(ctx, gemPortID, flowIDs)
}
-//UpdateFlowIDsForGem updates flow id per gemport
+// UpdateFlowIDsForGem updates flow id per gemport
func (rsrcMgr *OpenOltResourceMgr) UpdateFlowIDsForGem(ctx context.Context, gem uint32, flowIDs []uint64) error {
var val []byte
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
@@ -1302,7 +1302,7 @@
return nil
}
-//DeleteFlowIDsForGem deletes the flowID list entry per gem from kvstore.
+// DeleteFlowIDsForGem deletes the flowID list entry per gem from kvstore.
func (rsrcMgr *OpenOltResourceMgr) DeleteFlowIDsForGem(ctx context.Context, gem uint32) error {
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
if err := rsrcMgr.KVStore.Delete(ctx, path); err != nil {
@@ -1316,7 +1316,7 @@
return nil
}
-//DeleteAllFlowIDsForGemForIntf deletes all the flow ids associated for all the gems on the given pon interface
+// DeleteAllFlowIDsForGemForIntf deletes all the flow ids associated for all the gems on the given pon interface
func (rsrcMgr *OpenOltResourceMgr) DeleteAllFlowIDsForGemForIntf(ctx context.Context) error {
path := fmt.Sprintf(FlowIDsForGemPathPrefix, rsrcMgr.PonIntfID)
@@ -1333,7 +1333,7 @@
return nil
}
-//GetMcastQueuePerInterfaceMap gets multicast queue info per pon interface
+// GetMcastQueuePerInterfaceMap gets multicast queue info per pon interface
func (rsrcMgr *OpenOltResourceMgr) GetMcastQueuePerInterfaceMap(ctx context.Context) (map[uint32][]uint32, error) {
path := McastQueuesForIntf
var val []byte
@@ -1366,7 +1366,7 @@
return rsrcMgr.mcastQueueForIntf, nil
}
-//AddMcastQueueForIntf adds multicast queue for pon interface
+// AddMcastQueueForIntf adds multicast queue for pon interface
func (rsrcMgr *OpenOltResourceMgr) AddMcastQueueForIntf(ctx context.Context, gem uint32, servicePriority uint32) error {
var val []byte
path := McastQueuesForIntf
@@ -1403,7 +1403,7 @@
return nil
}
-//DeleteMcastQueueForIntf deletes multicast queue info for the current pon interface from kvstore
+// DeleteMcastQueueForIntf deletes multicast queue info for the current pon interface from kvstore
func (rsrcMgr *OpenOltResourceMgr) DeleteMcastQueueForIntf(ctx context.Context) error {
path := McastQueuesForIntf
@@ -1415,7 +1415,7 @@
return nil
}
-//AddFlowGroupToKVStore adds flow group into KV store
+// AddFlowGroupToKVStore adds flow group into KV store
func (rsrcMgr *OpenOltResourceMgr) AddFlowGroupToKVStore(ctx context.Context, groupEntry *ofp.OfpGroupEntry, cached bool) error {
var Value []byte
var err error
@@ -1458,7 +1458,7 @@
return nil
}
-//RemoveFlowGroupFromKVStore removes flow group from KV store
+// RemoveFlowGroupFromKVStore removes flow group from KV store
func (rsrcMgr *OpenOltResourceMgr) RemoveFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) error {
var path string
if cached {
@@ -1479,8 +1479,8 @@
return nil
}
-//GetFlowGroupFromKVStore fetches flow group from the KV store. Returns (false, {} error) if any problem occurs during
-//fetching the data. Returns (true, groupInfo, nil) if the group is fetched successfully.
+// GetFlowGroupFromKVStore fetches flow group from the KV store. Returns (false, {} error) if any problem occurs during
+// fetching the data. Returns (true, groupInfo, nil) if the group is fetched successfully.
// Returns (false, {}, nil) if the group does not exists in the KV store.
func (rsrcMgr *OpenOltResourceMgr) GetFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) (bool, GroupInfo, error) {
var groupInfo GroupInfo
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index b1ba8ef..215933e 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -20,7 +20,7 @@
and few utility functions.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
+// Package adaptercore provides the utility for olt devices, flows and statistics
package resourcemanager
import (