From 73fdbedb89e4e8415dcedb4eecca6cde5b6f3ec2 Mon Sep 17 00:00:00 2001 From: Cristiano Urban Date: Wed, 10 Mar 2021 11:00:03 +0100 Subject: [PATCH] Added 'base_url' support for 'portal' storage type. Signed-off-by: Cristiano Urban --- client/vos_storage | 42 ++++++++++++++----------- transfer_service/storage_amqp_server.py | 15 +++++---- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/client/vos_storage b/client/vos_storage index aa5214d..785a6d8 100644 --- a/client/vos_storage +++ b/client/vos_storage @@ -1,6 +1,5 @@ #!/usr/bin/env python -import os import sys from amqp_client import AMQPClient @@ -22,6 +21,7 @@ class VOSStorage(AMQPClient): def add(self): storageType = None storageBasePath = None + storageBaseUrl = None storageHostname = None while not storageType in ("cold", "hot", "portal"): try: @@ -32,25 +32,31 @@ class VOSStorage(AMQPClient): print("\nPlease, use CTRL+C to quit.") except KeyboardInterrupt: sys.exit("\nCTRL+C detected. Exiting...") - try: - storageBasePath = input("\nStorage base path: ") - except ValueError: - print("Input type is not valid!") - except EOFError: - print("\nPlease, use CTRL+C to quit.") - except KeyboardInterrupt: - sys.exit("\nCTRL+C detected. Exiting...") - try: - storageHostname = input("\nStorage hostname: ") - except ValueError: - print("Input type is not valid!") - except EOFError: - print("\nPlease, use CTRL+C to quit.") - except KeyboardInterrupt: - sys.exit("\nCTRL+C detected. Exiting...") + while not (storageBasePath or storageBaseUrl): + try: + if storageType == "portal": + storageBaseUrl = input("\nStorage base url: ") + else: + storageBasePath = input("\nStorage base path: ") + except ValueError: + print("Input type is not valid!") + except EOFError: + print("\nPlease, use CTRL+C to quit.") + except KeyboardInterrupt: + sys.exit("\nCTRL+C detected. Exiting...") + while not storageHostname: + try: + storageHostname = input("\nStorage hostname: ") + except ValueError: + print("Input type is not valid!") + except EOFError: + print("\nPlease, use CTRL+C to quit.") + except KeyboardInterrupt: + sys.exit("\nCTRL+C detected. Exiting...") storageRequest = { "requestType": "STORAGE_ADD", "storageType": storageType, "basePath": storageBasePath, + "baseUrl": storageBaseUrl, "hostname": storageHostname } storageResponse = self.call(storageRequest) @@ -93,7 +99,7 @@ class VOSStorage(AMQPClient): except KeyboardInterrupt: sys.exit("\nCTRL+C detected. Exiting...") print() - print("!!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("! This operation will remove the selected storage location only !") print("! from the database. !") print("! The mount point on the transfer node will not be removed, you !") diff --git a/transfer_service/storage_amqp_server.py b/transfer_service/storage_amqp_server.py index abec735..8289619 100644 --- a/transfer_service/storage_amqp_server.py +++ b/transfer_service/storage_amqp_server.py @@ -24,7 +24,7 @@ class StorageAMQPServer(AMQPServer): super(StorageAMQPServer, self).__init__(host, port, queue) def execute_callback(self, requestBody): - # 'requestType', 'mountPoint', 'hostname' and 'storageType' attributes are mandatory + # 'requestType' attribute is mandatory if "requestType" not in requestBody: response = { "responseType": "ERROR", "errorCode": 1, @@ -33,17 +33,20 @@ class StorageAMQPServer(AMQPServer): elif requestBody["requestType"] == "STORAGE_ADD": self.storageType = requestBody["storageType"] self.storageBasePath = requestBody["basePath"] + self.storageBaseUrl = requestBody["baseUrl"] self.storageHostname = requestBody["hostname"] - if not os.path.exists(self.storageBasePath) and self.storageType != "portal": - response = { "responseType": "ERROR", - "errorCode": 2, - "errorMsg": "Base path doesn't exist."} - return response + if self.storageType != "portal": + if not os.path.exists(self.storageBasePath): + response = { "responseType": "ERROR", + "errorCode": 2, + "errorMsg": "Base path doesn't exist."} + return response self.dbConn.connect() result = self.dbConn.insertStorage(self.storageType, self.storageBasePath, + self.storageBaseUrl, self.storageHostname) self.dbConn.disconnect() -- GitLab