#NEWLINE# def remove_snap( self , volume , name , ignore_errors = False , pool = None , force = False ) : #NEWLINE# #INDENT# 'Removes a snapshot from an RBD volume.\n\n        :volume: Name of RBD object\n        :name: Name of snapshot\n        :ignore_errors: whether or not to log warnings on failures\n        :pool: Name of pool\n        :force: Remove snapshot even if it is protected\n        ' #NEWLINE# with RBDVolumeProxy ( self , str ( volume ) , pool = pool ) as vol : #NEWLINE# #INDENT# if ( name in [ snap . get ( 'name' , '' ) for snap in vol . list_snaps ( ) ] ) : #NEWLINE# #INDENT# if vol . is_protected_snap ( name ) : #NEWLINE# #INDENT# if force : #NEWLINE# #INDENT# tpool . execute ( vol . unprotect_snap , name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ignore_errors ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'snapshot(%(name)s) on rbd image(%(img)s) is protected, skipping' ) , { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'img' : volume , #NEWLINE# #UNINDENT# } ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# LOG . debug ( 'removing snapshot(%(name)s) on rbd image(%(img)s)' , { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'img' : volume , #NEWLINE# #UNINDENT# } ) #NEWLINE# tpool . execute ( vol . remove_snap , name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ignore_errors ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'no snapshot(%(name)s) found on rbd image(%(img)s)' ) , { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'img' : volume , #NEWLINE# #UNINDENT# } )