Commit 9fdc2656 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Completed 'vos_import' cli tool.

parent 8a8779de
Loading
Loading
Loading
Loading
+24 −11
Original line number Diff line number Diff line
@@ -38,6 +38,16 @@ class AMQPClient(object):
    def load(self, path, username):
        importRequest = { "requestType": "NODE_IMPORT", "path": path, "userName": username }
        importResponse = self.call(importRequest)
        if "responseType" not in importResponse:
            sys.exit("FATAL: Malformed response, storage acknowledge expected.\n")
        elif importResponse["responseType"] == "IMPORT_DONE":
            print("\nImport procedure completed!\n")
        elif importResponse["responseType"] == "ERROR":
            errorCode = importResponse["errorCode"]
            errorMsg = importResponse["errorMsg"]
            sys.exit(f"\nError code: {errorCode}\nError message: {errorMsg}\n")
        else:
            sys.exit("\nFATAL: Unknown response type.\n")

    def help(self):
        sys.exit("""
@@ -45,18 +55,25 @@ NAME
       vos_import

SYNOPSYS
       vos_import PATH
       vos_import DIR_PATH USERNAME

DESCRIPTION
       This tool imports external data on the VOSpace file catalog.
       This tool recursively imports nodes on the VOSpace file catalog.
       
       Only one parameter is required:

       PATH
           the file/directory physical path. It can be a file or a 
           directory.
           If the path is a directory, the command will scan it 
           recursively.
       DIR_PATH:
           the physical path of a directory located within the user directory
           at a given mount point.
           
       USERNAME:
           the username used for accessing the transfer node.
           
EXAMPLE
      The following command will import recursively all the nodes contained
      in 'mydir' on the VOSpace for the 'jsmith' user:
      
      # vos_import /mnt/storage/users/jsmith/mydir jsmith   
    """)

# Create new AMQPClient object
@@ -68,8 +85,4 @@ if len(sys.argv) == 3:
else:
    vosImportCli.help()

# Check the parameter passed by the user
#if os.path.exists(path):
vosImportCli.load(path, username)
#else:
#    vosImportCli.help()