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

Added basic email notification with report for imported nodes.

parent 8a51d9eb
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ from db_connector import DbConnector
from mailer import Mailer
from node import Node
from system_utils import SystemUtils
from tabulate import tabulate
from tape_client import TapeClient

from multiprocessing import Process
@@ -112,6 +113,10 @@ class ImportAMQPServer(AMQPServer):
        This method performs an import and is executed from a separate process in order to allow the 
        'execute_callback' to return quickly.
        """
        
        nodeList = []
        nodes = open("node_list.txt", "w")
        
        out = open("import_amqp_server_log.txt", "a")
        if storageType == "cold":
                tapeClient.connect()
@@ -152,6 +157,9 @@ class ImportAMQPServer(AMQPServer):
                        dbConn.insertNode(cnode)
                        dbConn.setAsyncTrans(vospacePath, True)
                        dbConn.setSticky(vospacePath, True)
                        nodeList.append([ dir, nodeName, "DONE" ])
                    else:
                        nodeList.append([ dir, nodeName, "SKIP" ])

        for flist in files:
            for file in flist:                
@@ -186,10 +194,16 @@ class ImportAMQPServer(AMQPServer):
                        dbConn.insertNode(dnode)
                        dbConn.setAsyncTrans(vospacePath, True)
                        dbConn.setSticky(vospacePath, True)
                        nodeList.append([ file, nodeName, "DONE" ])
                    else:
                        nodeList.append([ file, nodeName, "SKIP" ])
                        
        nodes.write(tabulate(nodeList))
        nodes.close()
                        
        m = Mailer()
        m.setMessage("Nodes successfully imported.")
        m.addReceiver("cristiano.urban@inaf.it")
        m.addRecipient("cristiano.urban@inaf.it")
        m.setMessageWithAttachment("import", "Import procedure completed", "node_list.txt")
        m.send()                        

    def run(self):