lib/zfs_mgmt.rb in zfs_mgmt-0.3.0 vs lib/zfs_mgmt.rb in zfs_mgmt-0.3.1
- old
+ new
@@ -228,14 +228,14 @@
$logger.info("no snapshots marked as saved by policy for #{zfs}")
next
end
# print a table of saved snapshots with the reasons it is being saved
table = Text::Table.new
- table.head = ['snap','creation','hourly','daily','weekly','monthly','yearly']
+ table.head = [zfs,'creation','hourly','daily','weekly','monthly','yearly']
table.rows = []
saved_snaps.sort { |a,b| snaps[b]['creation'] <=> snaps[a]['creation'] }.each do |snap|
- table.rows << [snap,local_epoch_to_datetime(snaps[snap]['creation'])] + find_saved_reason(saved,snap)
+ table.rows << [snap.split('@')[1],local_epoch_to_datetime(snaps[snap]['creation'])] + find_saved_reason(saved,snap)
end
print table.to_s
end
end
def self.snapshot_destroy(noop: false, verbopt: false, debugopt: false, filter: '.+')
@@ -261,26 +261,29 @@
com_base = "#{com_base}v"
end
deleteme.reverse! # oldest first for removal
deleteme.each do |snap_name|
$logger.debug("delete: #{snap_name} #{local_epoch_to_datetime(snaps[snap_name]['creation']).strftime('%F %T')}")
+ com = "#{com_base} #{snap_name}"
+ $logger.info(com)
+ system(com)
end
- while deleteme.length > 0
- for i in 0..(deleteme.length - 1) do
- max = deleteme.length - 1 - i
- $logger.debug("attempting to remove snaps 0 through #{max} out of #{deleteme.length} snapshots")
- bigarg = "#{zfs}@#{deleteme[0..max].map { |s| s.split('@')[1] }.join(',')}"
- com = "#{com_base} #{bigarg}"
- $logger.debug("size of bigarg: #{bigarg.length} size of com: #{com.length}")
- if bigarg.length >= 131072 or com.length >= (2097152-10000)
- next
- end
- $logger.info(com)
- deleteme = deleteme - deleteme[0..max]
- system(com)
- break
- end
- end
+ # while deleteme.length > 0
+ # for i in 0..(deleteme.length - 1) do
+ # max = deleteme.length - 1 - i
+ # $logger.debug("attempting to remove snaps 0 through #{max} out of #{deleteme.length} snapshots")
+ # bigarg = "#{zfs}@#{deleteme[0..max].map { |s| s.split('@')[1] }.join(',')}"
+ # com = "#{com_base} #{bigarg}"
+ # $logger.debug("size of bigarg: #{bigarg.length} size of com: #{com.length}")
+ # if bigarg.length >= 131072 or com.length >= (2097152-10000)
+ # next
+ # end
+ # $logger.info(com)
+ # deleteme = deleteme - deleteme[0..max]
+ # system(com)
+ # break
+ # end
+ # end
end
end
# parse a policy string into a hash of integers
def self.policy_parser(str)
res = {}