[VOL-4913]: Implementation for on demand audit of ONU alarms

Change-Id: I48eadccb76cd1b486ce783e3f0ea50d94750969e
diff --git a/internal/pkg/almgr/alarm_manager.go b/internal/pkg/almgr/alarm_manager.go
index ae872fa..40632c2 100755
--- a/internal/pkg/almgr/alarm_manager.go
+++ b/internal/pkg/almgr/alarm_manager.go
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//Package almgr provides the utilities for managing alarm notifications
+// Package almgr provides the utilities for managing alarm notifications
 package almgr
 
 import (
@@ -31,6 +31,7 @@
 	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+	"github.com/opencord/voltha-protos/v5/go/extension"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
 )
 
@@ -114,6 +115,9 @@
 	alarmUploadNoOfCmdsOrMEs   uint16
 	StopAlarmAuditTimer        chan struct{}
 	isExtendedOmci             bool
+	AsyncAlarmsCommChan        chan struct{}
+	isAsyncAlarmRequest        bool
+	onuAlarmRequestLock        sync.RWMutex
 }
 
 // NewAlarmManager - TODO: add comment
@@ -130,6 +134,8 @@
 	alarmManager.activeAlarms = make(map[alarmInfo]struct{})
 	alarmManager.alarmBitMapDB = make(map[meAlarmKey][alarmBitMapSizeBytes]byte)
 	alarmManager.StopAlarmAuditTimer = make(chan struct{})
+	alarmManager.AsyncAlarmsCommChan = make(chan struct{})
+	alarmManager.isAsyncAlarmRequest = false
 	alarmManager.onuEventsList = map[onuDevice]onuDeviceEvent{
 		{classID: circuitPackClassID, alarmno: 0}: {EventName: "ONU_EQUIPMENT",
 			EventCategory: voltha.EventCategory_EQUIPMENT, EventSubCategory: voltha.EventSubCategory_ONU, EventDescription: "onu equipment"},
@@ -186,6 +192,7 @@
 			"enter_" + asStAuditing:        func(e *fsm.Event) { alarmManager.asFsmAuditing(ctx, e) },
 			"enter_" + asStInSync:          func(e *fsm.Event) { alarmManager.asFsmInSync(ctx, e) },
 			"enter_" + asStResynchronizing: func(e *fsm.Event) { alarmManager.asFsmResynchronizing(ctx, e) },
+			"leave_" + asStAuditing:        func(e *fsm.Event) { alarmManager.asFsmLeaveAuditing(ctx, e) },
 		},
 	)
 	return &alarmManager
@@ -237,7 +244,15 @@
 		go failureTransition()
 	}
 }
+func (am *OnuAlarmManager) asFsmLeaveAuditing(ctx context.Context, e *fsm.Event) {
+	logger.Debugw(ctx, "alarm-sync-fsm-leave-auditing state", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
+	if am.isAsyncAlarmRequest {
+		logger.Errorw(ctx, "alarm-sync-fsm-leave-auditing state process the updated ONU alarms ", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
+		am.AsyncAlarmsCommChan <- struct{}{}
+		am.isAsyncAlarmRequest = false
 
+	}
+}
 func (am *OnuAlarmManager) asFsmResynchronizing(ctx context.Context, e *fsm.Event) {
 	logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
 	failureTransition := func() {
@@ -339,6 +354,17 @@
 		case <-am.StopAlarmAuditTimer:
 			logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.deviceID})
 			return
+
+		case <-am.AsyncAlarmsCommChan:
+			go func() {
+				logger.Debugw(ctx, "On demand Auditing the ONU for Alarms  ", log.Fields{"device-id": am.deviceID})
+				if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+					logger.Errorw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing, use current snapshot of alarms", log.Fields{"device-id": am.deviceID, "err": err})
+					am.isAsyncAlarmRequest = false
+					am.AsyncAlarmsCommChan <- struct{}{}
+				}
+			}()
+
 		}
 	}
 }
@@ -450,6 +476,7 @@
 					logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
 				}
 			}()
+
 		}
 	} else {
 		logger.Errorw(ctx, "invalid-number-of-commands-received", log.Fields{"device-id": am.deviceID,
@@ -532,6 +559,7 @@
 				}
 			}()
 		}
+
 	}
 }
 
@@ -796,7 +824,7 @@
 	return onuDeviceEvent{}, errors.New("onu Event Detail not found")
 }
 
-//ResetAlarmUploadCounters resets alarm upload sequence number and number of commands
+// ResetAlarmUploadCounters resets alarm upload sequence number and number of commands
 func (am *OnuAlarmManager) ResetAlarmUploadCounters() {
 	am.onuAlarmManagerLock.Lock()
 	am.alarmUploadSeqNo = 0
@@ -804,14 +832,14 @@
 	am.onuAlarmManagerLock.Unlock()
 }
 
-//IncrementAlarmUploadSeqNo increments alarm upload sequence number
+// IncrementAlarmUploadSeqNo increments alarm upload sequence number
 func (am *OnuAlarmManager) IncrementAlarmUploadSeqNo() {
 	am.onuAlarmManagerLock.Lock()
 	am.alarmUploadSeqNo++
 	am.onuAlarmManagerLock.Unlock()
 }
 
-//GetAlarmUploadSeqNo gets alarm upload sequence number
+// GetAlarmUploadSeqNo gets alarm upload sequence number
 func (am *OnuAlarmManager) GetAlarmUploadSeqNo() uint16 {
 	am.onuAlarmManagerLock.RLock()
 	value := am.alarmUploadSeqNo
@@ -819,11 +847,57 @@
 	return value
 }
 
-//GetAlarmMgrEventChannel gets alarm manager event channel
+// GetAlarmMgrEventChannel gets alarm manager event channel
 func (am *OnuAlarmManager) GetAlarmMgrEventChannel() chan cmn.Message {
 	return am.eventChannel
 }
 
+// GetOnuActiveAlarms - Fetch the Active Alarms on demand
+func (am *OnuAlarmManager) GetOnuActiveAlarms(ctx context.Context) *extension.SingleGetValueResponse {
+
+	am.onuAlarmRequestLock.Lock()
+	defer am.onuAlarmRequestLock.Unlock()
+
+	resp := extension.SingleGetValueResponse{
+		Response: &extension.GetValueResponse{
+			Status: extension.GetValueResponse_OK,
+			Response: &extension.GetValueResponse_OnuActiveAlarms{
+				OnuActiveAlarms: &extension.GetOnuOmciActiveAlarmsResponse{},
+			},
+		},
+	}
+
+	logger.Debugw(ctx, "Requesting to start audit on demand  ", log.Fields{"device-id": am.deviceID})
+	am.isAsyncAlarmRequest = true
+
+	am.AsyncAlarmsCommChan <- struct{}{}
+
+	select {
+	case <-time.After(10 * time.Second): //the time to wait needs further discussion.
+		logger.Errorw(ctx, "Couldn't get the Alarms with in 10 seconds stipulated time frame ", log.Fields{"device-id": am.deviceID})
+		am.isAsyncAlarmRequest = false
+
+	case <-am.AsyncAlarmsCommChan:
+		logger.Debugw(ctx, "Received response for the alarm audit ", log.Fields{"device-id": am.deviceID})
+
+	}
+
+	for activeAlarm := range am.activeAlarms {
+
+		onuEventDetails := am.onuEventsList[onuDevice{classID: activeAlarm.classID, alarmno: activeAlarm.alarmNo}]
+		activeAlarmData := extension.AlarmData{}
+		activeAlarmData.ClassId = uint32(activeAlarm.classID)
+		activeAlarmData.InstanceId = uint32(activeAlarm.instanceID)
+		activeAlarmData.Name = onuEventDetails.EventName
+		activeAlarmData.Description = onuEventDetails.EventDescription
+
+		resp.Response.GetOnuActiveAlarms().ActiveAlarms = append(resp.Response.GetOnuActiveAlarms().ActiveAlarms, &activeAlarmData)
+
+	}
+
+	return &resp
+}
+
 // PrepareForGarbageCollection - remove references to prepare for garbage collection
 func (am *OnuAlarmManager) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
 	logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
diff --git a/internal/pkg/common/interfaces.go b/internal/pkg/common/interfaces.go
index c56f8f8..901704d 100755
--- a/internal/pkg/common/interfaces.go
+++ b/internal/pkg/common/interfaces.go
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//Package common provides global definitions
+// Package common provides global definitions
 package common
 
 import (
@@ -26,6 +26,7 @@
 	"github.com/opencord/voltha-lib-go/v7/pkg/db"
 	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
 	"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
+	"github.com/opencord/voltha-protos/v5/go/extension"
 	ia "github.com/opencord/voltha-protos/v5/go/inter_adapter"
 	"github.com/opencord/voltha-protos/v5/go/openolt"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
@@ -172,6 +173,7 @@
 	GetAlarmMgrEventChannel() chan Message
 	GetAlarmUploadSeqNo() uint16
 	IncrementAlarmUploadSeqNo()
+	GetOnuActiveAlarms(ctx context.Context) *extension.SingleGetValueResponse
 }
 
 // IonuUniTechProf interface to onuUniTechProf
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index e6bfea6..b9cadf0 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//Package core provides the utility for onu devices, flows and statistics
+// Package core provides the utility for onu devices, flows and statistics
 package core
 
 import (
@@ -95,7 +95,7 @@
 	devStUp        = "devStUp"
 )
 
-//Event category and subcategory definitions - same as defiend for OLT in eventmgr.go  - should be done more centrally
+// Event category and subcategory definitions - same as defiend for OLT in eventmgr.go  - should be done more centrally
 const (
 	pon = voltha.EventSubCategory_PON
 	//olt           = voltha.EventSubCategory_OLT
@@ -149,7 +149,7 @@
 	respChan     *chan error // channel to report the Flow handling error
 }
 
-//deviceHandler will interact with the ONU ? device.
+// deviceHandler will interact with the ONU ? device.
 type deviceHandler struct {
 	DeviceID         string
 	DeviceType       string
@@ -233,7 +233,7 @@
 	oltAvailable                   bool
 }
 
-//newDeviceHandler creates a new device handler
+// newDeviceHandler creates a new device handler
 func newDeviceHandler(ctx context.Context, cc *vgrpc.Client, ep eventif.EventProxy, device *voltha.Device, adapter *OpenONUAC) *deviceHandler {
 	var dh deviceHandler
 	dh.coreClient = cc
@@ -333,7 +333,7 @@
 // ##########################################################################################
 // deviceHandler methods that implement the adapters interface requests ##### begin #########
 
-//adoptOrReconcileDevice adopts the ONU device
+// adoptOrReconcileDevice adopts the ONU device
 func (dh *deviceHandler) adoptOrReconcileDevice(ctx context.Context, device *voltha.Device) {
 	logger.Debugw(ctx, "adopt_or_reconcile_device", log.Fields{"device-id": device.Id, "Address": device.GetHostAndPort()})
 
@@ -617,7 +617,7 @@
 	return nil
 }
 
-//FlowUpdateIncremental removes and/or adds the flow changes on a given device
+// FlowUpdateIncremental removes and/or adds the flow changes on a given device
 func (dh *deviceHandler) FlowUpdateIncremental(ctx context.Context,
 	apOfFlowChanges *of.FlowChanges,
 	apOfGroupChanges *of.FlowGroupChanges, apFlowMetaData *of.FlowMetadata) error {
@@ -789,9 +789,9 @@
 	return nil
 }
 
-//disableDevice locks the ONU and its UNI/VEIP ports (admin lock via OMCI)
-//following are the expected device states after this activity:
-//Device Admin-State : down (on rwCore), Port-State: UNKNOWN, Conn-State: REACHABLE, Reason: omci-admin-lock
+// disableDevice locks the ONU and its UNI/VEIP ports (admin lock via OMCI)
+// following are the expected device states after this activity:
+// Device Admin-State : down (on rwCore), Port-State: UNKNOWN, Conn-State: REACHABLE, Reason: omci-admin-lock
 // (Conn-State: REACHABLE might conflict with some previous ONU Down indication - maybe to be resolved later)
 func (dh *deviceHandler) disableDevice(ctx context.Context, device *voltha.Device) {
 	logger.Debugw(ctx, "disable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
@@ -835,7 +835,7 @@
 	}
 }
 
-//reEnableDevice unlocks the ONU and its UNI/VEIP ports (admin unlock via OMCI)
+// reEnableDevice unlocks the ONU and its UNI/VEIP ports (admin unlock via OMCI)
 func (dh *deviceHandler) reEnableDevice(ctx context.Context, device *voltha.Device) {
 	logger.Debugw(ctx, "reenable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
 
@@ -1148,8 +1148,9 @@
 	} //for all flows of this UNI
 }
 
-//waitOnUniVlanConfigReconcilingReady collects all VlanConfigReady signals from VlanConfig FSM processing in reconciling
-//  and decrements the according handler wait group waiting for these indications
+// waitOnUniVlanConfigReconcilingReady collects all VlanConfigReady signals from VlanConfig FSM processing in reconciling
+//
+//	and decrements the according handler wait group waiting for these indications
 func (dh *deviceHandler) waitOnUniVlanConfigReconcilingReady(ctx context.Context, aSyncChannel chan<- struct{},
 	waitGroup *cmn.WaitGroupWithTimeOut) {
 	var reconciledUniVlanConfigEntries []uint8
@@ -1259,10 +1260,12 @@
 	return pDevEntry.GetKvProcessingErrorIndication()
 }
 
-//func (dh *deviceHandler) rebootDevice(ctx context.Context, device *voltha.Device) error {
+// func (dh *deviceHandler) rebootDevice(ctx context.Context, device *voltha.Device) error {
 // before this change here return like this was used:
-// 		return fmt.Errorf("device-unreachable: %s, %s", dh.DeviceID, device.SerialNumber)
-//was and is called in background - error return does not make sense
+//
+//	return fmt.Errorf("device-unreachable: %s, %s", dh.DeviceID, device.SerialNumber)
+//
+// was and is called in background - error return does not make sense
 func (dh *deviceHandler) rebootDevice(ctx context.Context, aCheckDeviceState bool, device *voltha.Device) {
 	logger.Infow(ctx, "reboot-device", log.Fields{"device-id": dh.DeviceID, "SerialNumber": dh.device.SerialNumber})
 	if aCheckDeviceState && device.ConnectStatus != voltha.ConnectStatus_REACHABLE {
@@ -1300,8 +1303,9 @@
 	//  all other FSM's should be synchronized again
 }
 
-//doOnuSwUpgrade initiates the SW download transfer to the ONU and on success activates the (inactive) image
-//  used only for old - R2.7 style - upgrade API
+// doOnuSwUpgrade initiates the SW download transfer to the ONU and on success activates the (inactive) image
+//
+//	used only for old - R2.7 style - upgrade API
 func (dh *deviceHandler) doOnuSwUpgrade(ctx context.Context, apImageDsc *voltha.ImageDownload,
 	apDownloadManager *swupg.AdapterDownloadManager) error {
 	logger.Debugw(ctx, "onuSwUpgrade requested", log.Fields{
@@ -1353,7 +1357,7 @@
 	return err
 }
 
-//onuSwUpgradeAfterDownload initiates the SW download transfer to the ONU with activate and commit options
+// onuSwUpgradeAfterDownload initiates the SW download transfer to the ONU with activate and commit options
 // after the OnuImage has been downloaded to the adapter, called in background
 func (dh *deviceHandler) onuSwUpgradeAfterDownload(ctx context.Context, apImageRequest *voltha.DeviceImageDownloadRequest,
 	apDownloadManager *swupg.FileDownloadManager, aImageIdentifier string) {
@@ -1423,7 +1427,7 @@
 		"device-id": dh.DeviceID, "error": err})
 }
 
-//onuSwActivateRequest ensures activation of the requested image with commit options
+// onuSwActivateRequest ensures activation of the requested image with commit options
 func (dh *deviceHandler) onuSwActivateRequest(ctx context.Context,
 	aVersion string, aCommitRequest bool) (*voltha.ImageState, error) {
 	var err error
@@ -1492,7 +1496,7 @@
 	return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.DeviceID)
 }
 
-//onuSwCommitRequest ensures commitment of the requested image
+// onuSwCommitRequest ensures commitment of the requested image
 func (dh *deviceHandler) onuSwCommitRequest(ctx context.Context,
 	aVersion string) (*voltha.ImageState, error) {
 	var err error
@@ -1794,8 +1798,9 @@
 
 // doStateConnected get the device info and update to voltha core
 // for comparison of the original method (not that easy to uncomment): compare here:
-//  voltha-openolt-adapter/adaptercore/device_handler.go
-//  -> this one obviously initiates all communication interfaces of the device ...?
+//
+//	voltha-openolt-adapter/adaptercore/device_handler.go
+//	-> this one obviously initiates all communication interfaces of the device ...?
 func (dh *deviceHandler) doStateConnected(ctx context.Context, e *fsm.Event) {
 
 	logger.Debugw(ctx, "doStateConnected-started", log.Fields{"device-id": dh.DeviceID})
@@ -1892,7 +1897,7 @@
 // ###################################################
 // deviceHandler utility methods ##### begin #########
 
-//GetOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
+// GetOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
 func (dh *deviceHandler) GetOnuDeviceEntry(ctx context.Context, aWait bool) *mib.OnuDeviceEntry {
 	dh.lockDevice.RLock()
 	pOnuDeviceEntry := dh.pOnuOmciDevice
@@ -1916,7 +1921,7 @@
 	return pOnuDeviceEntry
 }
 
-//setDeviceHandlerEntries sets the ONU device entry within the handler
+// setDeviceHandlerEntries sets the ONU device entry within the handler
 func (dh *deviceHandler) setDeviceHandlerEntries(apDeviceEntry *mib.OnuDeviceEntry, apOnuTp *avcfg.OnuUniTechProf,
 	apOnuMetricsMgr *pmmgr.OnuMetricsManager, apOnuAlarmMgr *almgr.OnuAlarmManager, apSelfTestHdlr *otst.SelfTestControlBlock) {
 	dh.lockDevice.Lock()
@@ -1928,7 +1933,7 @@
 	dh.pSelfTestHdlr = apSelfTestHdlr
 }
 
-//addOnuDeviceEntry creates a new ONU device or returns the existing
+// addOnuDeviceEntry creates a new ONU device or returns the existing
 func (dh *deviceHandler) addOnuDeviceEntry(ctx context.Context) error {
 	logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.DeviceID})
 
@@ -2639,7 +2644,7 @@
 	}
 }
 
-//DeviceProcStatusUpdate evaluates possible processing events and initiates according next activities
+// DeviceProcStatusUpdate evaluates possible processing events and initiates according next activities
 func (dh *deviceHandler) DeviceProcStatusUpdate(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
 	switch devEvent {
 	case cmn.MibDatabaseSync:
@@ -3122,7 +3127,7 @@
 	dh.lockUpgradeFsm.RUnlock()
 }
 
-//SetBackend provides a DB backend for the specified path on the existing KV client
+// SetBackend provides a DB backend for the specified path on the existing KV client
 func (dh *deviceHandler) SetBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
 
 	logger.Debugw(ctx, "SetKVStoreBackend", log.Fields{"IpTarget": dh.pOpenOnuAc.KVStoreAddress,
@@ -3260,7 +3265,7 @@
 	} //for all Actions
 }
 
-//addFlowItemToUniPort parses the actual flow item to add it to the UniPort
+// addFlowItemToUniPort parses the actual flow item to add it to the UniPort
 func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort,
 	apFlowMetaData *of.FlowMetadata, respChan *chan error) {
 	var loSetVlan uint16 = uint16(of.OfpVlanId_OFPVID_NONE)      //noValidEntry
@@ -3361,7 +3366,7 @@
 	}
 }
 
-//removeFlowItemFromUniPort parses the actual flow item to remove it from the UniPort
+// removeFlowItemFromUniPort parses the actual flow item to remove it from the UniPort
 func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort, respChan *chan error) {
 	//optimization and assumption: the flow cookie uniquely identifies the flow and with that the internal rule
 	//hence only the cookie is used here to find the relevant flow and possibly remove the rule
@@ -3464,7 +3469,7 @@
 	return nil
 }
 
-//VerifyVlanConfigRequest checks on existence of a given uniPort
+// VerifyVlanConfigRequest checks on existence of a given uniPort
 // and starts verification of flow config based on that
 func (dh *deviceHandler) VerifyVlanConfigRequest(ctx context.Context, aUniID uint8, aTpID uint8) {
 	//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
@@ -3484,7 +3489,7 @@
 	dh.VerifyUniVlanConfigRequest(ctx, pCurrentUniPort, aTpID)
 }
 
-//VerifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
+// VerifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
 func (dh *deviceHandler) VerifyUniVlanConfigRequest(ctx context.Context, apUniPort *cmn.OnuUniPort, aTpID uint8) {
 	//TODO!! verify and start pending flow configuration
 	//some pending config request my exist in case the UniVlanConfig FSM was already started - with internal data -
@@ -3537,7 +3542,7 @@
 	}
 }
 
-//RemoveVlanFilterFsm deletes the stored pointer to the VlanConfigFsm
+// RemoveVlanFilterFsm deletes the stored pointer to the VlanConfigFsm
 // intention is to provide this method to be called from VlanConfigFsm itself, when resources (and methods!) are cleaned up
 func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *cmn.OnuUniPort) {
 	logger.Debugw(ctx, "remove UniVlanConfigFsm StateMachine", log.Fields{
@@ -3548,7 +3553,7 @@
 	dh.lockVlanConfig.Unlock()
 }
 
-//startWritingOnuDataToKvStore initiates the KVStore write of ONU persistent data
+// startWritingOnuDataToKvStore initiates the KVStore write of ONU persistent data
 func (dh *deviceHandler) startWritingOnuDataToKvStore(ctx context.Context, aPDevEntry *mib.OnuDeviceEntry) error {
 	dh.mutexKvStoreContext.Lock()         //this write routine may (could) be called with the same context,
 	defer dh.mutexKvStoreContext.Unlock() //this write routine may (could) be called with the same context,
@@ -3568,8 +3573,8 @@
 	return aPDevEntry.GetKvProcessingErrorIndication()
 }
 
-//StorePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
-//available for potential reconcilement
+// StorePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
+// available for potential reconcilement
 func (dh *deviceHandler) StorePersUniFlowConfig(ctx context.Context, aUniID uint8,
 	aUniVlanFlowParams *[]cmn.UniVlanFlowParams, aWriteToKvStore bool) error {
 
@@ -3599,8 +3604,9 @@
 		"device-id": dh.DeviceID, "called from": aCallerIdent})
 }
 
-//ReasonUpdate set the internally store device reason and if requested in notifyCore updates this state in the core
-//  (renamed from previous deviceReasonUpdate to avoid confusing with the core function DeviceReasonUpdate)
+// ReasonUpdate set the internally store device reason and if requested in notifyCore updates this state in the core
+//
+//	(renamed from previous deviceReasonUpdate to avoid confusing with the core function DeviceReasonUpdate)
 func (dh *deviceHandler) ReasonUpdate(ctx context.Context, deviceReason uint8, notifyCore bool) error {
 	// acquire the deviceReason semaphore throughout this function including the possible update processing in core
 	// in order to avoid reversion of the state sequence within core in case of quasi-parallel calls (eg. in multi UNI processing)
@@ -4654,6 +4660,12 @@
 	return tpPathFound
 }
 
+func (dh *deviceHandler) getOnuActiveAlarms(ctx context.Context) *extension.SingleGetValueResponse {
+	resp := dh.GetOnuAlarmManager().GetOnuActiveAlarms(ctx)
+	logger.Debugw(ctx, "Received response from AlarmManager for Active Alarms for DeviceEntry", log.Fields{"device-id": dh.DeviceID})
+	return resp
+}
+
 // PrepareForGarbageCollection - remove references to prepare for garbage collection
 func (dh *deviceHandler) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
 	logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
diff --git a/internal/pkg/core/openonu.go b/internal/pkg/core/openonu.go
index 5192850..bbcd956 100755
--- a/internal/pkg/core/openonu.go
+++ b/internal/pkg/core/openonu.go
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//Package core provides the utility for onu devices, flows and statistics
+// Package core provides the utility for onu devices, flows and statistics
 package core
 
 import (
@@ -60,7 +60,7 @@
 	keepAliveInterval int64
 }
 
-//OpenONUAC structure holds the ONU core information
+// OpenONUAC structure holds the ONU core information
 type OpenONUAC struct {
 	deviceHandlers              map[string]*deviceHandler
 	deviceHandlersCreateChan    map[string]chan bool //channels for deviceHandler create events
@@ -99,7 +99,7 @@
 	maxConcurrentFlowsPerUni    int
 }
 
-//NewOpenONUAC returns a new instance of OpenONU_AC
+// NewOpenONUAC returns a new instance of OpenONU_AC
 func NewOpenONUAC(ctx context.Context, coreClient *vgrpc.Client, eventProxy eventif.EventProxy,
 	kvClient kvstore.Client, cfg *config.AdapterFlags, cm *conf.ConfigManager) *OpenONUAC {
 	var openOnuAc OpenONUAC
@@ -160,14 +160,14 @@
 	return &openOnuAc
 }
 
-//Start starts (logs) the adapter
+// Start starts (logs) the adapter
 func (oo *OpenONUAC) Start(ctx context.Context) error {
 	logger.Info(ctx, "starting-openonu-adapter")
 
 	return nil
 }
 
-//Stop terminates the session
+// Stop terminates the session
 func (oo *OpenONUAC) Stop(ctx context.Context) error {
 	logger.Info(ctx, "stopping-device-manager")
 	close(oo.exitChannel)
@@ -196,7 +196,7 @@
 	delete(oo.deviceHandlersCreateChan, agent.DeviceID)
 }
 
-//getDeviceHandler gets the ONU deviceHandler and may wait until it is created
+// getDeviceHandler gets the ONU deviceHandler and may wait until it is created
 func (oo *OpenONUAC) getDeviceHandler(ctx context.Context, deviceID string, aWait bool) *deviceHandler {
 	oo.mutexDeviceHandlersMap.Lock()
 	agent, ok := oo.deviceHandlers[deviceID]
@@ -249,7 +249,7 @@
 	return &empty.Empty{}, nil
 }
 
-//ReconcileDevice is called once when the adapter needs to re-create device - usually on core restart
+// ReconcileDevice is called once when the adapter needs to re-create device - usually on core restart
 func (oo *OpenONUAC) ReconcileDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
 	if device == nil {
 		logger.Warn(ctx, "reconcile-device-voltha-device-is-nil")
@@ -289,7 +289,7 @@
 	return &empty.Empty{}, nil
 }
 
-//DisableDevice disables the given device
+// DisableDevice disables the given device
 func (oo *OpenONUAC) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
 	logger.Infow(ctx, "disable-device", log.Fields{"device-id": device.Id})
 	if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
@@ -300,7 +300,7 @@
 	return nil, fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
 }
 
-//ReEnableDevice enables the onu device after disable
+// ReEnableDevice enables the onu device after disable
 func (oo *OpenONUAC) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
 	logger.Infow(ctx, "reenable-device", log.Fields{"device-id": device.Id})
 	if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
@@ -311,7 +311,7 @@
 	return nil, fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
 }
 
-//RebootDevice reboots the given device
+// RebootDevice reboots the given device
 func (oo *OpenONUAC) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
 	logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id})
 	if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
@@ -367,7 +367,7 @@
 	return &empty.Empty{}, nil
 }
 
-//UpdateFlowsIncrementally updates (add/remove) the flows on a given device
+// UpdateFlowsIncrementally updates (add/remove) the flows on a given device
 func (oo *OpenONUAC) UpdateFlowsIncrementally(ctx context.Context, incrFlows *ca.IncrementalFlows) (*empty.Empty, error) {
 	logger.Infow(ctx, "update-flows-incrementally", log.Fields{"device-id": incrFlows.Device.Id})
 
@@ -397,7 +397,7 @@
 	return nil, fmt.Errorf(fmt.Sprintf("handler-not-found-%s", incrFlows.Device.Id))
 }
 
-//UpdatePmConfig returns PmConfigs nil or error
+// UpdatePmConfig returns PmConfigs nil or error
 func (oo *OpenONUAC) UpdatePmConfig(ctx context.Context, configs *ca.PmConfigsInfo) (*empty.Empty, error) {
 	logger.Infow(ctx, "update-pm-config", log.Fields{"device-id": configs.DeviceId})
 	if handler := oo.getDeviceHandler(ctx, configs.DeviceId, false); handler != nil {
@@ -410,8 +410,8 @@
 	return nil, fmt.Errorf(fmt.Sprintf("handler-not-found-%s", configs.DeviceId))
 }
 
-//DownloadImage requests downloading some image according to indications as given in request
-//The ImageDownload needs to be called `request`due to library reflection requirements
+// DownloadImage requests downloading some image according to indications as given in request
+// The ImageDownload needs to be called `request`due to library reflection requirements
 func (oo *OpenONUAC) DownloadImage(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	ctx = log.WithSpanFromContext(context.Background(), ctx)
 	if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
@@ -435,9 +435,11 @@
 	return nil, errors.New("invalid image definition")
 }
 
-//ActivateImageUpdate requests downloading some Onu Software image to the ONU via OMCI
-//  according to indications as given in request and on success activate the image on the ONU
-//The ImageDownload needs to be called `request`due to library reflection requirements
+// ActivateImageUpdate requests downloading some Onu Software image to the ONU via OMCI
+//
+//	according to indications as given in request and on success activate the image on the ONU
+//
+// The ImageDownload needs to be called `request`due to library reflection requirements
 func (oo *OpenONUAC) ActivateImageUpdate(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
 		if oo.pDownloadManager.ImageLocallyDownloaded(ctx, imageInfo.Image) {
@@ -458,7 +460,7 @@
 	return nil, errors.New("invalid image definition")
 }
 
-//GetSingleValue handles the core request to retrieve uni status
+// GetSingleValue handles the core request to retrieve uni status
 func (oo *OpenONUAC) GetSingleValue(ctx context.Context, request *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) {
 	logger.Infow(ctx, "Single_get_value_request", log.Fields{"request": request})
 
@@ -485,6 +487,10 @@
 			return handler.getOnuOMCICounters(ctx, reqType.OnuInfo), nil
 		case *extension.GetValueRequest_OnuOmciStats:
 			return handler.getOnuOMCIStats(ctx)
+		case *extension.GetValueRequest_OnuActiveAlarms:
+			resp := handler.getOnuActiveAlarms(ctx)
+			logger.Infow(ctx, "Received response for on demand active alarms request ", log.Fields{"response": resp})
+			return resp, nil
 		default:
 			return uniprt.PostUniStatusErrResponse(extension.GetValueResponse_UNSUPPORTED), nil
 		}
@@ -500,7 +506,8 @@
 //   To be on the safe side argument names are left here always as defined in iAdapter.go .
 
 // DownloadOnuImage downloads (and optionally activates and commits) the indicated ONU image to the requested ONU(s)
-//   if the image is not yet present on the adapter it has to be automatically downloaded
+//
+//	if the image is not yet present on the adapter it has to be automatically downloaded
 func (oo *OpenONUAC) DownloadOnuImage(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) {
 	if request != nil && len((*request).DeviceId) > 0 && (*request).Image.Version != "" {
 		if strings.Contains((*request).Image.Url, "https:") {
@@ -601,7 +608,8 @@
 }
 
 // GetOnuImageStatus delivers the adapter-related information about the download/activation/commitment
-//   status for the requested image
+//
+//	status for the requested image
 func (oo *OpenONUAC) GetOnuImageStatus(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
 	if in != nil && len((*in).DeviceId) > 0 && (*in).Version != "" {
 		loResponse := voltha.DeviceImageResponse{}
@@ -765,7 +773,8 @@
 }
 
 // ActivateOnuImage initiates the activation of the image for the requested ONU(s)
-//  precondition: image downloaded and not yet activated or image refers to current inactive image
+//
+//	precondition: image downloaded and not yet activated or image refers to current inactive image
 func (oo *OpenONUAC) ActivateOnuImage(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
 	if in != nil && len((*in).DeviceId) > 0 && (*in).Version != "" {
 		loResponse := voltha.DeviceImageResponse{}
@@ -813,7 +822,8 @@
 }
 
 // CommitOnuImage enforces the commitment of the image for the requested ONU(s)
-//  precondition: image activated and not yet committed
+//
+//	precondition: image activated and not yet committed
 func (oo *OpenONUAC) CommitOnuImage(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) {
 	if in != nil && len((*in).DeviceId) > 0 && (*in).Version != "" {
 		loResponse := voltha.DeviceImageResponse{}
@@ -1007,7 +1017,7 @@
 	return false
 }
 
-//stopAllGrpcClients stops all grpc clients in use
+// stopAllGrpcClients stops all grpc clients in use
 func (oo *OpenONUAC) stopAllGrpcClients(ctx context.Context) {
 	// Stop the clients that connect to the parent
 	oo.lockParentAdapterClients.Lock()
@@ -1196,54 +1206,53 @@
  *
  */
 
-//GetOfpDeviceInfo returns OFP information for the given device.  Method not implemented as per [VOL-3202].
+// GetOfpDeviceInfo returns OFP information for the given device.  Method not implemented as per [VOL-3202].
 // OF port info is now to be delivered within UniPort create cmp changes in onu_uni_port.go::CreateVolthaPort()
-//
 func (oo *OpenONUAC) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ca.SwitchCapability, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//SimulateAlarm is unimplemented
+// SimulateAlarm is unimplemented
 func (oo *OpenONUAC) SimulateAlarm(context.Context, *ca.SimulateAlarmMessage) (*common.OperationResp, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//SetExtValue is unimplemented
+// SetExtValue is unimplemented
 func (oo *OpenONUAC) SetExtValue(context.Context, *ca.SetExtValueMessage) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//SetSingleValue is unimplemented
+// SetSingleValue is unimplemented
 func (oo *OpenONUAC) SetSingleValue(context.Context, *extension.SingleSetValueRequest) (*extension.SingleSetValueResponse, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//StartOmciTest not implemented
+// StartOmciTest not implemented
 func (oo *OpenONUAC) StartOmciTest(ctx context.Context, test *ca.OMCITest) (*omci.TestResponse, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//SuppressEvent unimplemented
+// SuppressEvent unimplemented
 func (oo *OpenONUAC) SuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//UnSuppressEvent  unimplemented
+// UnSuppressEvent  unimplemented
 func (oo *OpenONUAC) UnSuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//GetImageDownloadStatus is unimplemented
+// GetImageDownloadStatus is unimplemented
 func (oo *OpenONUAC) GetImageDownloadStatus(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//CancelImageDownload is unimplemented
+// CancelImageDownload is unimplemented
 func (oo *OpenONUAC) CancelImageDownload(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//RevertImageUpdate is unimplemented
+// RevertImageUpdate is unimplemented
 func (oo *OpenONUAC) RevertImageUpdate(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) {
 	return nil, errors.New("unImplemented")
 }
@@ -1253,12 +1262,12 @@
 	return nil, errors.New("unImplemented")
 }
 
-//SelfTestDevice unimplented
+// SelfTestDevice unimplented
 func (oo *OpenONUAC) SelfTestDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }
 
-//SendPacketOut sends packet out to the device
+// SendPacketOut sends packet out to the device
 func (oo *OpenONUAC) SendPacketOut(ctx context.Context, packet *ca.PacketOut) (*empty.Empty, error) {
 	return nil, errors.New("unImplemented")
 }