diff --git a/client/vos_data b/client/vos_data index 0fe08a1a0dec9a06f266353a07658fa407152ee2..717161ae0e909365523faa39ce439dbbe5f222f7 100644 --- a/client/vos_data +++ b/client/vos_data @@ -81,7 +81,7 @@ EXAMPLES for st in storageList: storageIdList.append(st["storage_id"]) storageId = None - while not storageId in storageIdList: + while storageId not in storageIdList: try: storageId = input("Please, insert a storage id: ") storageId = int(storageId) @@ -97,7 +97,7 @@ EXAMPLES print("! process is running. !") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") confirm = None - while not confirm in ( "yes", "no" ): + while confirm not in ( "yes", "no" ): try: confirm = input("Are you sure to proceed? [yes/no]: ") except KeyboardInterrupt: diff --git a/client/vos_storage b/client/vos_storage index ad4ab1eb4101b3c56afed5e9f0f1a3d3f0c0fca5..8d86b7a04342f4da6664fd83da9fad3bb54dc42b 100644 --- a/client/vos_storage +++ b/client/vos_storage @@ -27,23 +27,19 @@ class VOSStorage(RedisRPCClient): def add(self): storageType = None storageBasePath = None - storageBaseUrl = None storageHostname = None - while not storageType in ("cold", "hot", "portal"): + while storageType not in ("cold", "hot"): try: - storageType = input("\nStorage type ['cold', 'hot' or 'portal']: ") + storageType = input("\nStorage type ['cold' or 'hot']: ") 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): + while not storageBasePath: try: - if storageType == "portal": - storageBaseUrl = input("\nStorage base url: ") - else: - storageBasePath = input("\nStorage base path: ") + storageBasePath = input("\nStorage base path: ") except ValueError: print("Input type is not valid!") except EOFError: @@ -62,7 +58,6 @@ class VOSStorage(RedisRPCClient): storageRequest = { "requestType": "STORAGE_ADD", "storageType": storageType, "basePath": storageBasePath, - "baseUrl": storageBaseUrl, "hostname": storageHostname } storageResponse = self.call(storageRequest) @@ -93,7 +88,7 @@ class VOSStorage(RedisRPCClient): for st in storageList: storageIdList.append(st["storage_id"]) storageId = None - while not storageId in storageIdList: + while storageId not in storageIdList: try: storageId = input("Please, insert a storage id: ") storageId = int(storageId) @@ -110,7 +105,7 @@ class VOSStorage(RedisRPCClient): print("! must do it manually. !") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") confirm = None - while not confirm in ( "yes", "no" ): + while confirm not in ( "yes", "no" ): try: confirm = input("Are you sure to proceed? [yes/no]: ") except KeyboardInterrupt: @@ -179,11 +174,10 @@ DESCRIPTION prints the full storage point list - Supported storage types are: 'hot', 'cold' and 'portal'. + Supported storage types are: 'hot' and 'cold'. Adding 'hot' or 'cold' storage points requires a base path - to be specified (e.g. '/mnt/my_storage/users'). - For 'portal' storage points a base URL is required. + to be specified (e.g. '/mnt/my_storage/users'). All storage points require a valid hostname or IP address. """) diff --git a/client/vos_user b/client/vos_user index 901adf360b8d7dbe0fcf6066c268afa9d9b4f898..2ffff233602c828e018426298d6c28f99f18c82b 100644 --- a/client/vos_user +++ b/client/vos_user @@ -93,7 +93,7 @@ class VOSUser(RedisRPCClient): for user in userList: userIdList.append(user["user_id"]) userId = None - while not userId in userIdList: + while userId not in userIdList: try: userId = input("\nPlease, insert a valid user ID: ") except ValueError: @@ -109,7 +109,7 @@ class VOSUser(RedisRPCClient): print("! you must do it manually. !") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") confirm = None - while not confirm in ( "yes", "no" ): + while confirm not in ( "yes", "no" ): try: confirm = input("Are you sure to proceed? [yes/no]: ") except KeyboardInterrupt: diff --git a/transfer_service/db_connector.py b/transfer_service/db_connector.py index 3dd2635ce66f4c40a55028426804243f7dcf58ce..e8bbe8afea7bce72caf6069122d7d722cc7cba6e 100644 --- a/transfer_service/db_connector.py +++ b/transfer_service/db_connector.py @@ -1189,7 +1189,7 @@ class DbConnector(object): ##### Storage ##### - def insertStorage(self, storageType, basePath, baseUrl, hostname): + def insertStorage(self, storageType, basePath, hostname): """Inserts a storage point.""" if not self.getStorageId(basePath): try: @@ -1198,14 +1198,12 @@ class DbConnector(object): cursor.execute(""" INSERT INTO storage(storage_type, base_path, - base_url, hostname) - VALUES (%s, %s, %s, %s) + VALUES (%s, %s, %s) RETURNING storage_id; """, (storageType, basePath, - baseUrl, hostname,)) storageSrcId = cursor.fetchall()[0]["storage_id"] except Exception: @@ -1213,25 +1211,21 @@ class DbConnector(object): conn.rollback() raise else: - if storageType == "cold" or storageType == "hot": - try: - cursor.execute(""" - SELECT storage_id - FROM storage - WHERE storage_type = 'local' - AND base_path = '/home' - AND hostname = 'localhost'; - """) - storageDestId = cursor.fetchall()[0]["storage_id"] - except Exception: - if not conn.closed: - conn.rollback() - raise - else: - locationType = "async" + try: + cursor.execute(""" + SELECT storage_id + FROM storage + WHERE storage_type = 'local' + AND base_path = '/home' + AND hostname = 'localhost'; + """) + storageDestId = cursor.fetchall()[0]["storage_id"] + except Exception: + if not conn.closed: + conn.rollback() + raise else: - storageDestId = storageSrcId - locationType = "portal" + locationType = "async" try: cursor.execute(""" INSERT INTO location(location_type, diff --git a/transfer_service/storage_rpc_server.py b/transfer_service/storage_rpc_server.py index ad2790c6ffb6986ccb9469b028e62b744b908413..9adeda5e966edc1dc600d17484ac5694e5bf4e18 100644 --- a/transfer_service/storage_rpc_server.py +++ b/transfer_service/storage_rpc_server.py @@ -49,20 +49,17 @@ class StorageRPCServer(RedisRPCServer): elif requestBody["requestType"] == "STORAGE_ADD": storageType = requestBody["storageType"] storageBasePath = requestBody["basePath"] - storageBaseUrl = requestBody["baseUrl"] storageHostname = requestBody["hostname"] - if storageType != "portal": - if not os.path.exists(storageBasePath): - errorMsg = "Base path doesn't exist." - self.logger.error(errorMsg) - response = { "responseType": "ERROR", - "errorCode": 3, - "errorMsg": errorMsg } - return response + if not os.path.exists(storageBasePath): + errorMsg = "Base path doesn't exist." + self.logger.error(errorMsg) + response = { "responseType": "ERROR", + "errorCode": 3, + "errorMsg": errorMsg } + return response try: result = self.dbConn.insertStorage(storageType, storageBasePath, - storageBaseUrl, storageHostname) except Exception: errorMsg = "Database error."