Commit 158e96c7 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Enabled md5sum files recall test from tape.

parent 172ebd24
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -89,8 +89,10 @@ class ImportAMQPServer(AMQPServer):
                self.dbConn.disconnect()
                return response            
            else:
                #if storageType == "cold":
                #    self.tapeClient.recallCheksumFiles(self.path)
                if storageType == "cold":
                    self.tapeClient.connect()
                    self.tapeClient.recallChecksumFiles(self.path)
                    self.tapeClient.disconnect()
                
                [ dirs, files ] = self.systemUtils.scanRecursive(os.path.dirname(self.path))
                
+23 −10
Original line number Diff line number Diff line
@@ -5,28 +5,33 @@ import scp
import sys
import uuid

from config import Config
from tape_task import TapeTask


class TapeClient(object):

    # Constructor
    def __init__(self, host, port, user, password):
        self.host = host
        self.port = port
        self.user = user
        self.password = password
    def __init__(self):
        config = Config("vos_ts.conf")
        self.params = config.loadSection("spectrum_archive")
        self.host = self.params["host"]
        self.port = self.params.getint("port")
        self.user = self.params["user"]
        self.keyFile = self.params["pkey_file_path"]
        self.key = paramiko.RSAKey.from_private_key_file(keyFile)
        self.client = paramiko.SSHClient()
        self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self.client.load_system_host_keys()
        self.scp = None
        self.taskList = []
    
    # Connects to the tape library frontend
    def connect(self):
        self.client.connect(self.host,
                            self.port, 
                            self.user, 
                            self.password)        
        self.client.connect(hostname = self.host,
                            port = self.port,
                            username = self.user,
                            pkey = self.key)
    
    # Returns the whole task list
    def getTaskList(self):
@@ -79,6 +84,14 @@ class TapeClient(object):
    def recallChecksumFiles(self, dirName):
        cmd = "find $(dirname " + dirName + ") -type f \( -iname \"*-md5sum.txt\" \) | eeadm recall"
        stdin, stdout, stderr = self.client.exec_command(cmd)
        exitCode = stdout.channel.recv_exit_status()
        out = open("tape_client_log.txt", "a")
        out.write(f"exitCode: {exitCode}\n")
        out.close()
        if exitCode:
            return False
        else:
            return True
    
    # Closes the connection
    def disconnect(self):
+5 −2
Original line number Diff line number Diff line
@@ -34,10 +34,13 @@ port = 5672
# Spectrum Archive
[spectrum_archive]
; hostname or IP address of the tape library frontend
host = 192.168.56.101
host = tape-fe.ia2.inaf.it
; SSH port
port = 22
; login user
user = root
password = ibm
; SSH private key file absolute path
pkey_file_path = /home/transfer_service/tape/tape_rsa


############################