Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sweep:integration] fix: added fromAddress for notification emails #7801

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def main():
subject = f"{len(totalAllowedSEs)} storage elements allowed for use"
addressPath = "EMail/Production"
address = Operations().getValue(addressPath, "")
fromAddress = Operations().getValue("ResourceStatus/Config/FromAddress", "")

body = ""
if read:
Expand All @@ -185,7 +186,7 @@ def main():
gLogger.notice(f"'{addressPath}' not defined in Operations, can not send Mail\n", body)
DIRAC.exit(0)

res = diracAdmin.sendMail(address, subject, body)
res = diracAdmin.sendMail(address, subject, body, fromAddress=fromAddress)
gLogger.notice(f"Notifying {address}")
if res["OK"]:
gLogger.notice(res["Value"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def main():
subject = f"{len(writeBanned + readBanned + checkBanned + removeBanned)} storage elements banned for use"
addressPath = "EMail/Production"
address = Operations().getValue(addressPath, "")
fromAddress = Operations().getValue("ResourceStatus/Config/FromAddress", "")

body = ""
if read:
Expand All @@ -227,7 +228,7 @@ def main():
gLogger.notice(f"'{addressPath}' not defined in Operations, can not send Mail\n", body)
DIRAC.exit(0)

res = diracAdmin.sendMail(address, subject, body)
res = diracAdmin.sendMail(address, subject, body, fromAddress=fromAddress)
gLogger.notice(f"Notifying {address}")
if res["OK"]:
gLogger.notice(res["Value"])
Expand Down
3 changes: 2 additions & 1 deletion src/DIRAC/Interfaces/scripts/dirac_admin_allow_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def getBoolean(value):
if not address:
gLogger.notice(f"'{addressPath}' not defined in Operations, can not send Mail\n", body)
else:
result = diracAdmin.sendMail(address, subject, body)
fromAddress = Operations().getValue("ResourceStatus/Config/FromAddress", "")
result = diracAdmin.sendMail(address, subject, body, fromAddress=fromAddress)
else:
print("Automatic email disabled by flag.")

Expand Down
3 changes: 2 additions & 1 deletion src/DIRAC/Interfaces/scripts/dirac_admin_ban_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def getBoolean(value):
if not address:
gLogger.notice(f"'{addressPath}' not defined in Operations, can not send Mail\n", body)
else:
result = diracAdmin.sendMail(address, subject, body)
fromAddress = Operations().getValue("ResourceStatus/Config/FromAddress", "")
result = diracAdmin.sendMail(address, subject, body, fromAddress=fromAddress)
else:
print("Automatic email disabled by flag.")

Expand Down
5 changes: 4 additions & 1 deletion src/DIRAC/ResourceStatusSystem/Agent/TokenAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from datetime import datetime, timedelta

from DIRAC import S_OK, S_ERROR
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.Core.Base.AgentModule import AgentModule
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient


AGENT_NAME = "ResourceStatus/TokenAgent"


Expand Down Expand Up @@ -209,7 +211,8 @@ def _notify(self, tokenOwner, expired, expiring):
mail += " Or you can use the dirac-rss-set-token script\n\n"
mail += "Through the same interfaces you can release the token any time\n"

resEmail = self.diracAdmin.sendMail(tokenOwner, subject, mail)
fromAddress = Operations().getValue("ResourceStatus/Config/FromAddress", "")
resEmail = self.diracAdmin.sendMail(tokenOwner, subject, mail, fromAddress=fromAddress)
if not resEmail["OK"]:
return S_ERROR(f'Cannot send email to user "{tokenOwner}"')

Expand Down
Loading