Sha256: 36b7036186c92882fd6dad9686abd9f0b2ab7216e50da8e316a1557327310392
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module PrlBackup class Backup class << self include PrlBackup def all(uuid) backup_list(uuid).split("\n").map { |b| create(b) }.compact.sort end def backup_list(uuid) run('prlctl', 'backup-list', uuid) end def create(line) re = /^ (\{[0-9a-f-]+\}) # VM UUID \s+ (\{[0-9a-f-]+\}[\.\d]*) # Backup UUID \s+ (\S+) # Node \s+ ([\d\/]+\s[\d:]+) # Time \s+ ([fi]) # Type \s+ (\d+) # Size $/x new(:uuid => $2, :time => $4, :type => $5) if re.match(line) end end include PrlBackup include Comparable attr_reader :properties def initialize(properties) @properties = properties end def uuid properties[:uuid] end def time DateTime.parse(properties[:time]) end def full? properties[:type] == 'f' end def delete conditionally_run('prlctl', 'backup-delete', '--tag', uuid) end def <=>(other) time <=> other.time end def to_s "Backup: #{time.strftime('%Y-%m-%d %H:%M:%S')}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prlbackup-1.2.0 | lib/prlbackup/backup.rb |