[VOL-4612] Remove intf-id parameters from ResourceManager functions
Change-Id: I214162781e4be69461f22603e5b1f95996ff2ceb
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 140158a..ed7baf7 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1336,7 +1336,7 @@
func (dh *DeviceHandler) activateONU(ctx context.Context, intfID uint32, onuID int64, serialNum *oop.SerialNumber, serialNumber string) error {
logger.Debugw(ctx, "activate-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "serialNum": serialNum, "serialNumber": serialNumber, "device-id": dh.device.Id, "OmccEncryption": dh.openOLT.config.OmccEncryption})
- if err := dh.resourceMgr[intfID].AddNewOnuGemInfoToCacheAndKvStore(ctx, intfID, uint32(onuID), serialNumber); err != nil {
+ if err := dh.resourceMgr[intfID].AddNewOnuGemInfoToCacheAndKvStore(ctx, uint32(onuID), serialNumber); err != nil {
return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": onuID, "intf-id": intfID}, err)
}
var pir uint32 = 1000000
@@ -1425,7 +1425,7 @@
logger.Debugw(ctx, "creating-new-onu", log.Fields{"sn": sn})
// we need to create a new ChildDevice
ponintfid := onuDiscInd.GetIntfId()
- onuID, err = dh.resourceMgr[ponintfid].GetONUID(ctx, ponintfid)
+ onuID, err = dh.resourceMgr[ponintfid].GetONUID(ctx)
logger.Infow(ctx, "creating-new-onu-got-onu-id", log.Fields{"sn": sn, "onuId": onuID})
@@ -1447,7 +1447,7 @@
OnuId: onuID,
}); err != nil {
dh.discOnus.Delete(sn)
- dh.resourceMgr[ponintfid].FreeonuID(ctx, ponintfid, []uint32{onuID}) // NOTE I'm not sure this method is actually cleaning up the right thing
+ dh.resourceMgr[ponintfid].FreeonuID(ctx, []uint32{onuID}) // NOTE I'm not sure this method is actually cleaning up the right thing
return olterrors.NewErrAdapter("core-proxy-child-device-detected-failed", log.Fields{
"pon-intf-id": ponintfid,
"serial-number": sn}, err)
@@ -1971,23 +1971,23 @@
logger.Debugw(ctx, "failed-to-remove-tech-profile-instance-for-onu", log.Fields{"onu-id": onu.OnuID})
}
logger.Debugw(ctx, "deleted-tech-profile-instance-for-onu", log.Fields{"onu-id": onu.OnuID})
- tpIDList := dh.resourceMgr[onu.IntfID].GetTechProfileIDForOnu(ctx, onu.IntfID, onu.OnuID, uniID)
+ tpIDList := dh.resourceMgr[onu.IntfID].GetTechProfileIDForOnu(ctx, onu.OnuID, uniID)
for _, tpID := range tpIDList {
- if err = dh.resourceMgr[onu.IntfID].RemoveMeterInfoForOnu(ctx, "upstream", onu.IntfID, onu.OnuID, uniID, tpID); err != nil {
+ if err = dh.resourceMgr[onu.IntfID].RemoveMeterInfoForOnu(ctx, "upstream", onu.OnuID, uniID, tpID); err != nil {
logger.Debugw(ctx, "failed-to-remove-meter-id-for-onu-upstream", log.Fields{"onu-id": onu.OnuID})
}
logger.Debugw(ctx, "removed-meter-id-for-onu-upstream", log.Fields{"onu-id": onu.OnuID})
- if err = dh.resourceMgr[onu.IntfID].RemoveMeterInfoForOnu(ctx, "downstream", onu.IntfID, onu.OnuID, uniID, tpID); err != nil {
+ if err = dh.resourceMgr[onu.IntfID].RemoveMeterInfoForOnu(ctx, "downstream", onu.OnuID, uniID, tpID); err != nil {
logger.Debugw(ctx, "failed-to-remove-meter-id-for-onu-downstream", log.Fields{"onu-id": onu.OnuID})
}
logger.Debugw(ctx, "removed-meter-id-for-onu-downstream", log.Fields{"onu-id": onu.OnuID})
}
- dh.resourceMgr[onu.IntfID].FreePONResourcesForONU(ctx, onu.IntfID, onu.OnuID, uniID)
- if err = dh.resourceMgr[onu.IntfID].RemoveTechProfileIDsForOnu(ctx, onu.IntfID, onu.OnuID, uniID); err != nil {
+ dh.resourceMgr[onu.IntfID].FreePONResourcesForONU(ctx, onu.OnuID, uniID)
+ if err = dh.resourceMgr[onu.IntfID].RemoveTechProfileIDsForOnu(ctx, onu.OnuID, uniID); err != nil {
logger.Debugw(ctx, "failed-to-remove-tech-profile-id-for-onu", log.Fields{"onu-id": onu.OnuID})
}
logger.Debugw(ctx, "removed-tech-profile-id-for-onu", log.Fields{"onu-id": onu.OnuID})
- if err = dh.resourceMgr[onu.IntfID].DeletePacketInGemPortForOnu(ctx, onu.IntfID, onu.OnuID, port); err != nil {
+ if err = dh.resourceMgr[onu.IntfID].DeletePacketInGemPortForOnu(ctx, onu.OnuID, port); err != nil {
logger.Debugw(ctx, "failed-to-remove-gemport-pkt-in", log.Fields{"intfid": onu.IntfID, "onuid": onu.OnuID, "uniId": uniID})
}
}
@@ -2057,14 +2057,15 @@
logger.Errorw(ctx, "failed-to-clear-data-for-onu", log.Fields{"onu-device": onu})
}
}
- _ = dh.resourceMgr[ponPort].DeleteAllFlowIDsForGemForIntf(ctx, ponPort)
- _ = dh.resourceMgr[ponPort].DeleteAllOnuGemInfoForIntf(ctx, ponPort)
+ _ = dh.resourceMgr[ponPort].DeleteAllFlowIDsForGemForIntf(ctx)
+ _ = dh.resourceMgr[ponPort].DeleteAllOnuGemInfoForIntf(ctx)
dh.resourceMgr[ponPort].DeleteMcastQueueForIntf(ctx)
if err := dh.resourceMgr[ponPort].Delete(ctx, ponPort); err != nil {
logger.Debug(ctx, err)
}
}
- _ = dh.resourceMgr[dh.totalPonPorts].DeleteAllFlowIDsForGemForIntf(ctx, dh.totalPonPorts)
+ // Clean up NNI manager's data
+ _ = dh.resourceMgr[dh.totalPonPorts].DeleteAllFlowIDsForGemForIntf(ctx)
}
/*Delete ONU map for the device*/
@@ -2482,7 +2483,7 @@
onu := &oop.Onu{IntfId: intfID, OnuId: onuID, SerialNumber: sn}
//clear PON resources associated with ONU
- onuGem, err := dh.resourceMgr[intfID].GetOnuGemInfo(ctx, intfID, onuID)
+ onuGem, err := dh.resourceMgr[intfID].GetOnuGemInfo(ctx, onuID)
if err != nil || onuGem == nil || onuGem.OnuID != onuID {
logger.Warnw(ctx, "failed-to-get-onu-info-for-pon-port", log.Fields{
"device-id": dh.device.Id,
@@ -2499,9 +2500,9 @@
}
// Clear flowids for gem cache.
for _, gem := range onuGem.GemPorts {
- _ = dh.resourceMgr[intfID].DeleteFlowIDsForGem(ctx, intfID, gem)
+ _ = dh.resourceMgr[intfID].DeleteFlowIDsForGem(ctx, gem)
}
- if err := dh.resourceMgr[intfID].DelOnuGemInfo(ctx, intfID, onuID); err != nil {
+ if err := dh.resourceMgr[intfID].DelOnuGemInfo(ctx, onuID); err != nil {
logger.Warnw(ctx, "persistence-update-onu-gem-info-failed", log.Fields{
"intf-id": intfID,
"onu-device": onu,
@@ -2512,7 +2513,7 @@
logger.Debugw(ctx, "removed-onu-gem-info", log.Fields{"intf": intfID, "onu-device": onu, "onugem": onuGem})
}
- dh.resourceMgr[intfID].FreeonuID(ctx, intfID, []uint32{onuID})
+ dh.resourceMgr[intfID].FreeonuID(ctx, []uint32{onuID})
dh.onus.Delete(onuKey)
dh.discOnus.Delete(onuSn)
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 9b3a9de..8b24630 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -257,15 +257,15 @@
func (f *OpenOltFlowMgr) registerFlow(ctx context.Context, flowFromCore *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) error {
// In case of nni trap flow
if deviceFlow.AccessIntfId == -1 {
- return f.resourceMgr.RegisterFlowIDForGem(ctx, uint32(deviceFlow.AccessIntfId), uint32(deviceFlow.AccessIntfId), flowFromCore)
+ return f.resourceMgr.RegisterFlowIDForGem(ctx, uint32(deviceFlow.AccessIntfId), flowFromCore)
}
if !deviceFlow.ReplicateFlow && deviceFlow.GemportId > 0 {
// Flow is not replicated in this case, we need to register the flow for a single gem-port
- return f.resourceMgr.RegisterFlowIDForGem(ctx, uint32(deviceFlow.AccessIntfId), uint32(deviceFlow.GemportId), flowFromCore)
+ return f.resourceMgr.RegisterFlowIDForGem(ctx, uint32(deviceFlow.GemportId), flowFromCore)
} else if deviceFlow.ReplicateFlow && len(deviceFlow.PbitToGemport) > 0 {
// Flow is replicated in this case. We need to register the flow for all the gem-ports it is replicated to.
for _, gemPort := range deviceFlow.PbitToGemport {
- if err := f.resourceMgr.RegisterFlowIDForGem(ctx, uint32(deviceFlow.AccessIntfId), gemPort, flowFromCore); err != nil {
+ if err := f.resourceMgr.RegisterFlowIDForGem(ctx, gemPort, flowFromCore); err != nil {
return err
}
}
@@ -390,7 +390,7 @@
* then the scheduler and queues configuration is applied on the OLT device
* in the given direction.
*/
- meterInfo, err := f.resourceMgr.GetMeterInfoForOnu(ctx, direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID)
+ meterInfo, err := f.resourceMgr.GetMeterInfoForOnu(ctx, direction, sq.onuID, sq.uniID, sq.tpID)
if err != nil {
return olterrors.NewErrNotFound("meter",
log.Fields{"intf-id": sq.intfID,
@@ -403,7 +403,7 @@
if meterInfo != nil && meterInfo.MeterID == sq.meterID {
logger.Infow(ctx, "scheduler-already-created-for-direction",
log.Fields{"device-id": f.deviceHandler.device.Id, "direction": direction, "meter-id": sq.meterID})
- if err = f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID, true); err != nil {
+ if err = f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, direction, sq.onuID, sq.uniID, sq.tpID, true); err != nil {
return err
}
@@ -478,7 +478,7 @@
/* After we successfully applied the scheduler configuration on the OLT device,
* store the meter id on the KV store, for further reference.
*/
- if err := f.resourceMgr.StoreMeterInfoForOnu(ctx, direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID, meterInfo); err != nil {
+ if err := f.resourceMgr.StoreMeterInfoForOnu(ctx, direction, sq.onuID, sq.uniID, sq.tpID, meterInfo); err != nil {
return olterrors.NewErrAdapter("failed-updating-meter-id",
log.Fields{"onu-id": sq.onuID,
"meter-id": sq.meterID,
@@ -585,7 +585,7 @@
}
f.grpMgr.UpdateInterfaceToMcastQueueMap(sq.intfID, val)
//also store the queue info in kv store
- if err := f.resourceMgr.AddMcastQueueForIntf(ctx, sq.intfID, multicastQueuePerPonPort.GemportId, multicastQueuePerPonPort.Priority); err != nil {
+ if err := f.resourceMgr.AddMcastQueueForIntf(ctx, multicastQueuePerPonPort.GemportId, multicastQueuePerPonPort.Priority); err != nil {
logger.Errorw(ctx, "failed-to-add-mcast-queue", log.Fields{"err": err})
return err
}
@@ -684,7 +684,7 @@
allocID := sq.tpInst.(*tp_pb.TechProfileInstance).UsScheduler.AllocId
// Delete the TCONT on the ONU.
uni := getUniPortPath(f.deviceHandler.device.Id, sq.intfID, int32(sq.onuID), int32(sq.uniID))
- tpPath := f.getTPpath(ctx, sq.intfID, uni, sq.tpID)
+ tpPath := f.getTPpath(ctx, uni, sq.tpID)
if err := f.sendDeleteTcontToChild(ctx, sq.intfID, sq.onuID, sq.uniID, allocID, tpPath); err != nil {
logger.Errorw(ctx, "error-processing-delete-tcont-towards-onu",
log.Fields{
@@ -799,9 +799,9 @@
var gemPortIDs []uint32
tpInstanceExists := false
var err error
- allocIDs = f.resourceMgr.GetCurrentAllocIDsForOnu(ctx, intfID, onuID, uniID)
- allgemPortIDs = f.resourceMgr.GetCurrentGEMPortIDsForOnu(ctx, intfID, onuID, uniID)
- tpPath := f.getTPpath(ctx, intfID, uni, TpID)
+ allocIDs = f.resourceMgr.GetCurrentAllocIDsForOnu(ctx, onuID, uniID)
+ allgemPortIDs = f.resourceMgr.GetCurrentGEMPortIDsForOnu(ctx, onuID, uniID)
+ tpPath := f.getTPpath(ctx, uni, TpID)
logger.Debugw(ctx, "creating-new-tcont-and-gem", log.Fields{
"intf-id": intfID,
@@ -827,7 +827,7 @@
"device-id": f.deviceHandler.device.Id})
return 0, nil, nil
}
- if err := f.resourceMgr.UpdateTechProfileIDForOnu(ctx, intfID, onuID, uniID, TpID); err != nil {
+ if err := f.resourceMgr.UpdateTechProfileIDForOnu(ctx, onuID, uniID, TpID); err != nil {
logger.Warnw(ctx, "failed-to-update-tech-profile-id", log.Fields{"err": err})
}
} else {
@@ -939,16 +939,16 @@
"gemport-ids": gemPortIDs,
"device-id": f.deviceHandler.device.Id})
/* Update the allocated alloc_id and gem_port_id for the ONU/UNI to KV store */
- if err := f.resourceMgr.UpdateAllocIdsForOnu(ctx, intfID, onuID, uniID, allocID); err != nil {
+ if err := f.resourceMgr.UpdateAllocIdsForOnu(ctx, onuID, uniID, allocID); err != nil {
logger.Errorw(ctx, "error-while-uploading-allocid-to-kv-store", log.Fields{"device-id": f.deviceHandler.device.Id, "onuID": onuID, "allocID": allocID})
}
- if err := f.resourceMgr.UpdateGEMPortIDsForOnu(ctx, intfID, onuID, uniID, gemPortIDs); err != nil {
+ if err := f.resourceMgr.UpdateGEMPortIDsForOnu(ctx, onuID, uniID, gemPortIDs); err != nil {
logger.Errorw(ctx, "error-while-uploading-gemports-to-kv-store", log.Fields{"device-id": f.deviceHandler.device.Id, "onuID": onuID, "gemPort": gemPortIDs})
}
logger.Infow(ctx, "stored-tconts-and-gem-into-kv-store-successfully", log.Fields{"device-id": f.deviceHandler.device.Id})
for _, gemPort := range gemPortIDs {
- if err := f.resourceMgr.AddGemToOnuGemInfo(ctx, intfID, onuID, gemPort); err != nil {
+ if err := f.resourceMgr.AddGemToOnuGemInfo(ctx, onuID, gemPort); err != nil {
logger.Errorw(ctx, "error-while-uploading-onugeminfos-to-kv-store", log.Fields{"device-id": f.deviceHandler.device.Id, "onuID": onuID, "gemPort": gemPort})
}
}
@@ -1055,7 +1055,7 @@
"gemport-id": gemPortID,
"logicalflow": *logicalFlow})
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Infow(ctx, "flow-already-exists",
log.Fields{
@@ -1154,7 +1154,7 @@
classifier[UDPDst] = uint32(67)
classifier[PacketTagType] = SingleTag
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Infow(ctx, "flow-exists--not-re-adding",
log.Fields{
@@ -1252,7 +1252,7 @@
action[TrapToHost] = true
classifier[PacketTagType] = SingleTag
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, networkIntfID, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Infow(ctx, "flow-exists-not-re-adding", log.Fields{"device-id": f.deviceHandler.device.Id})
return nil
@@ -1343,7 +1343,7 @@
uplinkClassifier[VlanPcp] = classifier[VlanPcp]
// Fill action
uplinkAction[TrapToHost] = true
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Infow(ctx, "flow-exists-not-re-adding", log.Fields{
"device-id": f.deviceHandler.device.Id,
@@ -1516,7 +1516,7 @@
}
// getTPpath return the ETCD path for a given UNI port
-func (f *OpenOltFlowMgr) getTPpath(ctx context.Context, intfID uint32, uniPath string, TpID uint32) string {
+func (f *OpenOltFlowMgr) getTPpath(ctx context.Context, uniPath string, TpID uint32) string {
return f.techprofile.GetTechProfileInstanceKey(ctx, TpID, uniPath)
}
@@ -1531,7 +1531,7 @@
// uncleaned on the OLT. So we force clean up here and ignore any error that OLT returns during the
// force cleanup (possible if the OLT has already cleared those resources).
func (f *OpenOltFlowMgr) DeleteTechProfileInstances(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) error {
- tpIDList := f.resourceMgr.GetTechProfileIDForOnu(ctx, intfID, onuID, uniID)
+ tpIDList := f.resourceMgr.GetTechProfileIDForOnu(ctx, onuID, uniID)
uniPortName := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
for _, tpID := range tpIDList {
@@ -1539,7 +1539,7 @@
// Force cleanup scheduler/queues -- start
uniPortNum := plt.MkUniPortNum(ctx, intfID, onuID, uniID)
uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
- tpPath := f.getTPpath(ctx, intfID, uni, tpID)
+ tpPath := f.getTPpath(ctx, uni, tpID)
tpInst, err := f.techprofile.GetTPInstance(ctx, tpPath)
if err != nil || tpInst == nil { // This should not happen, something wrong in KV backend transaction
logger.Warnw(ctx, "tech-profile-not-in-kv-store",
@@ -1687,8 +1687,7 @@
if err != nil {
return olterrors.NewErrInvalidValue(log.Fields{"nni-port-number": portNo}, err).Log()
}
-
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, f.ponPortIdx, int32(onuID), flow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), flow.Id)
if present {
logger.Infow(ctx, "flow-exists--not-re-adding", log.Fields{"device-id": f.deviceHandler.device.Id})
return nil
@@ -1899,7 +1898,7 @@
logger.Debugw(ctx, "clearing-resources", log.Fields{"intfID": intfID, "onuID": onuID, "uniID": uniID, "tpID": tpID})
uni := getUniPortPath(f.deviceHandler.device.Id, intfID, onuID, uniID)
- tpPath := f.getTPpath(ctx, intfID, uni, tpID)
+ tpPath := f.getTPpath(ctx, uni, tpID)
logger.Debugw(ctx, "getting-techprofile-instance-for-subscriber",
log.Fields{
"tpPath": tpPath,
@@ -1930,14 +1929,14 @@
gemPortID := gemPort.GemportId
used := f.resourceMgr.IsGemPortUsedByAnotherFlow(gemPortID, flowID)
if used {
- flowIDs, err := f.resourceMgr.GetFlowIDsForGem(ctx, intfID, gemPortID)
+ flowIDs, err := f.resourceMgr.GetFlowIDsForGem(ctx, gemPortID)
if err != nil {
return err
}
for i, flowIDinMap := range flowIDs {
if flowIDinMap == flowID {
flowIDs = append(flowIDs[:i], flowIDs[i+1:]...)
- if err := f.resourceMgr.UpdateFlowIDsForGem(ctx, intfID, gemPortID, flowIDs); err != nil {
+ if err := f.resourceMgr.UpdateFlowIDsForGem(ctx, gemPortID, flowIDs); err != nil {
return err
}
break
@@ -1962,7 +1961,7 @@
// Free TPInstance, TPID, GemPorts and Traffic Queues. AllocID and Schedulers will be cleared later only if they are not shared across all the UNIs
switch techprofileInst := techprofileInst.(type) {
case *tp_pb.TechProfileInstance:
- if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, intfID, uint32(onuID), uint32(uniID), tpID); err != nil {
+ if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, uint32(onuID), uint32(uniID), tpID); err != nil {
logger.Warn(ctx, err)
}
if err := f.DeleteTechProfileInstance(ctx, intfID, uint32(onuID), uint32(uniID), "", tpID); err != nil {
@@ -1971,9 +1970,9 @@
for _, gemPort := range techprofileInst.UpstreamGemPortAttributeList {
gemPortID := gemPort.GemportId
- _ = f.resourceMgr.RemoveGemFromOnuGemInfo(ctx, intfID, uint32(onuID), gemPortID) // ignore error and proceed.
+ _ = f.resourceMgr.RemoveGemFromOnuGemInfo(ctx, uint32(onuID), gemPortID) // ignore error and proceed.
- if err := f.resourceMgr.DeleteFlowIDsForGem(ctx, intfID, gemPortID); err != nil {
+ if err := f.resourceMgr.DeleteFlowIDsForGem(ctx, gemPortID); err != nil {
logger.Errorw(ctx, "error-removing-flow-ids-of-gem-port",
log.Fields{
"err": err,
@@ -2003,13 +2002,13 @@
allocExists := f.isAllocUsedByAnotherUNI(ctx, schedQueue)
if !allocExists {
// all alloc object references removed, remove upstream scheduler
- if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "upstream", intfID, uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
+ if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "upstream", uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
if err := f.RemoveScheduler(ctx, schedQueue); err != nil {
logger.Warn(ctx, err)
}
}
// remove alloc id from resource pool by setting the 'freeFromResourcePool' to true
- f.resourceMgr.FreeAllocID(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst.UsScheduler.AllocId, true)
+ f.resourceMgr.FreeAllocID(ctx, uint32(onuID), uint32(uniID), techprofileInst.UsScheduler.AllocId, true)
} else {
// just remove meter reference for the upstream direction for the current pon/onu/uni
// The upstream scheduler, alloc id and meter-reference for the last remaining pon/onu/uni will be removed when no other alloc references that TP
@@ -2018,18 +2017,18 @@
}
// setting 'freeFromResourcePool' to false in resourceMgr.FreeAllocID will only remove alloc-id data for the given pon/onu/uni
// but still preserve it on the resource pool.
- f.resourceMgr.FreeAllocID(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst.UsScheduler.AllocId, false)
+ f.resourceMgr.FreeAllocID(ctx, uint32(onuID), uint32(uniID), techprofileInst.UsScheduler.AllocId, false)
}
// Downstream scheduler removal is simple, just invoke RemoveScheduler without all the complex handling we do for the alloc object.
schedQueue.direction = tp_pb.Direction_DOWNSTREAM
- if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "downstream", intfID, uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
+ if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "downstream", uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
if err := f.RemoveScheduler(ctx, schedQueue); err != nil {
logger.Warn(ctx, err)
}
}
case *tp_pb.EponTechProfileInstance:
- if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, intfID, uint32(onuID), uint32(uniID), tpID); err != nil {
+ if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, uint32(onuID), uint32(uniID), tpID); err != nil {
logger.Warn(ctx, err)
}
if err := f.DeleteTechProfileInstance(ctx, intfID, uint32(onuID), uint32(uniID), "", tpID); err != nil {
@@ -2046,7 +2045,7 @@
"alloc-id": techprofileInst.AllocId,
"error": err})
}
- f.resourceMgr.FreeAllocID(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst.AllocId, true)
+ f.resourceMgr.FreeAllocID(ctx, uint32(onuID), uint32(uniID), techprofileInst.AllocId, true)
default:
logger.Errorw(ctx, "error-unknown-tech",
log.Fields{
@@ -2069,7 +2068,7 @@
"device-id": f.deviceHandler.device.Id,
"gemport-id": gemPort.GemportId})
}
- f.resourceMgr.FreeGemPortID(ctx, intfID, uint32(onuID), uint32(uniID), gemPort.GemportId)
+ f.resourceMgr.FreeGemPortID(ctx, uint32(onuID), uint32(uniID), gemPort.GemportId)
}
}
}
@@ -2154,7 +2153,7 @@
}
// Decrement reference count for the meter associated with the given <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction>
- if err := f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, flowDirection, Intf, uint32(onuID), uint32(uniID), tpID, false); err != nil {
+ if err := f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, flowDirection, uint32(onuID), uint32(uniID), tpID, false); err != nil {
return err
}
return nil
@@ -2362,7 +2361,7 @@
return f.addIgmpTrapFlowOnNNI(ctx, flow, classifierInfo, portNo)
}
- f.resourceMgr.AddUniPortToOnuInfo(ctx, intfID, onuID, portNo)
+ f.resourceMgr.AddUniPortToOnuInfo(ctx, onuID, portNo)
tpID, err := getTpIDFromFlow(ctx, flow)
if err != nil {
@@ -2413,7 +2412,7 @@
onuID := NoneOnuID
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, networkInterfaceID, int32(onuID), flow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), flow.Id)
if present {
logger.Infow(ctx, "multicast-flow-exists-not-re-adding", log.Fields{"classifier-info": classifierInfo})
return nil
@@ -2484,7 +2483,7 @@
}
logger.Debugw(ctx, "got-child-device-from-olt-device-handler", log.Fields{"onu-id": onuDev.deviceID})
- tpPath := f.getTPpath(ctx, intfID, uni, TpID)
+ tpPath := f.getTPpath(ctx, uni, TpID)
tpDownloadMsg := &ia.TechProfileDownloadMessage{
DeviceId: onuDev.deviceID,
UniId: uniID,
@@ -2610,7 +2609,7 @@
err)
}
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, f.ponPortIdx, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Info(ctx, "flow-exists-not-re-adding")
return nil
@@ -2711,8 +2710,7 @@
"action": action},
err)
}
-
- present, err := f.resourceMgr.IsFlowOnKvStore(ctx, f.ponPortIdx, int32(onuID), logicalFlow.Id)
+ present, err := f.resourceMgr.IsFlowOnKvStore(ctx, int32(onuID), logicalFlow.Id)
if present {
logger.Info(ctx, "igmp-flow-exists-not-re-adding")
return nil
@@ -3324,7 +3322,7 @@
}
// check reverse direction - if reverse meter exists, tech profile instance is in use - do not delete
- if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, reverseDirection, intfID, onuID, uniID, tpID); KvStoreMeter != nil {
+ if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, reverseDirection, onuID, uniID, tpID); KvStoreMeter != nil {
return
}
@@ -3332,15 +3330,15 @@
logger.Warnw(ctx, "reverting-tech-profile-instance-and-tech-profile-id-for-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "uni-id": uniID, "tp-id": tpID})
uniPortName := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
_ = f.DeleteTechProfileInstance(ctx, intfID, onuID, uniID, uniPortName, tpID)
- _ = f.resourceMgr.RemoveTechProfileIDForOnu(ctx, intfID, onuID, uniID, tpID)
+ _ = f.resourceMgr.RemoveTechProfileIDForOnu(ctx, onuID, uniID, tpID)
// free gem/alloc
switch techprofileInst := sq.tpInst.(type) {
case *tp_pb.TechProfileInstance:
for _, gem := range techprofileInst.UpstreamGemPortAttributeList {
- f.resourceMgr.FreeGemPortID(ctx, intfID, onuID, uniID, gem.GemportId)
+ f.resourceMgr.FreeGemPortID(ctx, onuID, uniID, gem.GemportId)
}
- f.resourceMgr.FreeAllocID(ctx, intfID, onuID, uniID, techprofileInst.UsScheduler.AllocId, true)
+ f.resourceMgr.FreeAllocID(ctx, onuID, uniID, techprofileInst.UsScheduler.AllocId, true)
}
}
@@ -3356,7 +3354,7 @@
// validateMeter validates if there is a meter mismatch for the given direction. It also clears the stale meter if the reference count is zero
func (f *OpenOltFlowMgr) validateMeter(ctx context.Context, direction string, meterID uint32, intfID uint32, onuID uint32, uniID uint32, tpID uint32) error {
- meterInfo, err := f.resourceMgr.GetMeterInfoForOnu(ctx, direction, intfID, onuID, uniID, tpID)
+ meterInfo, err := f.resourceMgr.GetMeterInfoForOnu(ctx, direction, onuID, uniID, tpID)
if err != nil {
return olterrors.NewErrNotFound("meter",
log.Fields{"intf-id": intfID,
@@ -3368,7 +3366,7 @@
if meterInfo != nil {
// If RefCnt become 0 clear the meter information from the DB.
if meterInfo.MeterID != meterID && meterInfo.RefCnt == 0 {
- if err := f.resourceMgr.RemoveMeterInfoForOnu(ctx, direction, intfID, onuID, uniID, tpID); err != nil {
+ if err := f.resourceMgr.RemoveMeterInfoForOnu(ctx, direction, onuID, uniID, tpID); err != nil {
return err
}
} else if meterInfo.MeterID != meterID {
@@ -3391,7 +3389,7 @@
/* After we successfully remove the scheduler configuration on the OLT device,
* delete the meter id on the KV store.
*/
- err := f.resourceMgr.RemoveMeterInfoForOnu(ctx, direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID)
+ err := f.resourceMgr.RemoveMeterInfoForOnu(ctx, direction, sq.onuID, sq.uniID, sq.tpID)
if err != nil {
return olterrors.NewErrAdapter("unable-to-remove-meter",
log.Fields{
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 301e2e9..9566637 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -244,7 +244,7 @@
}
ResourceMgr.InitLocalCache()
- if err := ResourceMgr.LoadLocalCacheFromKVStore(ctx, PonIntfID); err != nil {
+ if err := ResourceMgr.LoadLocalCacheFromKVStore(ctx); err != nil {
logger.Error(ctx, "failed-to-load-local-cache-from-kvstore")
}
logger.Info(ctx, "Initialization of resource manager success!")
@@ -265,10 +265,10 @@
}
//LoadLocalCacheFromKVStore loads local maps
-func (rsrcMgr *OpenOltResourceMgr) LoadLocalCacheFromKVStore(ctx context.Context, PonIntfID uint32) error {
+func (rsrcMgr *OpenOltResourceMgr) LoadLocalCacheFromKVStore(ctx context.Context) error {
//List all the keys for OnuGemInfo
- prefixPath := fmt.Sprintf(OnuGemInfoPathPathPrefix, PonIntfID)
+ prefixPath := fmt.Sprintf(OnuGemInfoPathPathPrefix, rsrcMgr.PonIntfID)
keys, err := rsrcMgr.KVStore.List(ctx, prefixPath)
logger.Debug(ctx, "load-local-cache-from-KV-store-started")
if err != nil {
@@ -369,13 +369,13 @@
}
// GetONUID returns the available onuID for the given pon-port
-func (rsrcMgr *OpenOltResourceMgr) GetONUID(ctx context.Context, PonIntfID uint32) (uint32, error) {
+func (rsrcMgr *OpenOltResourceMgr) GetONUID(ctx context.Context) (uint32, error) {
// Get ONU id for a provided pon interface ID.
- onuID, err := rsrcMgr.TechprofileRef.GetResourceID(ctx, PonIntfID,
+ onuID, err := rsrcMgr.TechprofileRef.GetResourceID(ctx, rsrcMgr.PonIntfID,
ponrmgr.ONU_ID, 1)
if err != nil {
logger.Errorf(ctx, "Failed to get resource for interface %d for type %s",
- PonIntfID, ponrmgr.ONU_ID)
+ rsrcMgr.PonIntfID, ponrmgr.ONU_ID)
return 0, err
}
if len(onuID) > 0 {
@@ -386,9 +386,9 @@
}
// UpdateAllocIdsForOnu updates alloc ids in kv store for a given pon interface id, onu id and uni id
-func (rsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(ctx context.Context, ponPort uint32, onuID uint32, uniID uint32, allocIDs []uint32) error {
+func (rsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(ctx context.Context, onuID uint32, uniID uint32, allocIDs []uint32) error {
- intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+ intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", rsrcMgr.PonIntfID, onuID, uniID)
// Note: in case the write to DB fails there could be inconsistent data between cache and db.
// Although this is highly unlikely with DB retries in place, this is something we have to deal with in the next release
@@ -405,10 +405,10 @@
}
// GetCurrentGEMPortIDsForOnu returns gem ports for given pon interface , onu id and uni id
-func (rsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(ctx context.Context, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(ctx context.Context, onuID uint32,
uniID uint32) []uint32 {
- intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", rsrcMgr.PonIntfID, onuID, uniID)
// fetch from cache
rsrcMgr.gemPortIDsForOnuLock.RLock()
@@ -429,9 +429,9 @@
}
// GetCurrentAllocIDsForOnu returns alloc ids for given pon interface and onu id
-func (rsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDsForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) []uint32 {
+func (rsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDsForOnu(ctx context.Context, onuID uint32, uniID uint32) []uint32 {
- intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", rsrcMgr.PonIntfID, onuID, uniID)
// fetch from cache
rsrcMgr.allocIDsForOnuLock.RLock()
allocIDs, ok := rsrcMgr.allocIDsForOnu[intfOnuIDuniID]
@@ -450,41 +450,41 @@
}
// RemoveAllocIDForOnu removes the alloc id for given pon interface, onu id, uni id and alloc id
-func (rsrcMgr *OpenOltResourceMgr) RemoveAllocIDForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, allocID uint32) {
- allocIDs := rsrcMgr.GetCurrentAllocIDsForOnu(ctx, intfID, onuID, uniID)
+func (rsrcMgr *OpenOltResourceMgr) RemoveAllocIDForOnu(ctx context.Context, onuID uint32, uniID uint32, allocID uint32) {
+ allocIDs := rsrcMgr.GetCurrentAllocIDsForOnu(ctx, onuID, uniID)
for i := 0; i < len(allocIDs); i++ {
if allocIDs[i] == allocID {
allocIDs = append(allocIDs[:i], allocIDs[i+1:]...)
break
}
}
- err := rsrcMgr.UpdateAllocIdsForOnu(ctx, intfID, onuID, uniID, allocIDs)
+ err := rsrcMgr.UpdateAllocIdsForOnu(ctx, onuID, uniID, allocIDs)
if err != nil {
logger.Errorf(ctx, "Failed to Remove Alloc Id For Onu. intfID %d onuID %d uniID %d allocID %d",
- intfID, onuID, uniID, allocID)
+ rsrcMgr.PonIntfID, onuID, uniID, allocID)
}
}
// RemoveGemPortIDForOnu removes the gem port id for given pon interface, onu id, uni id and gem port id
-func (rsrcMgr *OpenOltResourceMgr) RemoveGemPortIDForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, gemPortID uint32) {
- gemPortIDs := rsrcMgr.GetCurrentGEMPortIDsForOnu(ctx, intfID, onuID, uniID)
+func (rsrcMgr *OpenOltResourceMgr) RemoveGemPortIDForOnu(ctx context.Context, onuID uint32, uniID uint32, gemPortID uint32) {
+ gemPortIDs := rsrcMgr.GetCurrentGEMPortIDsForOnu(ctx, onuID, uniID)
for i := 0; i < len(gemPortIDs); i++ {
if gemPortIDs[i] == gemPortID {
gemPortIDs = append(gemPortIDs[:i], gemPortIDs[i+1:]...)
break
}
}
- err := rsrcMgr.UpdateGEMPortIDsForOnu(ctx, intfID, onuID, uniID, gemPortIDs)
+ err := rsrcMgr.UpdateGEMPortIDsForOnu(ctx, onuID, uniID, gemPortIDs)
if err != nil {
logger.Errorf(ctx, "Failed to Remove Gem Id For Onu. intfID %d onuID %d uniID %d gemPortId %d",
- intfID, onuID, uniID, gemPortID)
+ rsrcMgr.PonIntfID, onuID, uniID, gemPortID)
}
}
// UpdateGEMPortIDsForOnu updates gemport ids on to the kv store for a given pon port, onu id and uni id
-func (rsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(ctx context.Context, ponPort uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(ctx context.Context, onuID uint32,
uniID uint32, gemIDs []uint32) error {
- intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+ intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", rsrcMgr.PonIntfID, onuID, uniID)
if err := rsrcMgr.PonRsrMgr.UpdateGEMPortIDsForOnu(ctx, intfOnuIDuniID, gemIDs); err != nil {
logger.Errorw(ctx, "Failed to update gem port ids for onu", log.Fields{"err": err})
@@ -499,19 +499,19 @@
}
// FreeonuID releases(make free) onu id for a particular pon-port
-func (rsrcMgr *OpenOltResourceMgr) FreeonuID(ctx context.Context, intfID uint32, onuID []uint32) {
+func (rsrcMgr *OpenOltResourceMgr) FreeonuID(ctx context.Context, onuID []uint32) {
if len(onuID) == 0 {
logger.Info(ctx, "onu id slice is nil, nothing to free")
return
}
- if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, intfID, ponrmgr.ONU_ID, onuID); err != nil {
+ if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, rsrcMgr.PonIntfID, ponrmgr.ONU_ID, onuID); err != nil {
logger.Errorw(ctx, "error-while-freeing-onu-id", log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"err": err.Error(),
})
} else {
- logger.Infow(ctx, "freed onu id", log.Fields{"intfID": intfID, "onuID": onuID})
+ logger.Infow(ctx, "freed onu id", log.Fields{"intfID": rsrcMgr.PonIntfID, "onuID": onuID})
}
}
@@ -521,16 +521,16 @@
// the ONU so as not cause resource corruption since there are no mutexes used here.
// Setting freeFromResourcePool to false will not clear it from the resource pool but only
// clear it for the given pon/onu/uni
-func (rsrcMgr *OpenOltResourceMgr) FreeAllocID(ctx context.Context, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) FreeAllocID(ctx context.Context, onuID uint32,
uniID uint32, allocID uint32, freeFromResourcePool bool) {
- rsrcMgr.RemoveAllocIDForOnu(ctx, intfID, onuID, uniID, allocID)
+ rsrcMgr.RemoveAllocIDForOnu(ctx, onuID, uniID, allocID)
if freeFromResourcePool {
allocIDs := make([]uint32, 0)
allocIDs = append(allocIDs, allocID)
- if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, intfID, ponrmgr.ALLOC_ID, allocIDs); err != nil {
+ if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, rsrcMgr.PonIntfID, ponrmgr.ALLOC_ID, allocIDs); err != nil {
logger.Errorw(ctx, "error-while-freeing-alloc-id", log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"err": err.Error(),
})
@@ -542,15 +542,15 @@
// for the given OLT device.
// The caller should ensure that this is a blocking call and this operation is serialized for
// the ONU so as not cause resource corruption since there are no mutexes used here.
-func (rsrcMgr *OpenOltResourceMgr) FreeGemPortID(ctx context.Context, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) FreeGemPortID(ctx context.Context, onuID uint32,
uniID uint32, gemPortID uint32) {
- rsrcMgr.RemoveGemPortIDForOnu(ctx, intfID, onuID, uniID, gemPortID)
+ rsrcMgr.RemoveGemPortIDForOnu(ctx, onuID, uniID, gemPortID)
gemPortIDs := make([]uint32, 0)
gemPortIDs = append(gemPortIDs, gemPortID)
- if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, intfID, ponrmgr.GEMPORT_ID, gemPortIDs); err != nil {
+ if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, rsrcMgr.PonIntfID, ponrmgr.GEMPORT_ID, gemPortIDs); err != nil {
logger.Errorw(ctx, "error-while-freeing-gem-port-id", log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"err": err.Error(),
})
@@ -558,17 +558,17 @@
}
// FreePONResourcesForONU make the pon resources free for a given pon interface and onu id
-func (rsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) {
+func (rsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(ctx context.Context, onuID uint32, uniID uint32) {
- intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ intfOnuIDuniID := fmt.Sprintf("%d,%d,%d", rsrcMgr.PonIntfID, onuID, uniID)
AllocIDs := rsrcMgr.PonRsrMgr.GetCurrentAllocIDForOnu(ctx, intfOnuIDuniID)
- if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, intfID,
+ if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, rsrcMgr.PonIntfID,
ponrmgr.ALLOC_ID,
AllocIDs); err != nil {
logger.Errorw(ctx, "error-while-freeing-all-alloc-ids-for-onu", log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"err": err.Error(),
})
@@ -581,11 +581,11 @@
GEMPortIDs := rsrcMgr.PonRsrMgr.GetCurrentGEMPortIDsForOnu(ctx, intfOnuIDuniID)
- if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, intfID,
+ if err := rsrcMgr.TechprofileRef.FreeResourceID(ctx, rsrcMgr.PonIntfID,
ponrmgr.GEMPORT_ID,
GEMPortIDs); err != nil {
logger.Errorw(ctx, "error-while-freeing-all-gem-port-ids-for-onu", log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"err": err.Error(),
})
@@ -602,12 +602,12 @@
// IsFlowOnKvStore checks if the given flowID is present on the kv store
// Returns true if the flowID is found, otherwise it returns false
-func (rsrcMgr *OpenOltResourceMgr) IsFlowOnKvStore(ctx context.Context, intfID uint32, onuID int32, flowID uint64) (bool, error) {
+func (rsrcMgr *OpenOltResourceMgr) IsFlowOnKvStore(ctx context.Context, onuID int32, flowID uint64) (bool, error) {
var anyError error
// In case of nni trap flow
if onuID == -1 {
- nniTrapflowIDs, err := rsrcMgr.GetFlowIDsForGem(ctx, NNI, NNI)
+ nniTrapflowIDs, err := rsrcMgr.GetFlowIDsForGem(ctx, NNI)
if err != nil {
logger.Warnw(ctx, "failed-to-get-nni-trap-flowIDs", log.Fields{"err": err})
return false, err
@@ -619,14 +619,14 @@
}
}
- path := fmt.Sprintf(OnuGemInfoPath, intfID, onuID)
+ path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
rsrcMgr.onuGemInfoLock.RLock()
val, ok := rsrcMgr.onuGemInfo[path]
rsrcMgr.onuGemInfoLock.RUnlock()
if ok {
for _, gem := range val.GemPorts {
- flowIDs, err := rsrcMgr.GetFlowIDsForGem(ctx, intfID, gem)
+ flowIDs, err := rsrcMgr.GetFlowIDsForGem(ctx, gem)
if err != nil {
anyError = err
logger.Warnw(ctx, "failed-to-get-flowIDs-for-gem", log.Fields{"err": err, "onuID": onuID, "gem": gem})
@@ -644,8 +644,8 @@
// GetTechProfileIDForOnu fetches Tech-Profile-ID from the KV-Store for the given onu based on the path
// This path is formed as the following: {intfID, onuID, uniID}/tp_id
-func (rsrcMgr *OpenOltResourceMgr) GetTechProfileIDForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) []uint32 {
- Path := fmt.Sprintf(tpIDPathSuffix, intfID, onuID, uniID)
+func (rsrcMgr *OpenOltResourceMgr) GetTechProfileIDForOnu(ctx context.Context, onuID uint32, uniID uint32) []uint32 {
+ Path := fmt.Sprintf(tpIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID)
// fetch from cache
rsrcMgr.techProfileIDsForOnuLock.RLock()
tpIDs, ok := rsrcMgr.techProfileIDsForOnu[Path]
@@ -682,8 +682,8 @@
// RemoveTechProfileIDsForOnu deletes all tech profile ids from the KV-Store for the given onu based on the path
// This path is formed as the following: {intfID, onuID, uniID}/tp_id
-func (rsrcMgr *OpenOltResourceMgr) RemoveTechProfileIDsForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) error {
- intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, intfID, onuID, uniID)
+func (rsrcMgr *OpenOltResourceMgr) RemoveTechProfileIDsForOnu(ctx context.Context, onuID uint32, uniID uint32) error {
+ intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID)
if err := rsrcMgr.KVStore.Delete(ctx, intfOnuUniID); err != nil {
logger.Errorw(ctx, "Failed to delete techprofile id resource in KV store", log.Fields{"path": intfOnuUniID})
@@ -699,14 +699,14 @@
// RemoveTechProfileIDForOnu deletes a specific tech profile id from the KV-Store for the given onu based on the path
// This path is formed as the following: {intfID, onuID, uniID}/tp_id
-func (rsrcMgr *OpenOltResourceMgr) RemoveTechProfileIDForOnu(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, tpID uint32) error {
- tpIDList := rsrcMgr.GetTechProfileIDForOnu(ctx, intfID, onuID, uniID)
+func (rsrcMgr *OpenOltResourceMgr) RemoveTechProfileIDForOnu(ctx context.Context, onuID uint32, uniID uint32, tpID uint32) error {
+ tpIDList := rsrcMgr.GetTechProfileIDForOnu(ctx, onuID, uniID)
for i, tpIDInList := range tpIDList {
if tpIDInList == tpID {
tpIDList = append(tpIDList[:i], tpIDList[i+1:]...)
}
}
- intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, intfID, onuID, uniID)
+ intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID)
Value, err := json.Marshal(tpIDList)
if err != nil {
@@ -727,14 +727,14 @@
// UpdateTechProfileIDForOnu updates (put) already present tech-profile-id for the given onu based on the path
// This path is formed as the following: {intfID, onuID, uniID}/tp_id
-func (rsrcMgr *OpenOltResourceMgr) UpdateTechProfileIDForOnu(ctx context.Context, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) UpdateTechProfileIDForOnu(ctx context.Context, onuID uint32,
uniID uint32, tpID uint32) error {
var Value []byte
var err error
- intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, intfID, onuID, uniID)
+ intfOnuUniID := fmt.Sprintf(tpIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID)
- tpIDList := rsrcMgr.GetTechProfileIDForOnu(ctx, intfID, onuID, uniID)
+ tpIDList := rsrcMgr.GetTechProfileIDForOnu(ctx, onuID, uniID)
for _, value := range tpIDList {
if value == tpID {
logger.Debugf(ctx, "tpID %d is already in tpIdList for the path %s", tpID, intfOnuUniID)
@@ -763,11 +763,11 @@
// StoreMeterInfoForOnu updates the meter id in the KV-Store for the given onu based on the path
// This path is formed as the following: <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction>
-func (rsrcMgr *OpenOltResourceMgr) StoreMeterInfoForOnu(ctx context.Context, Direction string, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) StoreMeterInfoForOnu(ctx context.Context, Direction string, onuID uint32,
uniID uint32, tpID uint32, meterInfo *MeterInfo) error {
var Value []byte
var err error
- intfOnuUniID := fmt.Sprintf(MeterIDPathSuffix, intfID, onuID, uniID, tpID, Direction)
+ intfOnuUniID := fmt.Sprintf(MeterIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID, tpID, Direction)
Value, err = json.Marshal(*meterInfo)
if err != nil {
@@ -789,9 +789,9 @@
// GetMeterInfoForOnu fetches the meter id from the kv store for the given onu based on the path
// This path is formed as the following: <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction>
-func (rsrcMgr *OpenOltResourceMgr) GetMeterInfoForOnu(ctx context.Context, Direction string, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) GetMeterInfoForOnu(ctx context.Context, Direction string, onuID uint32,
uniID uint32, tpID uint32) (*MeterInfo, error) {
- Path := fmt.Sprintf(MeterIDPathSuffix, intfID, onuID, uniID, tpID, Direction)
+ Path := fmt.Sprintf(MeterIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID, tpID, Direction)
// get from cache
rsrcMgr.meterInfoForOnuLock.RLock()
@@ -834,19 +834,19 @@
// HandleMeterInfoRefCntUpdate increments or decrements the reference counter for a given meter.
// When reference count becomes 0, it clears the meter information from the kv store
func (rsrcMgr *OpenOltResourceMgr) HandleMeterInfoRefCntUpdate(ctx context.Context, Direction string,
- intfID uint32, onuID uint32, uniID uint32, tpID uint32, increment bool) error {
- meterInfo, err := rsrcMgr.GetMeterInfoForOnu(ctx, Direction, intfID, onuID, uniID, tpID)
+ onuID uint32, uniID uint32, tpID uint32, increment bool) error {
+ meterInfo, err := rsrcMgr.GetMeterInfoForOnu(ctx, Direction, onuID, uniID, tpID)
if err != nil {
return err
} else if meterInfo == nil {
// If we are increasing the reference count, we expect the meter information to be present on KV store.
// But if decrementing the reference count, the meter is possibly already cleared from KV store. Just log warn but do not return error.
if increment {
- logger.Errorf(ctx, "error-fetching-meter-info-for-intf-%d-onu-%d-uni-%d-tp-id-%d-direction-%s", intfID, onuID, uniID, tpID, Direction)
- return fmt.Errorf("error-fetching-meter-info-for-intf-%d-onu-%d-uni-%d-tp-id-%d-direction-%s", intfID, onuID, uniID, tpID, Direction)
+ logger.Errorf(ctx, "error-fetching-meter-info-for-intf-%d-onu-%d-uni-%d-tp-id-%d-direction-%s", rsrcMgr.PonIntfID, onuID, uniID, tpID, Direction)
+ return fmt.Errorf("error-fetching-meter-info-for-intf-%d-onu-%d-uni-%d-tp-id-%d-direction-%s", rsrcMgr.PonIntfID, onuID, uniID, tpID, Direction)
}
logger.Warnw(ctx, "meter is already cleared",
- log.Fields{"intfID": intfID, "onuID": onuID, "uniID": uniID, "direction": Direction, "increment": increment})
+ log.Fields{"intfID": rsrcMgr.PonIntfID, "onuID": onuID, "uniID": uniID, "direction": Direction, "increment": increment})
return nil
}
@@ -855,7 +855,7 @@
} else {
meterInfo.RefCnt--
}
- if err := rsrcMgr.StoreMeterInfoForOnu(ctx, Direction, intfID, onuID, uniID, tpID, meterInfo); err != nil {
+ if err := rsrcMgr.StoreMeterInfoForOnu(ctx, Direction, onuID, uniID, tpID, meterInfo); err != nil {
return err
}
return nil
@@ -863,9 +863,9 @@
// RemoveMeterInfoForOnu deletes the meter id from the kV-Store for the given onu based on the path
// This path is formed as the following: <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction>
-func (rsrcMgr *OpenOltResourceMgr) RemoveMeterInfoForOnu(ctx context.Context, Direction string, intfID uint32, onuID uint32,
+func (rsrcMgr *OpenOltResourceMgr) RemoveMeterInfoForOnu(ctx context.Context, Direction string, onuID uint32,
uniID uint32, tpID uint32) error {
- Path := fmt.Sprintf(MeterIDPathSuffix, intfID, onuID, uniID, tpID, Direction)
+ Path := fmt.Sprintf(MeterIDPathSuffix, rsrcMgr.PonIntfID, onuID, uniID, tpID, Direction)
if err := rsrcMgr.KVStore.Delete(ctx, Path); err != nil {
logger.Errorf(ctx, "Failed to delete meter id %s from kvstore ", Path)
@@ -880,10 +880,10 @@
}
//AddGemToOnuGemInfo adds gemport to onugem info kvstore and also local cache
-func (rsrcMgr *OpenOltResourceMgr) AddGemToOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32, gemPort uint32) error {
- onugem, err := rsrcMgr.GetOnuGemInfo(ctx, intfID, onuID)
+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 == "" {
- logger.Errorf(ctx, "failed to get onuifo for intfid %d", intfID)
+ logger.Errorf(ctx, "failed to get onuifo for intfid %d", rsrcMgr.PonIntfID)
return err
}
if onugem.OnuID == onuID {
@@ -896,11 +896,11 @@
logger.Debugw(ctx, "Added gem to onugem info", log.Fields{"gem": gemPort})
onugem.GemPorts = append(onugem.GemPorts, gemPort)
} else {
- logger.Errorw(ctx, "onu id in OnuGemInfo does not match", log.Fields{"onuID": onuID, "ponIf": intfID, "onuGemInfoOnuID": onugem.OnuID})
+ logger.Errorw(ctx, "onu id in OnuGemInfo does not match", log.Fields{"onuID": onuID, "ponIf": rsrcMgr.PonIntfID, "onuGemInfoOnuID": onugem.OnuID})
return fmt.Errorf("onu-id-in-OnuGemInfo-does-not-match-%v", onuID)
}
- err = rsrcMgr.AddOnuGemInfo(ctx, intfID, onuID, *onugem)
+ err = rsrcMgr.AddOnuGemInfo(ctx, onuID, *onugem)
if err != nil {
logger.Error(ctx, "Failed to add onugem to kv store")
return err
@@ -909,10 +909,10 @@
}
//RemoveGemFromOnuGemInfo removes gemport from onugem info on kvstore and also local cache
-func (rsrcMgr *OpenOltResourceMgr) RemoveGemFromOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32, gemPort uint32) error {
- onugem, err := rsrcMgr.GetOnuGemInfo(ctx, intfID, onuID)
+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 == "" {
- logger.Errorf(ctx, "failed to get onuifo for intfid %d", intfID)
+ logger.Errorf(ctx, "failed to get onuifo for intfid %d", rsrcMgr.PonIntfID)
return err
}
updated := false
@@ -926,11 +926,11 @@
}
}
} else {
- logger.Errorw(ctx, "onu id in OnuGemInfo does not match", log.Fields{"onuID": onuID, "ponIf": intfID, "onuGemInfoOnuID": onugem.OnuID})
+ logger.Errorw(ctx, "onu id in OnuGemInfo does not match", log.Fields{"onuID": onuID, "ponIf": rsrcMgr.PonIntfID, "onuGemInfoOnuID": onugem.OnuID})
return fmt.Errorf("onu-id-in-OnuGemInfo-does-not-match-%v", onuID)
}
if updated {
- err = rsrcMgr.AddOnuGemInfo(ctx, intfID, onuID, *onugem)
+ err = rsrcMgr.AddOnuGemInfo(ctx, onuID, *onugem)
if err != nil {
logger.Error(ctx, "Failed to add onugem to kv store")
return err
@@ -942,12 +942,12 @@
}
//GetOnuGemInfo gets onu gem info from the kvstore per interface
-func (rsrcMgr *OpenOltResourceMgr) GetOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32) (*OnuGemInfo, error) {
+func (rsrcMgr *OpenOltResourceMgr) GetOnuGemInfo(ctx context.Context, onuID uint32) (*OnuGemInfo, error) {
var err error
var Val []byte
var onugem OnuGemInfo
- path := fmt.Sprintf(OnuGemInfoPath, intfID, onuID)
+ path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
rsrcMgr.onuGemInfoLock.RLock()
val, ok := rsrcMgr.onuGemInfo[path]
@@ -981,9 +981,9 @@
}
//AddNewOnuGemInfoToCacheAndKvStore function adds a new onu gem info to cache and kvstore
-func (rsrcMgr *OpenOltResourceMgr) AddNewOnuGemInfoToCacheAndKvStore(ctx context.Context, intfID uint32, onuID uint32, serialNum string) error {
+func (rsrcMgr *OpenOltResourceMgr) AddNewOnuGemInfoToCacheAndKvStore(ctx context.Context, onuID uint32, serialNum string) error {
- Path := fmt.Sprintf(OnuGemInfoPath, intfID, onuID)
+ Path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
rsrcMgr.onuGemInfoLock.Lock()
_, ok := rsrcMgr.onuGemInfo[Path]
@@ -995,14 +995,14 @@
return nil
}
- onuGemInfo := OnuGemInfo{OnuID: onuID, SerialNumber: serialNum, IntfID: intfID}
+ onuGemInfo := OnuGemInfo{OnuID: onuID, SerialNumber: serialNum, IntfID: rsrcMgr.PonIntfID}
- if err := rsrcMgr.AddOnuGemInfo(ctx, intfID, onuID, onuGemInfo); err != nil {
+ if err := rsrcMgr.AddOnuGemInfo(ctx, onuID, onuGemInfo); err != nil {
return err
}
logger.Infow(ctx, "added-onuinfo",
log.Fields{
- "intf-id": intfID,
+ "intf-id": rsrcMgr.PonIntfID,
"onu-id": onuID,
"serial-num": serialNum,
"onu": onuGemInfo,
@@ -1011,11 +1011,11 @@
}
// AddOnuGemInfo adds onu info on to the kvstore per interface
-func (rsrcMgr *OpenOltResourceMgr) AddOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32, onuGem OnuGemInfo) error {
+func (rsrcMgr *OpenOltResourceMgr) AddOnuGemInfo(ctx context.Context, onuID uint32, onuGem OnuGemInfo) error {
var Value []byte
var err error
- Path := fmt.Sprintf(OnuGemInfoPath, intfID, onuID)
+ Path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
Value, err = json.Marshal(onuGem)
if err != nil {
@@ -1037,8 +1037,8 @@
}
// DelOnuGemInfo deletes the onugem info from kvstore per ONU
-func (rsrcMgr *OpenOltResourceMgr) DelOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32) error {
- path := fmt.Sprintf(OnuGemInfoPath, intfID, onuID)
+func (rsrcMgr *OpenOltResourceMgr) DelOnuGemInfo(ctx context.Context, onuID uint32) error {
+ path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
if err := rsrcMgr.KVStore.Delete(ctx, path); err != nil {
logger.Errorf(ctx, "failed to remove resource %s", path)
@@ -1054,11 +1054,11 @@
}
//DeleteAllOnuGemInfoForIntf deletes all the all onu gem info on the given pon interface
-func (rsrcMgr *OpenOltResourceMgr) DeleteAllOnuGemInfoForIntf(ctx context.Context, intfID uint32) error {
+func (rsrcMgr *OpenOltResourceMgr) DeleteAllOnuGemInfoForIntf(ctx context.Context) error {
- path := fmt.Sprintf(OnuGemInfoPathPathPrefix, intfID)
+ path := fmt.Sprintf(OnuGemInfoPathPathPrefix, rsrcMgr.PonIntfID)
- logger.Debugw(ctx, "delete-all-onu-gem-info-for-pon-intf", log.Fields{"intfID": intfID})
+ logger.Debugw(ctx, "delete-all-onu-gem-info-for-pon-intf", log.Fields{"intfID": rsrcMgr.PonIntfID})
if err := rsrcMgr.KVStore.DeleteWithPrefix(ctx, path); err != nil {
logger.Errorf(ctx, "failed-to-remove-resource-%s", path)
return err
@@ -1072,11 +1072,11 @@
}
// AddUniPortToOnuInfo adds uni port to the onuinfo kvstore. check if the uni is already present if not update the kv store.
-func (rsrcMgr *OpenOltResourceMgr) AddUniPortToOnuInfo(ctx context.Context, intfID uint32, onuID uint32, portNo uint32) {
+func (rsrcMgr *OpenOltResourceMgr) AddUniPortToOnuInfo(ctx context.Context, onuID uint32, portNo uint32) {
- onugem, err := rsrcMgr.GetOnuGemInfo(ctx, intfID, onuID)
+ onugem, err := rsrcMgr.GetOnuGemInfo(ctx, onuID)
if err != nil || onugem == nil || onugem.SerialNumber == "" {
- logger.Warnf(ctx, "failed to get onuifo for intfid %d", intfID)
+ logger.Warnf(ctx, "failed to get onuifo for intfid %d", rsrcMgr.PonIntfID)
return
}
@@ -1089,10 +1089,10 @@
}
onugem.UniPorts = append(onugem.UniPorts, portNo)
} else {
- logger.Warnw(ctx, "onu id mismatch in onu gem info", log.Fields{"intfID": intfID, "onuID": onuID})
+ logger.Warnw(ctx, "onu id mismatch in onu gem info", log.Fields{"intfID": rsrcMgr.PonIntfID, "onuID": onuID})
return
}
- err = rsrcMgr.AddOnuGemInfo(ctx, intfID, onuID, *onugem)
+ err = rsrcMgr.AddOnuGemInfo(ctx, onuID, *onugem)
if err != nil {
logger.Errorw(ctx, "Failed to add uni port in onugem to kv store", log.Fields{"uni": portNo})
return
@@ -1164,8 +1164,8 @@
}
//DeletePacketInGemPortForOnu deletes the packet-in gemport for ONU
-func (rsrcMgr *OpenOltResourceMgr) DeletePacketInGemPortForOnu(ctx context.Context, intfID uint32, onuID uint32, logicalPort uint32) error {
- path := fmt.Sprintf(OnuPacketInPathPrefix, intfID, onuID, logicalPort)
+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)
if err != nil {
logger.Errorf(ctx, "failed-to-read-value-from-path-%s", path)
@@ -1197,8 +1197,8 @@
}
//GetFlowIDsForGem gets the list of FlowIDs for the given gemport
-func (rsrcMgr *OpenOltResourceMgr) GetFlowIDsForGem(ctx context.Context, intf uint32, gem uint32) ([]uint64, error) {
- path := fmt.Sprintf(FlowIDsForGem, intf, gem)
+func (rsrcMgr *OpenOltResourceMgr) GetFlowIDsForGem(ctx context.Context, gem uint32) ([]uint64, error) {
+ path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
// get from cache
rsrcMgr.flowIDsForGemLock.RLock()
@@ -1249,7 +1249,7 @@
}
// RegisterFlowIDForGem updates both cache and KV store for flowIDsForGem map
-func (rsrcMgr *OpenOltResourceMgr) RegisterFlowIDForGem(ctx context.Context, accessIntfID uint32, gemPortID uint32, flowFromCore *ofp.OfpFlowStats) error {
+func (rsrcMgr *OpenOltResourceMgr) RegisterFlowIDForGem(ctx context.Context, gemPortID uint32, flowFromCore *ofp.OfpFlowStats) error {
// get from cache
rsrcMgr.flowIDsForGemLock.RLock()
flowIDs, ok := rsrcMgr.flowIDsForGem[gemPortID]
@@ -1260,13 +1260,13 @@
flowIDs = appendUnique64bit(flowIDs, flowFromCore.Id)
}
// update the flowids for a gem to the KVstore
- return rsrcMgr.UpdateFlowIDsForGem(ctx, accessIntfID, gemPortID, flowIDs)
+ return rsrcMgr.UpdateFlowIDsForGem(ctx, gemPortID, flowIDs)
}
//UpdateFlowIDsForGem updates flow id per gemport
-func (rsrcMgr *OpenOltResourceMgr) UpdateFlowIDsForGem(ctx context.Context, intf uint32, gem uint32, flowIDs []uint64) error {
+func (rsrcMgr *OpenOltResourceMgr) UpdateFlowIDsForGem(ctx context.Context, gem uint32, flowIDs []uint64) error {
var val []byte
- path := fmt.Sprintf(FlowIDsForGem, intf, gem)
+ path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
if flowIDs == nil {
if err := rsrcMgr.KVStore.Delete(ctx, path); err != nil {
@@ -1294,8 +1294,8 @@
}
//DeleteFlowIDsForGem deletes the flowID list entry per gem from kvstore.
-func (rsrcMgr *OpenOltResourceMgr) DeleteFlowIDsForGem(ctx context.Context, intf uint32, gem uint32) error {
- path := fmt.Sprintf(FlowIDsForGem, intf, gem)
+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 {
logger.Errorw(ctx, "Failed to delete from kvstore", log.Fields{"err": err, "path": path})
return err
@@ -1308,14 +1308,10 @@
}
//DeleteAllFlowIDsForGemForIntf deletes all the flow ids associated for all the gems on the given pon interface
-func (rsrcMgr *OpenOltResourceMgr) DeleteAllFlowIDsForGemForIntf(ctx context.Context, intfID uint32) error {
+func (rsrcMgr *OpenOltResourceMgr) DeleteAllFlowIDsForGemForIntf(ctx context.Context) error {
+ path := fmt.Sprintf(FlowIDsForGemPathPrefix, rsrcMgr.PonIntfID)
- if intfID == rsrcMgr.DevInfo.PonPorts {
- intfID = NNI
- }
- path := fmt.Sprintf(FlowIDsForGemPathPrefix, intfID)
-
- logger.Debugw(ctx, "delete-flow-ids-for-gem-for-pon-intf", log.Fields{"intfID": intfID})
+ logger.Debugw(ctx, "delete-flow-ids-for-gem-for-pon-intf", log.Fields{"intfID": rsrcMgr.PonIntfID})
if err := rsrcMgr.KVStore.DeleteWithPrefix(ctx, path); err != nil {
logger.Errorf(ctx, "failed-to-remove-resource-%s", path)
return err
@@ -1362,7 +1358,7 @@
}
//AddMcastQueueForIntf adds multicast queue for pon interface
-func (rsrcMgr *OpenOltResourceMgr) AddMcastQueueForIntf(ctx context.Context, intf uint32, gem uint32, servicePriority uint32) error {
+func (rsrcMgr *OpenOltResourceMgr) AddMcastQueueForIntf(ctx context.Context, gem uint32, servicePriority uint32) error {
var val []byte
path := McastQueuesForIntf
@@ -1372,7 +1368,7 @@
rsrcMgr.mcastQueueForIntfLock.RUnlock()
_, err := rsrcMgr.GetMcastQueuePerInterfaceMap(ctx)
if err != nil {
- logger.Errorw(ctx, "Failed to get multicast queue info for interface", log.Fields{"err": err, "intf": intf})
+ logger.Errorw(ctx, "Failed to get multicast queue info for interface", log.Fields{"err": err, "intf": rsrcMgr.PonIntfID})
return err
}
} else {
@@ -1381,7 +1377,7 @@
// Update KV store
rsrcMgr.mcastQueueForIntfLock.Lock()
- rsrcMgr.mcastQueueForIntf[intf] = []uint32{gem, servicePriority}
+ rsrcMgr.mcastQueueForIntf[rsrcMgr.PonIntfID] = []uint32{gem, servicePriority}
val, err := json.Marshal(rsrcMgr.mcastQueueForIntf)
if err != nil {
rsrcMgr.mcastQueueForIntfLock.Unlock()
@@ -1394,7 +1390,7 @@
logger.Errorw(ctx, "Failed to put to kvstore", log.Fields{"err": err, "path": path, "value": val})
return err
}
- logger.Debugw(ctx, "added multicast queue info to KV store successfully", log.Fields{"path": path, "interfaceId": intf, "gem": gem, "svcPrior": servicePriority})
+ logger.Debugw(ctx, "added multicast queue info to KV store successfully", log.Fields{"path": path, "interfaceId": rsrcMgr.PonIntfID, "gem": gem, "svcPrior": servicePriority})
return nil
}
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index e3fa49c..77832b4 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -351,7 +351,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- RsrcMgr.FreePONResourcesForONU(ctx, tt.args.intfID, tt.args.onuID, tt.args.uniID)
+ RsrcMgr.FreePONResourcesForONU(ctx, tt.args.onuID, tt.args.uniID)
})
}
}
@@ -373,7 +373,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- RsrcMgr.FreeonuID(ctx, tt.args.intfID, tt.args.onuID)
+ RsrcMgr.FreeonuID(ctx, tt.args.onuID)
})
}
}
@@ -397,7 +397,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- got := RsrcMgr.GetCurrentAllocIDsForOnu(ctx, tt.args.intfID, tt.args.onuID, tt.args.uniID)
+ got := RsrcMgr.GetCurrentAllocIDsForOnu(ctx, tt.args.onuID, tt.args.uniID)
if len(got) != len(tt.want) {
t.Errorf("GetCurrentAllocIDsForOnu() = %v, want %v", got, tt.want)
} else {
@@ -430,7 +430,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- err := RsrcMgr.DeleteAllFlowIDsForGemForIntf(ctx, tt.args.PONIntfID)
+ err := RsrcMgr.DeleteAllFlowIDsForGemForIntf(ctx)
if err != nil {
t.Errorf("DeleteAllFlowIDsForGemForIntf() returned error")
}
@@ -456,7 +456,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- err := RsrcMgr.DeleteAllOnuGemInfoForIntf(ctx, tt.args.PONIntfID)
+ err := RsrcMgr.DeleteAllOnuGemInfoForIntf(ctx)
if err != nil {
t.Errorf("DeleteAllOnuGemInfoForIntf() returned error")
}
@@ -496,24 +496,24 @@
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RsrcMgr := testResMgrObject(tt.fields)
- if err := RsrcMgr.DelOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID); err != nil {
+ if err := RsrcMgr.DelOnuGemInfo(ctx, tt.args.onuID); err != nil {
t.Errorf("failed to remove onu")
}
- if err := RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, tt.args.intfID, tt.args.onuID, tt.args.serialNum); err != nil {
+ if err := RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, tt.args.onuID, tt.args.serialNum); err != nil {
t.Errorf("failed to add onu")
}
for _, gemPort := range tt.args.gemPortIDs {
- if err := RsrcMgr.AddGemToOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID, gemPort); err != nil {
+ if err := RsrcMgr.AddGemToOnuGemInfo(ctx, tt.args.onuID, gemPort); err != nil {
t.Errorf("failed to add gem to onu")
}
}
for _, gemPortDeleted := range tt.args.gemPortIDsToBeDeleted {
- if err := RsrcMgr.RemoveGemFromOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID, gemPortDeleted); err != nil {
+ if err := RsrcMgr.RemoveGemFromOnuGemInfo(ctx, tt.args.onuID, gemPortDeleted); err != nil {
t.Errorf("failed to remove gem from onu")
}
}
lenofGemPorts := 0
- gP, err := RsrcMgr.GetOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID)
+ gP, err := RsrcMgr.GetOnuGemInfo(ctx, tt.args.onuID)
if err != nil || gP == nil {
t.Errorf("failed to get onuGemInfo")
}
@@ -555,7 +555,7 @@
for j := 1; j <= int(tt.args.OnuCount); j++ {
go func(i uint32, j uint32) {
// TODO: actually verify success
- _ = RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, i, i, fmt.Sprintf("onu-%d", i))
+ _ = RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, i, fmt.Sprintf("onu-%d", i))
}(tt.args.PONIntfID, uint32(j))
}
})
@@ -589,20 +589,20 @@
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RsrcMgr := testResMgrObject(tt.fields)
- if err := RsrcMgr.DelOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID); err != nil {
+ if err := RsrcMgr.DelOnuGemInfo(ctx, tt.args.onuID); err != nil {
t.Errorf("failed to remove onu")
}
- if err := RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, tt.args.intfID, tt.args.onuID, tt.args.serialNum); err != nil {
+ if err := RsrcMgr.AddNewOnuGemInfoToCacheAndKvStore(ctx, tt.args.onuID, tt.args.serialNum); err != nil {
t.Errorf("failed to add onu")
}
for _, gemPort := range tt.args.gemPortIDs {
- if err := RsrcMgr.AddGemToOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID, gemPort); err != nil {
+ if err := RsrcMgr.AddGemToOnuGemInfo(ctx, tt.args.onuID, gemPort); err != nil {
t.Errorf("failed to add gem to onu")
}
}
lenofGemPorts := 0
- gP, err := RsrcMgr.GetOnuGemInfo(ctx, tt.args.intfID, tt.args.onuID)
+ gP, err := RsrcMgr.GetOnuGemInfo(ctx, tt.args.onuID)
var gemPorts []uint32
if err == nil && gP != nil {
@@ -639,7 +639,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if got := RsrcMgr.GetCurrentGEMPortIDsForOnu(ctx, tt.args.intfID, tt.args.onuID, tt.args.uniID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+ if got := RsrcMgr.GetCurrentGEMPortIDsForOnu(ctx, tt.args.onuID, tt.args.uniID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("GetCurrentGEMPortIDsForOnu() = %v, want %v", got, tt.want)
}
})
@@ -671,7 +671,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- got, err := RsrcMgr.GetMeterInfoForOnu(ctx, tt.args.Direction, tt.args.IntfID, tt.args.OnuID, tt.args.UniID, tt.args.tpID)
+ got, err := RsrcMgr.GetMeterInfoForOnu(ctx, tt.args.Direction, tt.args.OnuID, tt.args.UniID, tt.args.tpID)
if reflect.TypeOf(got) != reflect.TypeOf(tt.want) && err != nil {
t.Errorf("GetMeterInfoForOnu() got = %v, want %v", got, tt.want)
}
@@ -697,7 +697,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- got, err := RsrcMgr.GetONUID(ctx, tt.args.ponIntfID)
+ got, err := RsrcMgr.GetONUID(ctx)
if got != tt.want && err != nil {
t.Errorf("GetONUID() got = %v, want %v", got, tt.want)
}
@@ -726,7 +726,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if got := RsrcMgr.GetTechProfileIDForOnu(ctx, tt.args.IntfID, tt.args.OnuID, tt.args.UniID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+ if got := RsrcMgr.GetTechProfileIDForOnu(ctx, tt.args.OnuID, tt.args.UniID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("GetTechProfileIDForOnu() = %v, want %v", got, tt.want)
}
})
@@ -756,7 +756,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.RemoveMeterInfoForOnu(ctx, tt.args.Direction, tt.args.IntfID, tt.args.OnuID, tt.args.UniID,
+ if err := RsrcMgr.RemoveMeterInfoForOnu(ctx, tt.args.Direction, tt.args.OnuID, tt.args.UniID,
tt.args.tpID); reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
t.Errorf("RemoveMeterIDForOnu() error = %v, wantErr %v", err, tt.wantErr)
}
@@ -785,7 +785,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.RemoveTechProfileIDForOnu(ctx, tt.args.IntfID, tt.args.OnuID, tt.args.UniID,
+ if err := RsrcMgr.RemoveTechProfileIDForOnu(ctx, tt.args.OnuID, tt.args.UniID,
tt.args.tpID); reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
t.Errorf("RemoveTechProfileIDForOnu() error = %v, wantErr %v", err, tt.wantErr)
}
@@ -814,7 +814,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.UpdateAllocIdsForOnu(ctx, tt.args.ponPort, tt.args.onuID, tt.args.uniID, tt.args.allocID); err != nil && reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) {
+ if err := RsrcMgr.UpdateAllocIdsForOnu(ctx, tt.args.onuID, tt.args.uniID, tt.args.allocID); err != nil && reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) {
t.Errorf("UpdateAllocIdsForOnu() error = %v, wantErr %v", err, tt.wantErr)
}
})
@@ -843,7 +843,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.UpdateGEMPortIDsForOnu(ctx, tt.args.ponPort, tt.args.onuID, tt.args.uniID, tt.args.GEMPortList); err != nil && reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) {
+ if err := RsrcMgr.UpdateGEMPortIDsForOnu(ctx, tt.args.onuID, tt.args.uniID, tt.args.GEMPortList); err != nil && reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) {
t.Errorf("UpdateGEMPortIDsForOnu() error = %v, wantErr %v", err, tt.wantErr)
}
})
@@ -873,7 +873,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.StoreMeterInfoForOnu(ctx, tt.args.Direction, tt.args.IntfID, tt.args.OnuID, tt.args.UniID,
+ if err := RsrcMgr.StoreMeterInfoForOnu(ctx, tt.args.Direction, tt.args.OnuID, tt.args.UniID,
tt.args.tpID, tt.args.MeterInfo); reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
t.Errorf("UpdateMeterIDForOnu() got = %v, want %v", err, tt.wantErr)
}
@@ -902,7 +902,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if err := RsrcMgr.UpdateTechProfileIDForOnu(ctx, tt.args.IntfID, tt.args.OnuID, tt.args.UniID, tt.args.TpID); reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
+ if err := RsrcMgr.UpdateTechProfileIDForOnu(ctx, tt.args.OnuID, tt.args.UniID, tt.args.TpID); reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
t.Errorf("UpdateTechProfileIDForOnu() got = %v, want %v", err, tt.wantErr)
}
})
@@ -982,7 +982,7 @@
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- err := RsrcMgr.AddMcastQueueForIntf(ctx, tt.args.intf, tt.args.gem, tt.args.servicePriority)
+ err := RsrcMgr.AddMcastQueueForIntf(ctx, tt.args.gem, tt.args.servicePriority)
if err != nil {
t.Errorf("%s got err= %s wants nil", tt.name, err)
return