#NEWLINE# def delete_volume( target , stop = True ) : #NEWLINE# #INDENT# '\n    Deletes a gluster volume\n\n    target\n        Volume to delete\n\n    stop\n        Stop volume before delete if it is started, True by default\n    ' #NEWLINE# volinfo = info ( ) #NEWLINE# if ( target not in volinfo ) : #NEWLINE# #INDENT# log . error ( 'Cannot delete non-existing volume {0}' . format ( target ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# running = ( volinfo [ target ] [ 'status' ] == '1' ) #NEWLINE# if ( ( not stop ) and running ) : #NEWLINE# #INDENT# log . error ( 'Volume {0} must be stopped before deletion' . format ( target ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# if running : #NEWLINE# #INDENT# if ( not stop_volume ( running , force = True ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# cmd = 'volume delete {0}' . format ( target ) #NEWLINE# return _gluster ( cmd )