#NEWLINE# def delete_snapshot( vm , name , key = 'uuid' ) : #NEWLINE# #INDENT# "\n    Delete snapshot of a vm\n\n    vm : string\n        vm to be targetted\n    name : string\n        snapshot name\n            The snapname must be 64 characters or less\n            and must only contain alphanumeric characters and\n            characters in the set [-_.:%] to comply with ZFS restrictions.\n    key : string [uuid|alias|hostname]\n        value type of 'vm' parameter\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' vmadm.delete_snapshot 186da9ab-7392-4f55-91a5-b8f1fe770543 baseline\n        salt '*' vmadm.delete_snapshot nacl baseline key=alias\n    " #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vmadm = _check_vmadm ( ) #NEWLINE# if ( key not in [ 'uuid' , 'alias' , 'hostname' ] ) : #NEWLINE# #INDENT# ret [ 'Error' ] = 'Key must be either uuid, alias or hostname' #NEWLINE# return ret #NEWLINE# #UNINDENT# vm = lookup ( '{0}={1}' . format ( key , vm ) , one = True ) #NEWLINE# if ( 'Error' in vmadm ) : #NEWLINE# #INDENT# return vm #NEWLINE# #UNINDENT# vmobj = get ( vm ) #NEWLINE# if ( 'datasets' in vmobj ) : #NEWLINE# #INDENT# ret [ 'Error' ] = 'VM cannot have datasets' #NEWLINE# return ret #NEWLINE# #UNINDENT# if ( vmobj [ 'brand' ] in [ 'kvm' ] ) : #NEWLINE# #INDENT# ret [ 'Error' ] = 'VM must be of type OS' #NEWLINE# return ret #NEWLINE# #UNINDENT# cmd = '{vmadm} delete-snapshot {uuid} {snapshot}' . format ( vmadm = vmadm , snapshot = name , uuid = vm ) #NEWLINE# res = __salt__ [ 'cmd.run_all' ] ( cmd ) #NEWLINE# retcode = res [ 'retcode' ] #NEWLINE# if ( retcode != 0 ) : #NEWLINE# #INDENT# ret [ 'Error' ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else _exit_status ( retcode ) ) #NEWLINE# return ret #NEWLINE# #UNINDENT# return True