Commit b0f83045 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Minor changes + added mail notification section to 'updateGroupRw()' method.

parent 7a6e4f75
Loading
Loading
Loading
Loading
+25 −3
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ class GroupRwExecutor(TaskExecutor):
        self.requestType = None
        self.requestType = None
        self.vospacePath = None
        self.vospacePath = None
        self.groupName = None
        self.groupName = None
        self.realGroupName = None
        super(GroupRwExecutor, self).__init__()
        super(GroupRwExecutor, self).__init__()


    def updateGroupRw(self):
    def updateGroupRw(self):
@@ -63,11 +64,32 @@ class GroupRwExecutor(TaskExecutor):
        elif self.requestType == "GRPW_DEL":
        elif self.requestType == "GRPW_DEL":
            self.dbConn.updateGroupWrite([], self.groupName, self.vospacePath)
            self.dbConn.updateGroupWrite([], self.groupName, self.vospacePath)
            
            
    def cleanup(self):
        self.jobObj.setPhase("COMPLETED")
        self.jobObj.setPhase("COMPLETED")
        self.dbConn.setPhase(self.jobId, "COMPLETED")
        self.dbConn.setPhase(self.jobId, "COMPLETED")
        self.dbConn.setEndTime(self.jobId)
        self.dbConn.setEndTime(self.jobId)
        
        
        # Send e-mail notification
        m = Mailer()
        m.addRecipient("cristiano.urban@inaf.it")
        if self.requestType == "GRPR_ADD":
            msg = f"""
        Added '{self.realGroupName}' to 'group_read' for {self.vospacePath} and any child nodes.
            """
        elif self.requestType == "GRPR_DEL":
            msg = f"""
        Removed '{self.realGroupName}' from 'group_read' for {self.vospacePath} and any child nodes.
            """
        elif self.requestType == "GRPW_ADD":
            msg = f"""
        Added '{self.realGroupName}' to 'group_write' for {self.vospacePath} and any child nodes.
            """
        elif self.requestType == "GRPW_DEL":
            msg = f"""
        Removed '{self.realGroupName}' from 'group_write' for {self.vospacePath} and any child nodes.
            """
        m.setMessage("VOSpace group_rw notification", msg)
        m.send()

    def run(self):
    def run(self):
        self.logger.info("Starting group_rw executor...")
        self.logger.info("Starting group_rw executor...")
        self.setSourceQueueName("group_rw_ready")
        self.setSourceQueueName("group_rw_ready")
@@ -81,8 +103,8 @@ class GroupRwExecutor(TaskExecutor):
                self.requestType = self.jobObj.jobInfo["requestType"]
                self.requestType = self.jobObj.jobInfo["requestType"]
                self.vospacePath = self.jobObj.jobInfo["vospacePath"]
                self.vospacePath = self.jobObj.jobInfo["vospacePath"]
                self.groupName = [ self.jobObj.jobInfo["groupName"] ]
                self.groupName = [ self.jobObj.jobInfo["groupName"] ]
                self.realGroupName = self.groupName[0].split("people.")[-1].replace("\\", "")
                self.updateGroupRw()
                self.updateGroupRw()
                self.cleanup()
                if self.destQueue.len() >= self.maxTerminatedJobs:
                if self.destQueue.len() >= self.maxTerminatedJobs:
                    self.destQueue.extractJob()
                    self.destQueue.extractJob()
                self.destQueue.insertJob(self.jobObj)
                self.destQueue.insertJob(self.jobObj)