Class: Rudy::MetaData::Backup
- Inherits:
-
Storable
- Object
- Storable
- Rudy::MetaData::Backup
show all
- Includes:
- ObjectBase
- Defined in:
- lib/rudy/metadata/backup.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ObjectBase
#==, #destroy, #initialize, #inspect, #liner_note, #refresh, #save
Methods included from Huxtable
change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Class Method Details
90
91
92
93
|
# File 'lib/rudy/metadata/backup.rb', line 90
def Backup.format_timestamp(dat)
mon, day, hour, min, sec = [dat.mon, dat.day, dat.hour, dat.min, dat.sec].collect { |v| v.to_s.rjust(2, "0") }
[dat.year, mon, day, Rudy::DELIM, hour, min, Rudy::DELIM, sec].join
end
|
Instance Method Details
#create(volume = nil) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/rudy/metadata/backup.rb', line 81
def create(volume=nil)
volume ||= @volume
vol = @rsnap.create(volume)
@awsid = vol.awsid
self.save
self
end
|
#disk ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/rudy/metadata/backup.rb', line 72
def disk
rdisk = Rudy::Disks.new
disk = Rudy::MetaData::Disk.new(@path, nil, nil, @position)
disk.region, disk.zone = @region, @zone
disk.environment, disk.role, disk.position = @environment, @role, @position
diskobj = rdisk.get(disk.name)
diskobj || disk
end
|
#init(volume = nil, path = nil, position = nil) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rudy/metadata/backup.rb', line 28
def init(volume=nil, path=nil, position=nil)
@volume= volume
@path = path
@rtype = 'back'
@region = @@global.region
@zone = @@global.zone
@environment = @@global.environment
@role = @@global.role
@position = position || @@global.position
now = Time.now.utc
datetime = Backup.format_timestamp(now).split(Rudy::DELIM)
@created = now.to_i
@date, @time, @second = datetime
postprocess
end
|
#name ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/rudy/metadata/backup.rb', line 49
def name
sep=File::SEPARATOR
dirs = @path.split sep if @path && !@path.empty?
dirs.shift while dirs && (dirs[0].nil? || dirs[0].empty?)
args = [dirs, @date, @time, @second].flatten
super("back", @zone, @environment, @role, @position, *args)
end
|
#nice_time ⇒ Object
57
58
59
60
61
62
|
# File 'lib/rudy/metadata/backup.rb', line 57
def nice_time
return "" unless @date && @time
t = @date.scan(/(\d\d\d\d)(\d\d)(\d\d)/).join('-')
t << " " << @time.scan(/(\d\d)(\d\d)/).join(':')
t
end
|
#to_query(more = [], less = []) ⇒ Object
95
96
97
|
# File 'lib/rudy/metadata/backup.rb', line 95
def to_query(more=[], less=[])
query = super([:path, :date, :time, :second, *more], less)
end
|
#to_s(*args) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/rudy/metadata/backup.rb', line 64
def to_s(*args)
str = ""
field_names.each do |key|
str << sprintf(" %22s: %s#{$/}", key, self.send(key.to_sym))
end
str
end
|
#to_select(more = [], less = []) ⇒ Object
99
100
101
|
# File 'lib/rudy/metadata/backup.rb', line 99
def to_select(more=[], less=[])
query = super([:path, :date, :time, :second, *more], less)
end
|
#valid? ⇒ Boolean
Does this disk have enough info to be saved or used? The test is based on the same criteria for building SimpleDB queries.
106
107
108
109
|
# File 'lib/rudy/metadata/backup.rb', line 106
def valid?
criteria = build_criteria([:path]).flatten
criteria.size == criteria.compact.size
end
|