storazzo 0.2.1 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Makefile +10 -2
- data/README.md +1 -1
- data/VERSION +1 -1
- data/bin/ricdisk-magic +39 -12
- data/lib/storazzo/colors.rb +6 -1
- data/lib/storazzo/common.rb +19 -4
- data/lib/storazzo/hashify.rb +29 -16
- data/lib/storazzo/main.rb +3 -3
- data/lib/storazzo/media/README.md +14 -0
- data/lib/storazzo/media/abstract_ric_disk.rb +106 -0
- data/lib/storazzo/media/gcs_bucket.rb +20 -0
- data/lib/storazzo/media/local_folder.rb +50 -0
- data/lib/storazzo/media/mount_point.rb +5 -0
- data/lib/storazzo/ric_disk.rb +103 -47
- data/lib/storazzo/ric_disk_config.rb +154 -34
- data/lib/storazzo/ric_disk_config_example.rb +9 -0
- data/lib/storazzo/ric_disk_sample_config.rb +31 -0
- data/lib/storazzo/ric_disk_statsfile.rb +15 -2
- data/lib/storazzo/ric_disk_ugly.rb +1 -1
- data/lib/storazzo/translator.rb +13 -13
- data/lib/storazzo/version.rb +6 -0
- data/lib/storazzo.rb +13 -4
- data/test/test_gcs_bucket.rb +58 -0
- data/test/test_local_folder.rb +65 -0
- data/test/test_ric_disk_config.rb +40 -0
- data/test/test_ric_disk_stats_file.rb +36 -0
- data/test/test_storazzo.rb +29 -29
- metadata +18 -3
data/lib/storazzo/ric_disk.rb
CHANGED
@@ -1,27 +1,33 @@
|
|
1
1
|
# A RicDisk wraps a local mount/disk/folder
|
2
2
|
# it's considered interesting if there's a ".ricdisk/.ricdisk"
|
3
3
|
|
4
|
+
require 'digest'
|
5
|
+
|
4
6
|
module Storazzo
|
5
7
|
class Storazzo::RicDisk
|
6
8
|
|
7
9
|
include Hashify
|
10
|
+
include Storazzo::Common
|
8
11
|
extend Storazzo::Colors
|
9
12
|
|
10
13
|
|
11
14
|
## Instance variables
|
12
15
|
|
13
16
|
# in order of finding, so the first will be the one we actually READ and use. I could looknat the date but cmon...
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
# These are the files I do accept.
|
18
|
+
ConfigFiles = %W{ ricdisk.yaml .ricdisk }
|
19
|
+
RicdiskVersion = '2.0'
|
20
|
+
DefaultGemfileTestDiskFolder = Storazzo.root + "/var/test/disks/" # was: @@default_gemfile_test_disks_folder
|
17
21
|
# Immutable
|
18
|
-
|
22
|
+
DefaultMediaFolders = %w{
|
19
23
|
/Volumes/
|
20
24
|
/mnt/
|
21
|
-
}.append(
|
25
|
+
}.append(DefaultGemfileTestDiskFolder ).append("/media/#{ENV["USER"]}/" )
|
22
26
|
|
23
27
|
# # todo substitute with protobuf..
|
24
|
-
attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path,
|
28
|
+
attr_accessor :name, :description, :ricdisk_file,:ricdisk_file_full, :local_mountpoint, :wr, :path,
|
29
|
+
:ricdisk_file_empty, :size, :active_dirs, :ricdisk_version,
|
30
|
+
:unique_hash # new 202207
|
25
31
|
|
26
32
|
|
27
33
|
################################
|
@@ -30,36 +36,41 @@ module Storazzo
|
|
30
36
|
|
31
37
|
|
32
38
|
def initialize(path, opts={})
|
33
|
-
|
34
|
-
@local_mountpoint = path
|
35
|
-
@
|
36
|
-
@
|
37
|
-
|
38
|
-
@ricdisk_file = RicDisk.get_ricdisk_file(path)
|
39
|
+
deb "RicDisk initialize.. path=#{path}"
|
40
|
+
# @local_mountpoint = path
|
41
|
+
@local_mountpoint = File.expand_path(path)
|
42
|
+
@description = "This is an automated RicDisk description from v.#{RicdiskVersion}. Created on #{Time.now}'"
|
43
|
+
@ricdisk_version = RicdiskVersion
|
44
|
+
@ricdisk_file = compute_ricdisk_file() # Storazzo::RicDisk.get_ricdisk_file(path)
|
45
|
+
@ricdisk_file_full = "#{@local_mountpoint}/#{@ricdisk_file}"
|
39
46
|
@ricdisk_file_empty = ricdisk_file_empty?
|
40
47
|
@label = path.split("/").last
|
41
48
|
@name = path.split("/").last
|
42
49
|
#@wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
|
50
|
+
#@wr = writeable?
|
43
51
|
@tags = ['ricdisk', 'storazzo']
|
44
52
|
@size = `du -s '#{path}'`.split(/\s/)[0] # self.size
|
45
|
-
|
53
|
+
@unique_hash = "MD5::" + Digest::MD5.hexdigest(File.expand_path(path)) # hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
|
54
|
+
@computation_hostname = Socket.gethostname
|
46
55
|
# @config = RicDiskConfig.instance.get_config
|
47
56
|
# #puts @config if @config
|
48
57
|
# find_info_from_mount(path)
|
58
|
+
deb "RicDisk initialize. to_s: #{self}"
|
49
59
|
# find_info_from_df()
|
50
60
|
end
|
51
61
|
|
52
62
|
def ricdisk_file_empty?()
|
53
|
-
File.empty?(
|
63
|
+
# File.empty?("#{local_mountpoint}/.ricdisk.yaml")
|
64
|
+
File.empty?(compute_ricdisk_file) # was (get_ricdisk_file)
|
54
65
|
end
|
55
66
|
|
56
67
|
def ok_dir?
|
57
|
-
not
|
68
|
+
not ricdisk_file.nil?
|
58
69
|
end
|
59
70
|
|
60
71
|
|
61
72
|
def analyze_local_system()
|
62
|
-
puts
|
73
|
+
puts "TODO This should analyzze the WHOLE system. TODO(ricc): move to another object which has to do with the system/computer."
|
63
74
|
puts "1. Interesting Mounts: #{green interesting_mount_points}"
|
64
75
|
puts "2. Sbrodoling everything: :TODO"
|
65
76
|
# find_info_from_mount(path)
|
@@ -71,7 +82,7 @@ module Storazzo
|
|
71
82
|
end
|
72
83
|
|
73
84
|
def to_s
|
74
|
-
"RicDisk(paz=#{path},
|
85
|
+
"RicDisk(paz=#{path}, r/w=#{writeable?}, size=#{size}B, f=#{ricdisk_file}, v#{ricdisk_version})"
|
75
86
|
end
|
76
87
|
|
77
88
|
# could take long..
|
@@ -80,7 +91,13 @@ module Storazzo
|
|
80
91
|
# end
|
81
92
|
|
82
93
|
def writeable?()
|
83
|
-
|
94
|
+
return @wr unless @wr.nil?
|
95
|
+
# Otherwise I can do an EXPENSIVE calculation
|
96
|
+
deb "TODO(ricc): Do expensive caluylation if this FS is writeable: #{path}"
|
97
|
+
wr = File.writable?(ricdisk_file)
|
98
|
+
wr
|
99
|
+
#:boh_todo_fix_me_and_compute
|
100
|
+
#false
|
84
101
|
end
|
85
102
|
|
86
103
|
################################
|
@@ -90,19 +107,20 @@ module Storazzo
|
|
90
107
|
|
91
108
|
# All places where to find for something :)
|
92
109
|
def self.default_media_folders
|
93
|
-
DEFAULT_MEDIA_FOLDERS
|
110
|
+
DefaultMediaFolders # was DEFAULT_MEDIA_FOLDERS
|
94
111
|
end
|
95
112
|
|
96
113
|
|
97
114
|
def self.test # _localgem_disks
|
98
|
-
d = RicDisk.new(
|
115
|
+
d = RicDisk.new( DefaultGemfileTestDiskFolder)
|
99
116
|
puts (d)
|
100
117
|
puts "do something with it: #{d}"
|
101
118
|
#d.find_active_dirs()
|
102
119
|
end
|
103
120
|
|
104
|
-
|
105
|
-
|
121
|
+
def absolute_path
|
122
|
+
@local_mountpoint + "/" + @ricdisk_file
|
123
|
+
end
|
106
124
|
|
107
125
|
|
108
126
|
def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
|
@@ -121,11 +139,12 @@ module Storazzo
|
|
121
139
|
deb "Dir doesnt exist, skipping: #{dir}"
|
122
140
|
next
|
123
141
|
end
|
124
|
-
Dir.chdir(dir)
|
142
|
+
Dir.chdir(dir)
|
125
143
|
x = Dir.glob('*').select {|f| File.directory? f}
|
126
144
|
subdirs = x.map{|subdir| "#{dir}#{subdir}"}
|
127
145
|
subdirs.each{|subdir|
|
128
|
-
|
146
|
+
puts "DEB Subdir: #{subdir}"
|
147
|
+
puts `ls -al "#{subdir}"`
|
129
148
|
active_dirs << subdir if ok_dir? # self.ok_dir?(subdir)
|
130
149
|
}
|
131
150
|
#puts(white x)
|
@@ -138,12 +157,33 @@ module Storazzo
|
|
138
157
|
end
|
139
158
|
end
|
140
159
|
|
160
|
+
def compute_ricdisk_file()
|
161
|
+
unless @ricdisk_file.nil?
|
162
|
+
deb "[CACHE HIT] ricdisk_file (didnt have to recompute it - yay!)"
|
163
|
+
return @ricdisk_file
|
164
|
+
end
|
165
|
+
warn "RICC_WARNING This requires cmputation I wanna do it almost once"
|
166
|
+
ConfigFiles.each do |papable_config_filename|
|
167
|
+
#return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
168
|
+
#return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
169
|
+
return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
170
|
+
end
|
171
|
+
return nil
|
172
|
+
end
|
173
|
+
|
141
174
|
|
142
175
|
# new
|
143
|
-
def self.
|
144
|
-
|
145
|
-
|
146
|
-
|
176
|
+
def self.get_ricdisk_file_obsolete(path)
|
177
|
+
if @ricdisk_file
|
178
|
+
puts "[CACHE HIT] ricdisk_file"
|
179
|
+
return @ricdisk_file
|
180
|
+
end
|
181
|
+
puts "RICC_WARNING This requires cmputation I wanna do it almost once"
|
182
|
+
ConfigFiles.each do |papable_config_filename|
|
183
|
+
#return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
184
|
+
#return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
185
|
+
return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
186
|
+
end
|
147
187
|
return nil
|
148
188
|
end
|
149
189
|
|
@@ -166,35 +206,51 @@ module Storazzo
|
|
166
206
|
|
167
207
|
|
168
208
|
# FORMER SBRODOLA, now write_config_yaml_to_disk
|
169
|
-
def self.write_config_yaml_to_disk(subdir) # sbrodola_ricdisk(subdir)
|
209
|
+
#def self.write_config_yaml_to_disk(subdir, opts={}) # sbrodola_ricdisk(subdir)
|
210
|
+
def write_config_yaml_to_disk(subdir, opts={}) # sbrodola_ricdisk(subdir)
|
170
211
|
# given a path, if .ricdisk exists i do stuff with it..
|
171
212
|
disk_info = nil
|
172
|
-
unless self.ok_dir?(subdir)
|
173
|
-
puts("Nothing for me here: '#{subdir}'. Existing")
|
213
|
+
unless ok_dir? # self.ok_dir?(subdir)
|
214
|
+
puts("[write_config_yaml_to_disk] Nothing for me here: '#{subdir}'. Existing")
|
174
215
|
return
|
175
216
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
deb("Interesting2. Empty file! TODO write YAML with it.")
|
182
|
-
disk_info = RicDisk.new(subdir, '.ricdisk.yaml')
|
183
|
-
puts(yellow disk_info.to_yaml)
|
217
|
+
ConfigFiles.each do |papable_configfile_name|
|
218
|
+
if File.exists?( "#{subdir}/#{papable_configfile_name}") and File.empty?( "#{subdir}/#{papable_configfile_name}")
|
219
|
+
deb("Interesting. Empty file '#{papable_configfile_name}'! Now I write YAML with it.")
|
220
|
+
disk_info = RicDisk.new(subdir, papable_configfile_name)
|
221
|
+
end
|
184
222
|
end
|
185
|
-
if
|
186
|
-
|
187
|
-
|
188
|
-
|
223
|
+
# if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
|
224
|
+
# deb("Interesting1. Empty file! Now I write YAML with it.")
|
225
|
+
# disk_info = RicDisk.new(subdir, '.ricdisk')
|
226
|
+
# end
|
227
|
+
# if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
|
228
|
+
# deb("Interesting2. Empty file! TODO write YAML with it.")
|
229
|
+
# disk_info = RicDisk.new(subdir, '.ricdisk.yaml')
|
230
|
+
# puts(yellow disk_info.to_yaml)
|
231
|
+
# end
|
232
|
+
if disk_info.is_a?(RicDisk)
|
233
|
+
deb("disk_info.class: #{disk_info.class}")
|
234
|
+
if File.empty?(disk_info.absolute_path) and (disk_info.wr)
|
235
|
+
puts(green("yay, we can now write the file '#{disk_info.absolute_path}' (which is R/W, I just checked!) with proper YAML content.."))
|
236
|
+
ret = File.write(disk_info.absolute_path, disk_info.to_yaml)
|
189
237
|
puts("Written file! ret=#{ret}")
|
190
238
|
else
|
191
|
-
puts(red("
|
192
|
-
puts("File size: #{File.size(disk_info.
|
239
|
+
puts(red("Something not right here: either file is NOT empty or disk is NOT writeable.. #{File.empty?(disk_info.absolute_path)}"))
|
240
|
+
puts("File size: #{File.size(disk_info.absolute_path)}")
|
241
|
+
puts(disk_info.to_s)
|
242
|
+
puts(disk_info.obj_to_hash)
|
243
|
+
puts(disk_info.obj_to_yaml)
|
193
244
|
end
|
245
|
+
else
|
246
|
+
puts "[write_config_yaml_to_disk] No DiskInfo found across #{ConfigFiles}. I leave this function empty-handed."
|
194
247
|
end
|
195
248
|
if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
|
196
|
-
puts("Config File found with old-style name: '#{subdir}/.ricdisk' !")
|
197
|
-
|
249
|
+
puts("Config File found with old-style name: '#{subdir}/.ricdisk' ! Please move it to .ricdisk.yaml!")
|
250
|
+
puts(white `cat "#{subdir}/.ricdisk"`)
|
251
|
+
else
|
252
|
+
puts "WRITING NOW. disk_info.obj_to_yaml .. to #{compute_ricdisk_file}"
|
253
|
+
File.open(ricdisk_file_full, 'w').write(disk_info.obj_to_yaml)
|
198
254
|
end
|
199
255
|
end
|
200
256
|
|
@@ -1,49 +1,99 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
+
=begin
|
5
|
+
This is a singleton class. You call me this way..
|
6
|
+
You call me with:
|
7
|
+
|
8
|
+
Storazzo::RicDiskConfig.instance()
|
9
|
+
|
10
|
+
Note that being a Singleton, in Unit Tests it's hard to use the /etc/storazzo_config.sample.yaml instead
|
11
|
+
of the real one - yiikes. How do I fix it? Do I unsingleton it? :) Or do I create TWO singletons? :)
|
12
|
+
=end
|
13
|
+
|
4
14
|
module Storazzo
|
5
|
-
class Storazzo::
|
15
|
+
# class Storazzo::Blah
|
16
|
+
# end
|
17
|
+
|
18
|
+
class Storazzo::RicDiskConfig
|
6
19
|
include Singleton
|
7
20
|
include Storazzo::Common
|
8
21
|
include Storazzo::Colors
|
9
22
|
|
10
|
-
|
11
|
-
|
23
|
+
#@@default_config_location = "~/.storazzo.yaml"
|
24
|
+
DefaultConfigLocation = File.expand_path "~/.storazzo.yaml"
|
25
|
+
# @@default_config_locations = [
|
26
|
+
# "~/.storazzo.yaml" , # HOME
|
27
|
+
# "./.storazzo.yaml" , # LOCAL DIR
|
28
|
+
# ]
|
29
|
+
DefaultConfigLocations = [
|
30
|
+
File.expand_path("~/.storazzo.yaml") , # HOME
|
31
|
+
File.expand_path("./.storazzo.yaml") , # LOCAL DIR
|
32
|
+
]
|
33
|
+
#@@default_gem_location_for_tests
|
34
|
+
DefaultGemLocationForTests = File.expand_path('../../../', __FILE__) + "/etc/storazzo_config.sample.yaml"
|
35
|
+
|
36
|
+
attr_accessor :config, :config_file, :load_called
|
12
37
|
|
13
38
|
public
|
39
|
+
# Load from the first valid config.
|
14
40
|
def load(config_path=nil, opts={})
|
15
41
|
verbose = opts.fetch :verbose, false
|
16
42
|
|
17
43
|
puts "[VERBOSE] Storazzo::RicDiskConfig.load(): BEGIN " if verbose
|
18
44
|
# trying default location
|
19
|
-
|
20
|
-
|
21
|
-
|
45
|
+
raise "DefaultConfigLocation is not a string" unless DefaultConfigLocation.is_a?(String)
|
46
|
+
possible_locations = DefaultConfigLocations # [ @@default_config_location , "./.storazzo.yaml"]
|
47
|
+
puts "DEB possible_locations: #{possible_locations}"
|
48
|
+
if config_path.is_a?(String)
|
49
|
+
#possible_locations = [config_path] + possible_locations # .append()
|
50
|
+
possible_locations = possible_locations.unshift(config_path) # append to front
|
51
|
+
#OR: possible_locations.instert(0, config_path)
|
52
|
+
puts "[LOAD] possible_locations: #{possible_locations}" if verbose
|
22
53
|
end
|
23
54
|
puts "[VERBOSE] Searching these paths in order: #{possible_locations}" if verbose
|
55
|
+
bug "This is not always an array of sTRINGS."
|
56
|
+
raise "possible_locations is not an array" unless possible_locations.is_a?(Array)
|
24
57
|
possible_locations.each do |possible_path|
|
25
|
-
|
26
|
-
|
27
|
-
|
58
|
+
# ASSERT is a string
|
59
|
+
raise "possible_path is not a string" unless possible_path.is_a?(String)
|
60
|
+
deb "before buggy expand_path paz: '#{possible_path}''"
|
61
|
+
paz = File.expand_path(possible_path) rescue possible_path
|
62
|
+
raise "Not a string: #{paz}" unless paz.is_a?(String)
|
63
|
+
if File.exists?(paz)
|
28
64
|
@config_file = paz
|
29
65
|
@config = YAML.load(File.read paz) # YAML.load(File.read("file_path"))
|
66
|
+
|
67
|
+
unless (@config["kind"] == 'StorazzoConfig' rescue false)
|
68
|
+
puts white "RicDiskConfig.load(): Sorry this is wrong Config File. Kind=#{@config["kind"] rescue $!}"
|
69
|
+
next
|
70
|
+
end
|
71
|
+
#
|
30
72
|
#pp @config if verbose
|
31
|
-
|
73
|
+
config_ver = @config["apiVersion"]
|
32
74
|
#puts @config[:ConfigVersion]
|
33
|
-
puts "Storazzo::RicDiskConfig v#{config_ver} parsed correctly"
|
34
|
-
puts "RicDiskConfig.to_s: #{self}" if verbose
|
75
|
+
puts white("OK. Storazzo::RicDiskConfig v'#{config_ver}' parsed correctly")
|
76
|
+
puts "[VERBOSE] RicDiskConfig.to_s: #{self}" if verbose
|
77
|
+
@load_called = true
|
35
78
|
return self.config
|
36
79
|
end
|
37
80
|
end
|
81
|
+
@load_called = true
|
38
82
|
# only get here if nothing is found
|
39
83
|
raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
|
40
|
-
|
41
|
-
|
84
|
+
end
|
85
|
+
|
86
|
+
# Obsolete, call another class instead.
|
87
|
+
def load_sample_version
|
88
|
+
# puts("Warning! We're destroying the world here. We're taking a Singletong and changing the way it behaves by moving the config file by under her feet. Don't be mad at me if this misbehaves. You saw it coming, my friends. This is why I would NEVER hire you as a Software Developer in my Company.")
|
89
|
+
raise "DEPRECATED! USE SampleRicDiskConfig.load() instead!"
|
90
|
+
# load(DefaultGemLocationForTests, :verbose => true )
|
42
91
|
end
|
43
92
|
|
44
93
|
def config_ver
|
45
|
-
|
46
|
-
@config['
|
94
|
+
raise "I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?" unless @config
|
95
|
+
@config['apiVersion'] # rescue :StillUnknown
|
96
|
+
#config['ConfigVersion']
|
47
97
|
end
|
48
98
|
def config_default_folder
|
49
99
|
#self.
|
@@ -51,8 +101,10 @@ public
|
|
51
101
|
end
|
52
102
|
|
53
103
|
def to_s
|
54
|
-
size =
|
55
|
-
|
104
|
+
size = File.size(@config_file) rescue -1
|
105
|
+
#puts yellow "DEB: #{@config["apiVersion"]}"
|
106
|
+
#"RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
107
|
+
"POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
56
108
|
end
|
57
109
|
|
58
110
|
def get_config(opts={})
|
@@ -64,31 +116,99 @@ public
|
|
64
116
|
Storazzo.root + "/etc/storazzo_config.sample.yaml"
|
65
117
|
end
|
66
118
|
|
119
|
+
|
120
|
+
# returns all folders from file which are Directories
|
121
|
+
# This method is FLAKY! Sometimes gives error.
|
122
|
+
# LocalFolderTest#test_show_all_shouldnt_fail_and_should_return_a_non_empty_array:
|
123
|
+
# TypeError: no implicit conversion of Hash into String
|
124
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `expand_path'
|
125
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `block in load'
|
126
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `each'
|
127
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `load'
|
128
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:83:in `get_config'
|
129
|
+
# /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:95:in `get_local_folders'
|
130
|
+
def get_local_folders
|
131
|
+
config = get_config
|
132
|
+
#puts config['Config']['AdditionalMountDirs']
|
133
|
+
config['Config']['AdditionalMountDirs'].map{|folder|
|
134
|
+
File.expand_path(folder) rescue folder # TypeError: no implicit conversion of Hash into String
|
135
|
+
}.filter{|f| File.directory?(f)}
|
136
|
+
end
|
137
|
+
|
138
|
+
def get_bucket_paths
|
139
|
+
get_config['Config']['Backends']['GoogleCloudStorage']['BucketPaths'].map{|complex_gcs_struct| complex_gcs_struct['path']}
|
140
|
+
end
|
141
|
+
|
67
142
|
# UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
|
68
143
|
def iterate_through_file_list_for_disks(files_list=[])
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
144
|
+
# I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
|
145
|
+
# if files_list == [] # or files_list.nil? # empty -> ALL
|
146
|
+
# deb "iterate_through_file_list_for_disks(): no args provided"
|
147
|
+
# dirs = RicDisk.find_active_dirs()
|
148
|
+
# puts "DEB find_active_dirs: #{green dirs}"
|
149
|
+
# dirs.each {|dir|
|
150
|
+
# RicDisk.write_config_yaml_to_disk(dir)
|
151
|
+
# RicDisk.calculate_stats_files(dir) # dir is inutile
|
152
|
+
# } # TODO refactor in option sbrodola_afterwards=true. :)
|
153
|
+
# else
|
78
154
|
deb "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)"
|
79
|
-
dirs = RicDisk.find_active_dirs()
|
155
|
+
#dirs = RicDisk.find_active_dirs()
|
80
156
|
files_list.each do |dir|
|
81
157
|
dir = File.expand_path(dir)
|
82
|
-
if
|
83
|
-
|
84
|
-
|
158
|
+
if File.directory?(dir)
|
159
|
+
#if dirs.include?(dir)
|
160
|
+
deb "iterate_through_file_list_for_disks() Legit dir: #{green dir}"
|
161
|
+
rd = RicDisk.new(dir)
|
162
|
+
rd.write_config_yaml_to_disk(dir)
|
163
|
+
#RicDisk.write_config_yaml_to_disk(dir)
|
85
164
|
RicDisk.calculate_stats_files(dir) # dir is inutile
|
86
165
|
else
|
87
|
-
deb "
|
166
|
+
deb red("Doesnt seem a legit dir to me: #{dir}")
|
167
|
+
# deb "Figghiu ri buttana: doesnt exist #{red dir}"
|
88
168
|
end
|
89
169
|
end
|
90
|
-
end
|
170
|
+
#end
|
91
171
|
end #/iterate_through_file_list_for_disks
|
92
172
|
|
173
|
+
|
174
|
+
def self.get_config
|
175
|
+
self.instance.get_config
|
176
|
+
end
|
177
|
+
end # class Storazzo::RicDiskConfig
|
178
|
+
|
179
|
+
# class Storazzo::SampleRicDiskConfig < Storazzo::RicDiskConfig
|
180
|
+
# include Singleton
|
181
|
+
|
182
|
+
# def load # _sample_version
|
183
|
+
# puts white("Wheew! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
|
184
|
+
# super.load(DefaultGemLocationForTests, :verbose => true )
|
185
|
+
# end
|
186
|
+
|
187
|
+
# end
|
188
|
+
|
189
|
+
puts "[REMOVEME]1 Storazzo::RicDiskConfig was read"
|
190
|
+
|
191
|
+
#end # module Storazzo
|
192
|
+
|
193
|
+
puts "[REMOVEME]2 Storazzo::RicDiskConfig was read"
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
#module Storazzo
|
198
|
+
|
199
|
+
# ric_disk_sample_config
|
200
|
+
#class Pincopallo # Storazzo::Blah #RicDiskSampleConfig # < Storazzo::RicDiskConfig
|
201
|
+
class Storazzo::Pincopallo # RicDiskSampleConfig
|
202
|
+
|
203
|
+
#include Singleton
|
204
|
+
# public
|
205
|
+
# def load # _sample_version
|
206
|
+
# puts white("Wheew! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
|
207
|
+
# super.load(DefaultGemLocationForTests, :verbose => true )
|
208
|
+
# end
|
93
209
|
end
|
94
|
-
|
210
|
+
|
211
|
+
puts "[REMOVEME]1 Storazzo::RicDiskSampleConfig was read"
|
212
|
+
end # module Storazzo
|
213
|
+
|
214
|
+
puts "[REMOVEME]2 Storazzo::RicDiskSampleConfig was read"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
require_relative "./common"
|
5
|
+
require_relative "./ric_disk_config"
|
6
|
+
|
7
|
+
=begin
|
8
|
+
This is a singleton class. You call me this way..
|
9
|
+
You call me with:
|
10
|
+
|
11
|
+
Storazzo::RicDiskSampleConfig.instance()
|
12
|
+
|
13
|
+
=end
|
14
|
+
|
15
|
+
module Storazzo
|
16
|
+
|
17
|
+
class Storazzo::RicDiskSampleConfig < Storazzo::RicDiskConfig
|
18
|
+
#include Storazzo::Common
|
19
|
+
|
20
|
+
include Singleton
|
21
|
+
public
|
22
|
+
def load # _sample_version
|
23
|
+
puts white("Wheew! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
|
24
|
+
super.load(DefaultGemLocationForTests, :verbose => true )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#puts "[REMOVEME]1 Storazzo::RicDiskSampleConfig was read"
|
29
|
+
end # module Storazzo
|
30
|
+
|
31
|
+
#puts "[REMOVEME]2 Storazzo::RicDiskSampleConfig was read"
|
@@ -2,9 +2,22 @@
|
|
2
2
|
# directly in the disk: /mount/
|
3
3
|
module Storazzo
|
4
4
|
class Storazzo::RicDiskStatsFile
|
5
|
-
|
5
|
+
# Please keep these two in sync, until you fix them and DRY the behaviour.
|
6
|
+
#@@default_name
|
7
|
+
DefaultName = "ricdisk_stats_v11.rds" # => RicDiskStatsFile
|
8
|
+
Version = "1.1" # @@version
|
6
9
|
|
10
|
+
# AttrAccessor for class - thanks StackOverflow from Android since Im in roaming :)
|
11
|
+
class << self
|
12
|
+
attr_accessor :default_name, :version
|
13
|
+
end
|
7
14
|
|
8
|
-
|
15
|
+
public
|
16
|
+
def self.default_name
|
17
|
+
DefaultName
|
18
|
+
end
|
19
|
+
def self.version
|
20
|
+
Version
|
21
|
+
end
|
9
22
|
end
|
10
23
|
end
|
data/lib/storazzo/translator.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# todo remove
|
2
|
-
class Storazzo::Translator
|
2
|
+
# class Storazzo::Translator
|
3
3
|
|
4
|
-
def initialize(language)
|
5
|
-
|
6
|
-
|
4
|
+
# def initialize(language)
|
5
|
+
# @language = language
|
6
|
+
# end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
# def hi
|
9
|
+
# case @language
|
10
|
+
# when "spanish"
|
11
|
+
# "hola mundo"
|
12
|
+
# else
|
13
|
+
# "hello world"
|
14
|
+
# end
|
15
|
+
# end
|
16
16
|
|
17
|
-
end
|
17
|
+
# end
|
data/lib/storazzo/version.rb
CHANGED