Skip to content

Commit

Permalink
feat: add a VO name to sendMessage call
Browse files Browse the repository at this point in the history
  • Loading branch information
martynia committed Jan 26, 2024
1 parent 9412031 commit a8349fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Pilot/dirac-pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
if not sys.stdin.isatty():
receivedContent = sys.stdin.read()
log = RemoteLogger(
pilotParams.loggerURL, "Pilot", bufsize=pilotParams.loggerBufsize, pilotUUID=pilotParams.pilotUUID, debugFlag=pilotParams.debugFlag
pilotParams.loggerURL, "Pilot", bufsize=pilotParams.loggerBufsize,
pilotUUID=pilotParams.pilotUUID, debugFlag=pilotParams.debugFlag, wnVO=pilotParams.wnVO,
)
log.info("Remote logger activated")
log.buffer.write(receivedContent)
Expand Down
9 changes: 6 additions & 3 deletions Pilot/pilotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def __init__(
pilotUUID="unknown",
flushInterval=10,
bufsize=1000,
wnVO = "unknown",
):
"""
c'tor
Expand All @@ -523,7 +524,7 @@ def __init__(
self.url = url
self.pilotUUID = pilotUUID
self.isPilotLoggerOn = isPilotLoggerOn
sendToURL = partial(sendMessage, url, pilotUUID, "sendMessage")
sendToURL = partial(sendMessage, url, pilotUUID, wnVO, "sendMessage")
self.buffer = FixedSizeBuffer(sendToURL, bufsize=bufsize, autoflush=flushInterval)

def debug(self, msg, header=True, sendPilotLog=False):
Expand Down Expand Up @@ -668,12 +669,13 @@ def cancelTimer(self):
self._timer.cancel()


def sendMessage(url, pilotUUID, method, rawMessage):
def sendMessage(url, pilotUUID, wnVO, method, rawMessage):
"""
Invoke a remote method on a Tornado server and pass a JSON message to it.
:param str url: Server URL
:param str pilotUUID: pilot unique ID
:param str wnVO: VO name, relevant only if not contained in a proxy
:param str method: a method to be invoked
:param str rawMessage: a message to be sent, in JSON format
:return: None.
Expand All @@ -684,7 +686,7 @@ def sendMessage(url, pilotUUID, method, rawMessage):
context = ssl.create_default_context()
context.load_verify_locations(capath=caPath)

message = json.dumps((json.dumps(rawMessage), pilotUUID))
message = json.dumps((json.dumps(rawMessage), pilotUUID, wnVO))

try:
context.load_cert_chain(cert) # this is a proxy
Expand Down Expand Up @@ -737,6 +739,7 @@ def __init__(self, pilotParams, dummy=""):
debugFlag=self.debugFlag,
flushInterval=interval,
bufsize=bufsize,
wnVO=pilotParams.wnVO,
)

self.log.isPilotLoggerOn = isPilotLoggerOn
Expand Down

0 comments on commit a8349fa

Please sign in to comment.