Class: Braavos::Storage::S3
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from StorageBase
#find_node_id, #get_cluster, #list_backups, #verify_cluster
Constructor Details
#initialize ⇒ S3
Returns a new instance of S3.
5
6
7
|
# File 'lib/braavos/storage/s3.rb', line 5
def initialize
@s3 = AWS::S3.new
end
|
Instance Attribute Details
#s3 ⇒ Object
Returns the value of attribute s3.
3
4
5
|
# File 'lib/braavos/storage/s3.rb', line 3
def s3
@s3
end
|
Instance Method Details
#clear_result(location) ⇒ Object
29
30
31
32
|
# File 'lib/braavos/storage/s3.rb', line 29
def clear_result(location)
path = File.join(location, "_FAILED")
s3.buckets[Braavos.config.bucket_name].objects[path].delete
end
|
#has_success?(location) ⇒ Boolean
23
24
25
26
27
|
# File 'lib/braavos/storage/s3.rb', line 23
def has_success?(location)
path = File.join(location, "_COMPLETED")
list_dir(location).size > 0 &&
s3.buckets[Braavos.config.bucket_name].objects[path].exists?
end
|
#list_dir(location) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/braavos/storage/s3.rb', line 13
def list_dir(location)
Braavos.logger.debug("S3 list_dir: #{Braavos.config.bucket_name}/#{location}")
listing = s3.buckets[Braavos.config.bucket_name].objects.with_prefix("#{location}/").inject({}) do |h,i|
h[i.key] = 0 if not i.key.end_with?('_$folder$') h
end
Braavos.logger.debug("\t#{listing}")
listing
end
|
#load_file(location) ⇒ Object
9
10
11
|
# File 'lib/braavos/storage/s3.rb', line 9
def load_file(location)
s3.buckets[Braavos.config.bucket_name].objects[location].read
end
|
#script_path(location) ⇒ Object
34
35
36
|
# File 'lib/braavos/storage/s3.rb', line 34
def script_path(location)
File.join(Braavos.config.bucket_name, location)
end
|
#write_file(location, contents) ⇒ Object
38
39
40
|
# File 'lib/braavos/storage/s3.rb', line 38
def write_file(location, contents)
s3.buckets[Braavos.config.bucket_name].objects[location].write(contents)
end
|