storazzo 0.3.5 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/bin/stats-with-md5 +428 -0
- data/lib/storazzo/media/gcs_bucket.rb +4 -2
- data/lib/storazzo/media/local_folder.rb +2 -1
- data/lib/storazzo/ric_disk.rb +132 -64
- data/lib/storazzo/ric_disk_config.rb +50 -54
- data/lib/storazzo/ric_disk_sample_config.rb +12 -8
- data/lib/storazzo/ric_disk_ugly.rb +245 -245
- data/lib/storazzo.rb +2 -2
- data/storazzo.gemspec +4 -1
- data/test/test_gcs_bucket.rb +29 -17
- data/test/test_local_folder.rb +68 -12
- data/test/test_ric_disk_config.rb +3 -5
- data/test/test_storazzo.rb +9 -9
- metadata +4 -4
- data/lib/storazzo/ric_disk_config_example.rb +0 -9
- data/lib/storazzo/translator.rb +0 -17
data/lib/storazzo/ric_disk.rb
CHANGED
@@ -9,14 +9,20 @@ module Storazzo
|
|
9
9
|
include Hashify
|
10
10
|
include Storazzo::Common
|
11
11
|
extend Storazzo::Colors
|
12
|
+
require 'socket'
|
12
13
|
|
13
14
|
|
14
15
|
## Instance variables
|
15
16
|
|
16
17
|
# in order of finding, so the first will be the one we actually READ and use. I could looknat the date but cmon...
|
17
18
|
# These are the files I do accept.
|
18
|
-
ConfigFiles = %W{ ricdisk.yaml .ricdisk
|
19
|
-
|
19
|
+
ConfigFiles = %W{ ricdisk.yaml .ricdisk storazzo.yaml }
|
20
|
+
DefaultConfigFile = "storazzo.yaml" # .ricdisk }
|
21
|
+
RicdiskVersion = '2.1'
|
22
|
+
RicdiskHistory = [
|
23
|
+
'2022-07-29 2.1 Added timestamp',
|
24
|
+
'2022-07-28 2.0 Added tags, siz, unique_hash, computation_hostname, wr, ...',
|
25
|
+
]
|
20
26
|
DefaultGemfileTestDiskFolder = Storazzo.root + "/var/test/disks/" # was: @@default_gemfile_test_disks_folder
|
21
27
|
# Immutable
|
22
28
|
DefaultMediaFolders = %w{
|
@@ -25,7 +31,7 @@ module Storazzo
|
|
25
31
|
}.append(DefaultGemfileTestDiskFolder ).append("/media/#{ENV["USER"]}/" )
|
26
32
|
|
27
33
|
# # todo substitute with protobuf..
|
28
|
-
attr_accessor :name, :description, :ricdisk_file
|
34
|
+
attr_accessor :name, :description, :ricdisk_file, :ricdisk_file_full, :local_mountpoint, :wr, :path,
|
29
35
|
:ricdisk_file_empty, :size, :active_dirs, :ricdisk_version,
|
30
36
|
:unique_hash # new 202207
|
31
37
|
|
@@ -37,13 +43,11 @@ module Storazzo
|
|
37
43
|
|
38
44
|
def initialize(path, opts={})
|
39
45
|
deb "RicDisk initialize.. path=#{path}"
|
40
|
-
# @local_mountpoint = path
|
41
46
|
@local_mountpoint = File.expand_path(path)
|
42
47
|
@description = "This is an automated RicDisk description from v.#{RicdiskVersion}. Created on #{Time.now}'"
|
43
48
|
@ricdisk_version = RicdiskVersion
|
44
49
|
@ricdisk_file = compute_ricdisk_file() # Storazzo::RicDisk.get_ricdisk_file(path)
|
45
50
|
@ricdisk_file_full = "#{@local_mountpoint}/#{@ricdisk_file}"
|
46
|
-
@ricdisk_file_empty = ricdisk_file_empty?
|
47
51
|
@label = path.split("/").last
|
48
52
|
@name = path.split("/").last
|
49
53
|
#@wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
|
@@ -52,6 +56,10 @@ module Storazzo
|
|
52
56
|
@size = `du -s '#{path}'`.split(/\s/)[0] # self.size
|
53
57
|
@unique_hash = "MD5::" + Digest::MD5.hexdigest(File.expand_path(path)) # hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
|
54
58
|
@computation_hostname = Socket.gethostname
|
59
|
+
@created_at = Time.now
|
60
|
+
|
61
|
+
@ricdisk_file_empty = ricdisk_file_empty?
|
62
|
+
|
55
63
|
# @config = RicDiskConfig.instance.get_config
|
56
64
|
# #puts @config if @config
|
57
65
|
# find_info_from_mount(path)
|
@@ -61,7 +69,8 @@ module Storazzo
|
|
61
69
|
|
62
70
|
def ricdisk_file_empty?()
|
63
71
|
# File.empty?("#{local_mountpoint}/.ricdisk.yaml")
|
64
|
-
|
72
|
+
puts "compute_ricdisk_file: #{compute_ricdisk_file}"
|
73
|
+
File.empty?(compute_ricdisk_file.to_s) # was (get_ricdisk_file)
|
65
74
|
end
|
66
75
|
|
67
76
|
def ok_dir?
|
@@ -93,9 +102,11 @@ module Storazzo
|
|
93
102
|
def writeable?()
|
94
103
|
return @wr unless @wr.nil?
|
95
104
|
# Otherwise I can do an EXPENSIVE calculation
|
96
|
-
|
97
|
-
wr = File.writable?(ricdisk_file)
|
98
|
-
|
105
|
+
puts yellow("TODO(ricc): Do expensive calculation if this FS is writeable: #{path}")
|
106
|
+
#@wr = File.writable?(File.expand_path(@ricdisk_file)) # rescue false
|
107
|
+
raise "for some reason an important info (ricdisk_file='#{absolute_path}') is missing!" if ricdisk_file.nil?
|
108
|
+
@wr = File.writable?(absolute_path) # rescue false
|
109
|
+
return @wr
|
99
110
|
#:boh_todo_fix_me_and_compute
|
100
111
|
#false
|
101
112
|
end
|
@@ -119,9 +130,9 @@ module Storazzo
|
|
119
130
|
end
|
120
131
|
|
121
132
|
def absolute_path
|
122
|
-
|
133
|
+
#@local_mountpoint + "/" + @ricdisk_file
|
134
|
+
"#{local_mountpoint}/#{ricdisk_file}"
|
123
135
|
end
|
124
|
-
|
125
136
|
|
126
137
|
def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
|
127
138
|
if base_dirs.nil?
|
@@ -162,30 +173,47 @@ module Storazzo
|
|
162
173
|
deb "[CACHE HIT] ricdisk_file (didnt have to recompute it - yay!)"
|
163
174
|
return @ricdisk_file
|
164
175
|
end
|
165
|
-
|
176
|
+
deb "[compute_ricdisk_file] RICC_WARNING This requires cmputation I wanna do it almost once"
|
166
177
|
ConfigFiles.each do |papable_config_filename|
|
167
178
|
#return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
168
179
|
#return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
169
180
|
return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
170
181
|
end
|
171
|
-
|
182
|
+
deb "File not found! Neither #{ConfigFiles} exist.."
|
183
|
+
# return nil
|
184
|
+
return DefaultConfigFile
|
172
185
|
end
|
173
186
|
|
187
|
+
|
188
|
+
# def self.compute_ricdisk_file_by_path_once(path)
|
189
|
+
# # unless @ricdisk_file.nil?
|
190
|
+
# # deb "[CACHE HIT] ricdisk_file (didnt have to recompute it - yay!)"
|
191
|
+
# # return @ricdisk_file
|
192
|
+
# # end
|
193
|
+
# warn "RICC_WARNING This requires cmputation I wanna do it almost once"
|
194
|
+
# ConfigFiles.each do |papable_config_filename|
|
195
|
+
# #return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
196
|
+
# #return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
197
|
+
# return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
198
|
+
# end
|
199
|
+
# return nil
|
200
|
+
# end
|
201
|
+
|
174
202
|
|
175
|
-
# new
|
176
|
-
def self.get_ricdisk_file_obsolete(path)
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
203
|
+
# # new
|
204
|
+
# def self.get_ricdisk_file_obsolete(path)
|
205
|
+
# if @ricdisk_file
|
206
|
+
# puts "[CACHE HIT] ricdisk_file"
|
207
|
+
# return @ricdisk_file
|
208
|
+
# end
|
209
|
+
# puts "RICC_WARNING This requires cmputation I wanna do it almost once"
|
210
|
+
# ConfigFiles.each do |papable_config_filename|
|
211
|
+
# #return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
212
|
+
# #return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
213
|
+
# return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
214
|
+
# end
|
215
|
+
# return nil
|
216
|
+
# end
|
189
217
|
|
190
218
|
|
191
219
|
def self.interesting_mount_points(opts={})
|
@@ -194,13 +222,13 @@ module Storazzo
|
|
194
222
|
end
|
195
223
|
|
196
224
|
# maybe move to a RiccFile class? Maybe even INHERIT from FILE?
|
197
|
-
def
|
225
|
+
def obsolescence_seconds(file_path)
|
198
226
|
creation_time = File.stat(file_path).ctime
|
199
227
|
deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
|
200
228
|
(Time.now - creation_time).to_i
|
201
229
|
end
|
202
230
|
# maybe move to a RiccFile class? Maybe even INHERIT from FILE?
|
203
|
-
def
|
231
|
+
def obsolescence_days(file_path)
|
204
232
|
return obsolescence_seconds(file_path) / 86400
|
205
233
|
end
|
206
234
|
|
@@ -230,11 +258,16 @@ module Storazzo
|
|
230
258
|
# puts(yellow disk_info.to_yaml)
|
231
259
|
# end
|
232
260
|
if disk_info.is_a?(RicDisk)
|
233
|
-
|
234
|
-
if File.empty?(disk_info.absolute_path) and (disk_info.wr)
|
261
|
+
puts yellow("DEB disk_info.class: #{disk_info.class}")
|
262
|
+
if File.empty?(disk_info.absolute_path) # and (disk_info.wr)
|
235
263
|
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
|
-
|
237
|
-
|
264
|
+
if disk_info.wr
|
265
|
+
ret = File.write(disk_info.absolute_path, disk_info.obj_to_yaml)
|
266
|
+
puts green("Written file! ret=#{ret}")
|
267
|
+
else
|
268
|
+
raise "TODO_IMPLEMENT: write in proper place in config dir"
|
269
|
+
puts red("TODO implement me")
|
270
|
+
end
|
238
271
|
else
|
239
272
|
puts(red("Something not right here: either file is NOT empty or disk is NOT writeable.. #{File.empty?(disk_info.absolute_path)}"))
|
240
273
|
puts("File size: #{File.size(disk_info.absolute_path)}")
|
@@ -242,30 +275,63 @@ module Storazzo
|
|
242
275
|
puts(disk_info.obj_to_hash)
|
243
276
|
puts(disk_info.obj_to_yaml)
|
244
277
|
end
|
245
|
-
else
|
278
|
+
else # not a RicDisk..
|
246
279
|
puts "[write_config_yaml_to_disk] No DiskInfo found across #{ConfigFiles}. I leave this function empty-handed."
|
247
280
|
end
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
281
|
+
|
282
|
+
#disk_info.absolute_path
|
283
|
+
#if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
|
284
|
+
# if File.exists?(disk_info.absolute_path) and ! File.empty?(disk_info.absolute_path)
|
285
|
+
# puts("Config File found with old-style name: '#{subdir}/.ricdisk' ! Please move it to .ricdisk.yaml!")
|
286
|
+
# puts(white `cat "#{disk_info.absolute_path}"`)
|
287
|
+
# else
|
288
|
+
# puts "WRITING NOW. [I BELIEVE THIS IS DUPE CODE - see a few lines above!] disk_info.obj_to_yaml .. to #{compute_ricdisk_file}"
|
289
|
+
# File.open(ricdisk_file_full, 'w').write(disk_info.obj_to_yaml)
|
290
|
+
# end
|
255
291
|
end
|
256
292
|
|
257
293
|
# TODO obsolete this as i should NOT be calling it from clas, but from method.
|
258
294
|
def self.ok_dir?(subdir)
|
259
295
|
File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
|
260
296
|
end
|
297
|
+
|
298
|
+
def compute_stats_files(opts={})
|
299
|
+
puts azure("[compute_stats_files] TODO implement natively. Now I'm being lazy")
|
300
|
+
#Storazzo::RicDisk.calculate_stats_files(path, opts)
|
301
|
+
opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
|
302
|
+
dir = path
|
303
|
+
|
304
|
+
full_file_path = "#{dir}/#{$stats_file}"
|
305
|
+
#return "This refactor is for another day"
|
306
|
+
|
307
|
+
puts("compute_stats_files(#{white dir}): #{white full_file_path}")
|
308
|
+
puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
|
309
|
+
Dir.chdir(dir)
|
310
|
+
if File.exists?(full_file_path) and ($opts[:force] == false)
|
311
|
+
puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
|
312
|
+
# TODO check for file time...
|
313
|
+
print "Lines found: #{yellow `wc -l "#{full_file_path}" `.chomp }. File obsolescence (days): #{yellow obsolescence_days(full_file_path)}."
|
314
|
+
if obsolescence_days(full_file_path) > 7
|
315
|
+
puts("*** ACHTUNG *** FIle is pretty old. You might consider rotating: #{yellow "mv #{full_file_path} #{full_file_path}_old"}. Or invoke with --force")
|
316
|
+
end
|
317
|
+
upload_to_gcs(full_file_path) if opts_upload_to_gcs
|
318
|
+
else
|
319
|
+
puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
|
320
|
+
command = "find . -print0 | xargs -0 stats-with-md5 --no-color | tee '#{full_file_path}'"
|
321
|
+
puts("[#{`pwd`.chomp}] Executing: #{azure command}")
|
322
|
+
ret = backquote_execute(command)
|
323
|
+
puts "Done. #{ret.split("\n").count} files processed."
|
324
|
+
end
|
325
|
+
end
|
261
326
|
|
262
327
|
|
263
328
|
|
264
329
|
# Create RDS file.
|
265
330
|
def self.calculate_stats_files(dir, opts={})
|
266
|
-
opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
|
331
|
+
opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
|
332
|
+
|
267
333
|
full_file_path = "#{dir}/#{$stats_file}"
|
268
|
-
return "This
|
334
|
+
return "This refactor is for another day"
|
269
335
|
|
270
336
|
puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
|
271
337
|
puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
|
@@ -280,7 +346,7 @@ module Storazzo
|
|
280
346
|
upload_to_gcs(full_file_path) if opts_upload_to_gcs
|
281
347
|
else
|
282
348
|
puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
|
283
|
-
command = "find . -print0 | xargs -0 stats-with-md5
|
349
|
+
command = "find . -print0 | xargs -0 stats-with-md5 --no-color | tee '#{full_file_path}'"
|
284
350
|
puts("[#{`pwd`.chomp}] Executing: #{azure command}")
|
285
351
|
ret = backquote_execute command
|
286
352
|
puts "Done. #{ret.split("\n").count} files processed."
|
@@ -390,25 +456,27 @@ end #/Module
|
|
390
456
|
|
391
457
|
|
392
458
|
|
393
|
-
|
394
|
-
|
395
|
-
#
|
396
|
-
#
|
397
|
-
|
459
|
+
def backquote_execute(cmd, opts={})
|
460
|
+
dryrun = opts.fetch :dryrun, false
|
461
|
+
# executed a command wrapped by dryrun though
|
462
|
+
return "DRYRUN backquote_execute(#{cmd})" if dryrun # $opts[:dryrun]
|
463
|
+
`#{cmd}`
|
464
|
+
end
|
398
465
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
|
466
|
+
def upload_to_gcs(file, opts={})
|
467
|
+
deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
|
468
|
+
mount_name = file.split('/')[-2]
|
469
|
+
filename = "#{mount_name}-#{File.basename file}"
|
470
|
+
hostname = Socket.gethostname[/^[^.]+/]
|
471
|
+
command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
|
472
|
+
deb("Command: #{command}")
|
473
|
+
puts azure("GCS upload disabled until I know if it works :) command='#{command}'")
|
474
|
+
ret = backquote_execute(command, :dryrun => true)
|
475
|
+
# if $opts[:debug] do
|
476
|
+
# puts "+ Current list of files:"
|
477
|
+
# ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
|
478
|
+
# puts ret
|
479
|
+
# end
|
480
|
+
ret
|
481
|
+
end
|
414
482
|
|
@@ -40,6 +40,11 @@ public
|
|
40
40
|
def load(config_path=nil, opts={})
|
41
41
|
verbose = opts.fetch :verbose, false
|
42
42
|
|
43
|
+
if already_loaded? # and not self.config.nil?
|
44
|
+
puts "[#{self.class}] VERBOSE load: already loaded" if verbose
|
45
|
+
return self.config
|
46
|
+
end
|
47
|
+
|
43
48
|
puts "[VERBOSE] Storazzo::RicDiskConfig.load(): BEGIN " if verbose
|
44
49
|
# trying default location
|
45
50
|
raise "DefaultConfigLocation is not a string" unless DefaultConfigLocation.is_a?(String)
|
@@ -72,8 +77,8 @@ public
|
|
72
77
|
#pp @config if verbose
|
73
78
|
config_ver = @config["apiVersion"]
|
74
79
|
#puts @config[:ConfigVersion]
|
75
|
-
|
76
|
-
puts "[VERBOSE] RicDiskConfig.to_s: #{self}" if verbose
|
80
|
+
deb("OK. Storazzo::RicDiskConfig v'#{config_ver}' parsed correctly")
|
81
|
+
#puts "[VERBOSE] RicDiskConfig.to_s: #{self}" if verbose
|
77
82
|
@load_called = true
|
78
83
|
return self.config
|
79
84
|
end
|
@@ -91,7 +96,7 @@ public
|
|
91
96
|
end
|
92
97
|
|
93
98
|
def config_ver
|
94
|
-
raise "I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?"
|
99
|
+
raise "I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?" if @config.nil?
|
95
100
|
@config['apiVersion'] # rescue :StillUnknown
|
96
101
|
#config['ConfigVersion']
|
97
102
|
end
|
@@ -99,6 +104,10 @@ public
|
|
99
104
|
#self.
|
100
105
|
@config['Config']['DefaultFolder'] #rescue "Unknown config_default_folder: #{$!}"
|
101
106
|
end
|
107
|
+
def already_loaded?
|
108
|
+
#return
|
109
|
+
load_called == true
|
110
|
+
end
|
102
111
|
|
103
112
|
def to_s
|
104
113
|
size = File.size(@config_file) rescue -1
|
@@ -107,6 +116,18 @@ public
|
|
107
116
|
"POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
108
117
|
end
|
109
118
|
|
119
|
+
def to_verbose_s
|
120
|
+
h = {}
|
121
|
+
h[:description] = "This is a Verbose Hash describing a RicDiskConfig or its child RicDiskSampleConfig to understand why it keeps failing.."
|
122
|
+
h[:to_s] = self.to_s
|
123
|
+
h[:class] = self.class
|
124
|
+
h[:file] = __FILE__
|
125
|
+
h[:id] = self.object_id
|
126
|
+
h[:get_bucket_paths] = self.get_bucket_paths()
|
127
|
+
h[:get_local_folders] = self.get_local_folders()
|
128
|
+
return h
|
129
|
+
end
|
130
|
+
|
110
131
|
def get_config(opts={})
|
111
132
|
return load(opts) if @config.nil?
|
112
133
|
@config
|
@@ -140,7 +161,8 @@ public
|
|
140
161
|
end
|
141
162
|
|
142
163
|
# UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
|
143
|
-
def iterate_through_file_list_for_disks(files_list=[])
|
164
|
+
def iterate_through_file_list_for_disks(files_list=[], opts={})
|
165
|
+
verbose = opts.fetch :verbose, true
|
144
166
|
# I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
|
145
167
|
# if files_list == [] # or files_list.nil? # empty -> ALL
|
146
168
|
# deb "iterate_through_file_list_for_disks(): no args provided"
|
@@ -150,65 +172,39 @@ public
|
|
150
172
|
# RicDisk.write_config_yaml_to_disk(dir)
|
151
173
|
# RicDisk.calculate_stats_files(dir) # dir is inutile
|
152
174
|
# } # TODO refactor in option sbrodola_afterwards=true. :)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
#
|
168
|
-
|
175
|
+
# else
|
176
|
+
raise "Wrong input, I need an array here: #{files_list} " unless files_list.is_a?(Array)
|
177
|
+
puts "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)" if verbose
|
178
|
+
|
179
|
+
#dirs = RicDisk.find_active_dirs()
|
180
|
+
files_list.each do |dir|
|
181
|
+
dir = File.expand_path(dir)
|
182
|
+
if File.directory?(dir)
|
183
|
+
#if dirs.include?(dir)
|
184
|
+
puts "iterate_through_file_list_for_disks() Legit dir: #{green dir}" if verbose
|
185
|
+
rd = RicDisk.new(dir)
|
186
|
+
puts "RicDisk: #{rd}"
|
187
|
+
rd.write_config_yaml_to_disk(dir)
|
188
|
+
#RicDisk.write_config_yaml_to_disk(dir)
|
189
|
+
#RicDisk.calculate_stats_files (CLASS) => will become OBJECT compute_stats_files
|
190
|
+
rd.compute_stats_files() # dir is inutile # TODO
|
191
|
+
else
|
192
|
+
raise("Doesnt seem a dir to me, quitting: #{dir}")
|
169
193
|
end
|
194
|
+
end
|
170
195
|
#end
|
171
196
|
end #/iterate_through_file_list_for_disks
|
197
|
+
|
198
|
+
def config_hash
|
199
|
+
config['Config']
|
200
|
+
end
|
172
201
|
|
173
202
|
|
174
203
|
def self.get_config
|
204
|
+
self.instance.load unless self.instance.load_called
|
175
205
|
self.instance.get_config
|
176
206
|
end
|
177
207
|
end # class Storazzo::RicDiskConfig
|
178
208
|
|
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
|
209
|
-
end
|
210
|
-
|
211
|
-
puts "[REMOVEME]1 Storazzo::RicDiskSampleConfig was read"
|
212
209
|
end # module Storazzo
|
213
210
|
|
214
|
-
puts "[REMOVEME]2 Storazzo::RicDiskSampleConfig was read"
|
@@ -17,15 +17,19 @@ module Storazzo
|
|
17
17
|
class Storazzo::RicDiskSampleConfig < Storazzo::RicDiskConfig
|
18
18
|
#include Storazzo::Common
|
19
19
|
|
20
|
-
include Singleton
|
20
|
+
#include Singleton
|
21
|
+
|
21
22
|
public
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def load # _sample_version
|
24
|
+
deb("[RicDiskSampleConfig] Wheew 1! 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.")
|
25
|
+
# super.load DefaultGemLocationForTests #super.load(DefaultGemLocationForTests, :verbose => true )
|
26
|
+
super(DefaultGemLocationForTests, :verbose => false )
|
27
|
+
end
|
28
|
+
def load_sample_version
|
29
|
+
puts white("[RicDiskSampleConfig] Wheew 2! 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.")
|
30
|
+
super(DefaultGemLocationForTests, :verbose => false )
|
31
|
+
end
|
32
|
+
end
|
27
33
|
|
28
|
-
#puts "[REMOVEME]1 Storazzo::RicDiskSampleConfig was read"
|
29
34
|
end # module Storazzo
|
30
35
|
|
31
|
-
#puts "[REMOVEME]2 Storazzo::RicDiskSampleConfig was read"
|