Commit 73fdbedb authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'base_url' support for 'portal' storage type.

parent f51a2ae7
Loading
Loading
Loading
Loading
+24 −18
Original line number Diff line number Diff line
#!/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,7 +32,11 @@ class VOSStorage(AMQPClient):
                    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!")
@@ -40,6 +44,7 @@ class VOSStorage(AMQPClient):
                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:
@@ -51,6 +56,7 @@ class VOSStorage(AMQPClient):
        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 !")
+9 −6
Original line number Diff line number Diff line
@@ -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,9 +33,11 @@ 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":
            if self.storageType != "portal":
                if not os.path.exists(self.storageBasePath):
                    response = { "responseType": "ERROR",
                                 "errorCode": 2,
                                 "errorMsg": "Base path doesn't exist."}
@@ -44,6 +46,7 @@ class StorageAMQPServer(AMQPServer):
            self.dbConn.connect()
            result = self.dbConn.insertStorage(self.storageType,
                                               self.storageBasePath,
                                               self.storageBaseUrl,
                                               self.storageHostname)
            self.dbConn.disconnect()