NotificationHandler

The Notification service provides a toolkit to contact people via email (eventually SMS etc.) to trigger some actions.

The original motivation for this is due to some sites restricting the sending of email but it is useful for e.g. crash reports to get to their destination.

Another use-case is for users to request an email notification for the completion of their jobs. When output data files are uploaded to the Grid, an email could be sent by default with the metadata of the file.

It can also be used to set alarms to be promptly forwarded to those subscribing to them.

class DIRAC.FrameworkSystem.Service.NotificationHandler.NotificationHandler(handlerInitDict, trid)

Bases: DIRAC.Core.DISET.RequestHandler.RequestHandler

exception ConnectionError(msg)

Bases: exceptions.Exception

__init__(msg)

x.__init__(…) initializes x; see help(type(x)) for signature

args
message
__init__(handlerInitDict, trid)

Constructor

Parameters:
  • handlerInitDict (dictionary) – Information vars for the service
  • trid (object) – Transport to use
auth_ping = ['all']
auth_refreshConfiguration = ['CSAdministrator']
export_addNotificationForUser(user, message, lifetime=604800, deferToMail=True)

Create a group of users to be used as an assignee for an alarm

export_deleteAlarmsByAlarmId(alarmsIdList)

Delete alarms by alarmId

export_deleteAlarmsByAlarmKey(alarmsKeyList)

Delete alarms by alarmId

export_deleteAssigneeGroup(groupName)

Delete an assignee group

static export_echo(data)

This method is used for testing performance of the service

Parameters:data (str) – data to be sent back to the caller
Returns:S_OK, Value is the input data
export_getAlarmInfo(alarmId)

Get the extended info of an alarm

export_getAlarms(selectDict, sortList, startItem, maxItems)

Select existing alarms suitable for the Web monitoring

export_getAssigneeGroups()

Get all assignee groups and the users that belong to them

export_getAssigneeGroupsForUser(user)

Get all assignee groups and the users that belong to them

export_getNotifications(selectDict, sortList, startItem, maxItems)

Get all assignee groups and the users that belong to them

export_getUsersInAssigneeGroup(groupName)

Get users in assignee group

export_markNotificationsAsNotRead(user, notIds)

Delete an assignee group

export_markNotificationsAsRead(user, notIds)

Delete an assignee group

export_newAlarm(alarmDefinition)

Set a new alarm in the Notification database

export_ping()
static export_refreshConfiguration(fromMaster)

Force refreshing the configuration data

Parameters:fromMaster (bool) – flag to refresh from the master configuration service
export_removeNotificationsForUser(user, notIds)

Get users in assignee group

export_sendMail(address, subject, body, fromAddress, avoidSpam=False)

Send an email with supplied body to the specified address using the Mail utility.

Parameters:
  • address (basestring) – recipient addresses
  • subject (basestring) – subject of letter
  • body (basestring) – body of letter
  • fromAddress (basestring) – sender address, if None, will be used default from CS
  • avoidSpam (bool) – if True, then emails are first added to a set so that duplicates are removed, and sent every hour.
Returns:

S_OK(basestring)/S_ERROR() – basestring is status message

export_sendSMS(userName, body, fromAddress)

Send an SMS with supplied body to the specified DIRAC user using the Mail utility via an SMS switch.

Parameters:
  • userName (basestring) – user name
  • body (basestring) – message
  • fromAddress (basestring) – sender address
Returns:

S_OK()/S_ERROR()

export_setAssigneeGroup(groupName, userList)

Create a group of users to be used as an assignee for an alarm

export_updateAlarm(updateDefinition)

update an existing alarm in the Notification database

classmethod getCSOption(optionName, defaultValue=False)

Get an option from the CS section of the services

Returns:Value for serviceSection/optionName in the CS being defaultValue the default
getRemoteAddress()

Get the address of the remote peer.

Returns:Address of remote peer.
getRemoteCredentials()

Get the credentials of the remote peer.

Returns:Credentials dictionary of remote peer.
initialize()

Initialize this instance of the handler (to be overwritten)

classmethod initializeHandler(serviceInfo)

Handler initialization

srv_disconnect(trid=None)
classmethod srv_disconnectClient(trid)
srv_getActionTuple()
classmethod srv_getCSOption(optionName, defaultValue=False)

Get an option from the CS section of the services

Returns:Value for serviceSection/optionName in the CS being defaultValue the default
srv_getClientSetup()
srv_getClientVO()
srv_getClientVersion()
srv_getFormattedRemoteCredentials()
classmethod srv_getMonitor()
srv_getRemoteAddress()

Get the address of the remote peer.

Returns:Address of remote peer.
srv_getRemoteCredentials()

Get the credentials of the remote peer.

Returns:Credentials dictionary of remote peer.
classmethod srv_getServiceName()
srv_getTransportID()
classmethod srv_getURL()
classmethod srv_msgCreate(msgName)
srv_msgReply(msgObj)
classmethod srv_msgSend(trid, msgObj)
transfer_bulkFromClient(bulkId, token, bulkSize, fileHelper)
transfer_bulkToClient(bulkId, token, fileHelper)
transfer_fromClient(fileId, token, fileSize, fileHelper)
transfer_listBulk(bulkId, token, fileHelper)
transfer_toClient(fileId, token, fileHelper)
types_addNotificationForUser = [<type 'basestring'>, <type 'basestring'>]
types_deleteAlarmsByAlarmId = [(<type 'list'>, <type 'int'>)]
types_deleteAlarmsByAlarmKey = [(<type 'basestring'>, <type 'list'>)]
types_deleteAssigneeGroup = [<type 'basestring'>]
types_echo = [<type 'basestring'>]
types_getAlarmInfo = [(<type 'int'>, <type 'long'>)]
types_getAlarms = [<type 'dict'>, <type 'list'>, <type 'int'>, <type 'int'>]
types_getAssigneeGroups = []
types_getAssigneeGroupsForUser = [<type 'basestring'>]
types_getNotifications = [<type 'dict'>, <type 'list'>, <type 'int'>, <type 'int'>]
types_getUsersInAssigneeGroup = [<type 'basestring'>]
types_markNotificationsAsNotRead = [<type 'basestring'>, <type 'list'>]
types_markNotificationsAsRead = [<type 'basestring'>, <type 'list'>]
types_newAlarm = [<type 'dict'>]
types_ping = []
types_refreshConfiguration = [<type 'bool'>]
types_removeNotificationsForUser = [<type 'basestring'>, <type 'list'>]
types_sendMail = [<type 'basestring'>, <type 'basestring'>, <type 'basestring'>, <type 'basestring'>, <type 'bool'>]
types_sendSMS = [<type 'basestring'>, <type 'basestring'>, <type 'basestring'>]
types_setAssigneeGroup = [<type 'basestring'>, <type 'list'>]
types_updateAlarm = [<type 'dict'>]
DIRAC.FrameworkSystem.Service.NotificationHandler.purgeDelayedEMails()

Purges the emails accumulated in gMailSet