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

Added support for 'storageId' parameter.

parent a7cba471
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -61,11 +61,20 @@ DESCRIPTION
    def store(self, cmd, username):
        request_type = cmd.upper()
        storeRequest = { "requestType": request_type, "userName": username }
        print(f"\nSending {request_type} request...")
        print(f"\nSending {request_type} request...\n")
        storeResponse = self.call(storeRequest)
        if "responseType" not in storeResponse:
        if "responseType" not in storeResponse or "storageList" not in storeResponse:
            sys.exit("FATAL: Malformed response, store acknowledge expected.\n")
        elif storeResponse["responseType"] == "STORE_ACK":
            storageList = storeResponse["storageList"]
            print("Choose one of the following storage locations:\n")
            storageIdList = []
            for st in storageList:
                storageIdList.append(st["storage_id"])
                print("storage_id: {:<2d}   =>   hostname: {}".format(st['storage_id'], st['hostname']))
            storageId = None
            while not storageId in storageIdList:
                storageId = int(input("\nInsert the storage id: "))
            print("\nWARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!")
            print("If you confirm, all your data on the transfer node will be")
            print("available in read-only mode for all the time the archiving")
@@ -75,7 +84,7 @@ DESCRIPTION
            while not confirm in [ "yes", "no"]:
                confirm = input("Are you sure to proceed? [yes/no]: ")
            if confirm == "yes":
                confirmRequest = { "requestType": "STORE_CON", "userName": username }
                confirmRequest = { "requestType": "STORE_CON", "userName": username, "storageId": storageId }
                confirmResponse = self.call(confirmRequest)
                if "responseType" not in confirmResponse:
                    sys.exit("\nFATAL: Malformed response, store confirmation expected.\n")
+8 −1
Original line number Diff line number Diff line
@@ -49,6 +49,12 @@ class StoreAMQPServer(AMQPServer):
            self.job.setType("other")
            self.job.setInfo(requestBody)
            self.job.setPhase("PENDING")
            self.dbConn.connect()
            if requestBody["requestType"] == "CSTORE":
                storageList = self.dbConn.getStorageList("cold")
            else:
                storageList = self.dbConn.getStorageList("hot")
            self.dbConn.disconnect()
            #folderPath = "/home/" + user + "/store"
            folderPath = self.storageStorePath.replace("{username}", user)
            userInfo = self.systemUtils.userInfo(user)
@@ -67,7 +73,7 @@ class StoreAMQPServer(AMQPServer):
                    # be done until the write permissions are restored or new data is
                    # copied on the transfer node by the user.
                    if os.access(folderPath, os.W_OK) and os.listdir(folderPath):
                        response = { "responseType": "STORE_ACK" }
                        response = { "responseType": "STORE_ACK", "storageList": storageList }
                        self.storeAck = True
                    else:
                        response = { "responseType": "ERROR",
@@ -87,6 +93,7 @@ class StoreAMQPServer(AMQPServer):
                self.dbConn.insertJob(self.job)
                dbResponse = self.dbConn.getJob(self.job.jobId)
                self.dbConn.disconnect()
                self.job.jobInfo["storageId"] = requestBody["storageId"]
                self.pendingQueueWrite.insertJob(self.job)
                if "error" in dbResponse:
                    response = { "responseType": "ERROR",