Class: PrlBackup::Backup
Constant Summary
Constants included
from PrlBackup
VERSION
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from PrlBackup
conditionally_run, logger, run
Constructor Details
#initialize(properties) ⇒ Backup
Returns a new instance of Backup.
42
43
44
|
# File 'lib/prlbackup/backup.rb', line 42
def initialize(properties)
@properties = properties
end
|
Instance Attribute Details
#properties ⇒ Object
Returns the value of attribute properties.
40
41
42
|
# File 'lib/prlbackup/backup.rb', line 40
def properties
@properties
end
|
Class Method Details
.all(uuid) ⇒ Object
7
8
9
|
# File 'lib/prlbackup/backup.rb', line 7
def all(uuid)
backup_list(uuid).split("\n").map { |b| create(b) }.compact.sort
end
|
.backup_list(uuid) ⇒ Object
11
12
13
|
# File 'lib/prlbackup/backup.rb', line 11
def backup_list(uuid)
run('prlctl', 'backup-list', uuid)
end
|
.create(line) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/prlbackup/backup.rb', line 15
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
|
.to_s ⇒ Object
32
33
34
|
# File 'lib/prlbackup/backup.rb', line 32
def to_s
'Backup'
end
|
Instance Method Details
#<=>(other) ⇒ Object
62
63
64
|
# File 'lib/prlbackup/backup.rb', line 62
def <=>(other)
time <=> other.time
end
|
#delete ⇒ Object
58
59
60
|
# File 'lib/prlbackup/backup.rb', line 58
def delete
conditionally_run('prlctl', 'backup-delete', '--tag', uuid)
end
|
#full? ⇒ Boolean
54
55
56
|
# File 'lib/prlbackup/backup.rb', line 54
def full?
properties[:type] == 'f'
end
|
#time ⇒ Object
50
51
52
|
# File 'lib/prlbackup/backup.rb', line 50
def time
DateTime.strptime(properties[:time], '%m/%d/%Y %H:%M:%S')
end
|
#to_s ⇒ Object
67
68
69
70
71
|
# File 'lib/prlbackup/backup.rb', line 67
def to_s
"#{self.class.to_s}: #{time.strftime('%Y-%m-%d %H:%M:%S')}"
rescue ArgumentError
"#{self.class.to_s}: Unknown"
end
|
#uuid ⇒ Object
46
47
48
|
# File 'lib/prlbackup/backup.rb', line 46
def uuid
properties[:uuid]
end
|