Commit 0b8c848a authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'deleteStorage()' method.

parent 080f8231
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class DbConnector(object):
                return False    
        
    def getStorageBasePath(self, storageId):
        """Returns the storage base path for a give storage id"""
        """Returns the storage base path for a give storage id."""
        if self.conn:
            self.cursor.execute("SELECT base_path FROM storage WHERE storage_id = %s;", (storageId,))
            return self.cursor.fetchall()[0]["base_path"]
@@ -172,13 +172,13 @@ class DbConnector(object):
            return result
    
    def getStorageListByType(self, storageType):
        """Returns a list of storage locations for a given storage type"""
        """Returns a list of storage locations for a given storage type."""
        if self.conn:
            self.cursor.execute("SELECT * FROM storage WHERE storage_type = %s;", (storageType,))
            return self.cursor.fetchall()
        
    def getStorageId(self, basePath):
        """Returns the storage id for a given storage base path, if any. Otherwise it returns 'False'"""
        """Returns the storage id for a given storage base path, if any. Otherwise it returns 'False'."""
        if self.conn:
            self.cursor.execute("SELECT storage_id FROM storage WHERE base_path = %s;", (basePath,))
            result = self.cursor.fetchall()
@@ -190,7 +190,7 @@ class DbConnector(object):
    ### Location

    def getLocationId(self, destStorageId):
        """Returns the location id according to the storage id of the destination"""
        """Returns the location id according to the storage id of the destination."""
        if self.conn:
            self.cursor.execute("SELECT location_id FROM location WHERE storage_src_id = %s;", (destStorageId,))
            return self.cursor.fetchall()[0]["location_id"]
@@ -317,7 +317,7 @@ class DbConnector(object):
            self.conn.commit()    
            
    def deleteTmpDataNode(self, vospacePath):
        """Deletes a temporary VOSpace data node"""
        """Deletes a temporary VOSpace data node."""
        if self.conn:
            self.cursor.execute("""
                WITH deleted AS (
@@ -379,6 +379,7 @@ class DbConnector(object):
    ### Storage

    def insertStorage(self, storageType, basePath, hostname):
        """Inserts a storage point."""
        if self.conn:
            if not self.getStorageId(basePath):
                self.cursor.execute("""
@@ -423,3 +424,13 @@ class DbConnector(object):
            else:
                return False
            
    def deleteStorage(self, storageId):
        """Deletes a storage point."""
        if self.conn:
            self.cursor.execute("""
                DELETE FROM storage 
                WHERE storage_id = %s;
                """,
                (storageId,))
            self.conn.commit()