storazzo 0.6.1 → 0.7.3
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 +16 -1
- data/README.md +17 -18
- data/VERSION +1 -1
- data/bin/hello-storazzo +5 -1
- data/bin/ricdisk-magic +7 -13
- data/bin/stats-with-md5 +1 -1
- data/bin/storazzo +95 -141
- data/bin/storazzo-symlink.rb +1 -1
- data/bin/storazzo-util +1 -1
- data/lib/storazzo/common.rb +18 -5
- data/lib/storazzo/gcs/client.rb +85 -0
- data/lib/storazzo/main.rb +2 -5
- data/lib/storazzo/media/abstract_ric_disk.rb +162 -167
- data/lib/storazzo/media/gcs_bucket.rb +64 -69
- data/lib/storazzo/media/local_folder.rb +45 -49
- data/lib/storazzo/media/mount_point.rb +11 -15
- data/lib/storazzo/ric_disk.rb +30 -19
- data/lib/storazzo/ric_disk_config.rb +210 -214
- data/lib/storazzo/ric_disk_sample_config.rb +16 -18
- data/lib/storazzo/ric_disk_statsfile.rb +3 -5
- data/lib/storazzo/search_engine.rb +162 -0
- data/lib/storazzo/version.rb +1 -1
- data/lib/storazzo.rb +2 -7
- data/storazzo.gemspec +4 -3
- data/test/gcs/test_client.rb +42 -0
- data/test/media/test_local_folder.rb +2 -10
- data/test/test_ric_disk.rb +3 -1
- data/var/test/disks/ricdisk_stats_v11.rds +19 -11
- metadata +61 -18
|
@@ -20,174 +20,169 @@
|
|
|
20
20
|
|
|
21
21
|
module Storazzo
|
|
22
22
|
module Media
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if path =~ %r{^gs://}
|
|
184
|
-
deb 'Smells like GCS'
|
|
185
|
-
return GcsBucket.new(path)
|
|
186
|
-
end
|
|
187
|
-
deb 'Smells like LocalFolder :)'
|
|
188
|
-
LocalFolder.new(path)
|
|
189
|
-
end
|
|
23
|
+
class AbstractRicDisk
|
|
24
|
+
extend ::Storazzo::Common
|
|
25
|
+
|
|
26
|
+
# DefaultStatsFilename = Storazzo::RicDiskStatsFile.default_name
|
|
27
|
+
|
|
28
|
+
# looks like there's not Abstract Class in Ruby, but also SO says he best
|
|
29
|
+
# way to do this is this:
|
|
30
|
+
|
|
31
|
+
# attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path, :ricdisk_file_empty, :size, :active_dirs
|
|
32
|
+
attr_accessor :description
|
|
33
|
+
|
|
34
|
+
########################
|
|
35
|
+
# Abstract methods START
|
|
36
|
+
########################
|
|
37
|
+
def initialize(_local_mount)
|
|
38
|
+
deb "[AbstractRicDisk.init()] Some child of AbstractRicDisk (#{self}) called me! Yummie." # disable when you dont need me anymore..
|
|
39
|
+
@description ||= 'Not provided'
|
|
40
|
+
# validate
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.list_all
|
|
44
|
+
raise "[AbstractRicDiskc::self.list_all] You should override this, says StackOverflow and Riccardo. Class=#{self.class}. Self=#{self}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.list_all_with_type
|
|
48
|
+
raise "[AbstractRicDisk::self.list_all_with_type] You should override this, says StackOverflow and Riccardo. Class=#{self.class}. Self=#{self}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.super_duper_list_all_with_type
|
|
52
|
+
deb 'Would be cool to be able to enumerate them all..'
|
|
53
|
+
GcsBucket.list_all_with_type +
|
|
54
|
+
MountPoint.list_all_with_type +
|
|
55
|
+
LocalFolder.list_all_with_type
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def parse(_opts = {})
|
|
59
|
+
raise "[AbstractRicDiskc::parse] You should override this, says StackOverflow and Riccardo. Class=#{self.class}."
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def writeable?
|
|
63
|
+
raise "[AbstractRicDiskc::writeable] You should override this in class=#{self.class}, says StackOverflow and Riccardo"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def get_local_mountpoint
|
|
67
|
+
# raise "[AbstractRicDiskc::get_local_mountpoint] You should override this, says StackOverflow and Riccardo"
|
|
68
|
+
raise 'You forgot to set local_mountpoint in the constructor for your class, you cheeky little one!' if local_mountpoint.nil?
|
|
69
|
+
|
|
70
|
+
local_mountpoint
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def check_implemented_correctly
|
|
74
|
+
# raise "[AbstractRicDiskc] You should override this, says StackOverflow and Riccardo"
|
|
75
|
+
raise 'no @local_mountpoint' unless exists?(@local_mountpoint)
|
|
76
|
+
end
|
|
77
|
+
########################
|
|
78
|
+
# Abstract methods END
|
|
79
|
+
########################
|
|
80
|
+
|
|
81
|
+
########################
|
|
82
|
+
# Automated methods now...
|
|
83
|
+
########################
|
|
84
|
+
# stats_file_default_location()
|
|
85
|
+
def stats_file_smart_fullpath
|
|
86
|
+
# if its writeable... if not we'll think about it later.
|
|
87
|
+
if writeable?
|
|
88
|
+
"#{get_local_mountpoint}/#{default_stats_filename}"
|
|
89
|
+
else
|
|
90
|
+
# if not writeable, I will:
|
|
91
|
+
# 1. create a dir based on its unique format.
|
|
92
|
+
# 2. create a file of same look and feel (alternative - used a DASH)
|
|
93
|
+
"TODO FIXME {get_local_folder}/#{unique_id}::#{default_stats_filename}"
|
|
94
|
+
# "{get_local_folder}"/#{unique_id}/#{Storazzo::RicDiskStatsFile.default_name}"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Needs to be some unique id based on its thingy, but might change in the future:
|
|
99
|
+
# Solutions:
|
|
100
|
+
# {PHILOSOPHY}::{ID}
|
|
101
|
+
def unique_id
|
|
102
|
+
# Expand path to make it as unique as possible...
|
|
103
|
+
hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
|
|
104
|
+
"MD5::v1::#{hash}"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def to_s(verbose = false)
|
|
108
|
+
return to_verbose_s if verbose
|
|
109
|
+
|
|
110
|
+
readable_class = self.class.to_s.split('::').last # Storazzo::Media::LocalFolder => LocalFolder
|
|
111
|
+
my_keys = instance_variables # wow!
|
|
112
|
+
"S:M:#{readable_class}(path=#{path}, r/w=#{wr}, keys=#{my_keys})"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def to_verbose_s
|
|
116
|
+
h = {}
|
|
117
|
+
h[:class] = self.class
|
|
118
|
+
h[:unique_id] = unique_id
|
|
119
|
+
h[:inspect] = inspect
|
|
120
|
+
h[:to_s] = to_s
|
|
121
|
+
h[:local_mountpoint] = local_mountpoint
|
|
122
|
+
h[:writeable] = writeable?
|
|
123
|
+
h[:stats_file_smart_fullpath] = stats_file_smart_fullpath
|
|
124
|
+
h
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# # Todo check on instances these 3 methods exist
|
|
128
|
+
def self.abstract_class_mandatory_methods
|
|
129
|
+
%w[
|
|
130
|
+
self.list_all
|
|
131
|
+
self.list_all_with_type
|
|
132
|
+
local_mountpoint
|
|
133
|
+
parse
|
|
134
|
+
writeable?
|
|
135
|
+
]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Putting here since its same code for MountPoint or generic folder.
|
|
139
|
+
def parse_block_storage_folder(opts = {})
|
|
140
|
+
# Storazzo::RicDiskUgly.calculate_stats_files(get_local_mountpoint)
|
|
141
|
+
rd = Storazzo::RicDisk.new(self)
|
|
142
|
+
# Storazzo::RicDisk
|
|
143
|
+
rd.compute_stats_files(opts)
|
|
144
|
+
# return "42"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def self.default_stats_filename
|
|
148
|
+
raise 'Unknown Storazzo::RicDiskStatsFile.default_name 1!!' if Storazzo::RicDiskStatsFile.default_name.nil?
|
|
149
|
+
|
|
150
|
+
Storazzo::RicDiskStatsFile.default_name
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# if not writeable we need to pick another from stats_file_smart_fullpath()
|
|
154
|
+
def stats_filename_default_fullpath
|
|
155
|
+
# REDUNDANT, should use stats_file_smart_fullpath instead except on the writeable? part since it would go recursive otherwise.
|
|
156
|
+
my_stats_filename = default_stats_filename
|
|
157
|
+
# raise "Unknown Storazzo::RicDiskStatsFile.default_name 2 !!" if Storazzo::RicDiskStatsFile.default_name.nil?
|
|
158
|
+
"#{local_mountpoint}/#{my_stats_filename}"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def validate(opts = {})
|
|
162
|
+
opt_verbose = opts.fetch :verbose, false
|
|
163
|
+
pverbose opt_verbose,
|
|
164
|
+
"validate(): [BROKEN] We're trying to see if your object is valid, across 3 possible sub-classes."
|
|
165
|
+
# 1. check for
|
|
166
|
+
raise 'Unknown local mount ' unless local_mount.is_a?(String)
|
|
167
|
+
|
|
168
|
+
# 2. check thaty writeable? is true or false
|
|
169
|
+
my_writeable = wr
|
|
170
|
+
raise 'Writeable is not boolean' unless my_writeable.is_a?(TrueClass) || my_writeable.is_a?(FalseClass)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# TODO: use a proper Factory pattern.
|
|
174
|
+
def self.DirFactory(path)
|
|
175
|
+
raise "I need a path/directory string: #{path}" unless path.is_a?(String)
|
|
176
|
+
|
|
177
|
+
deb 'TODO: if coincides with MountPoint, instance THAT'
|
|
178
|
+
# if path in Storazzo::Media::MountPoint.list_all_mount_points
|
|
179
|
+
# then return ...
|
|
180
|
+
if path =~ %r{^gs://}
|
|
181
|
+
deb 'Smells like GCS'
|
|
182
|
+
return GcsBucket.new(path)
|
|
190
183
|
end
|
|
184
|
+
deb 'Smells like LocalFolder :)'
|
|
185
|
+
LocalFolder.new(path)
|
|
191
186
|
end
|
|
192
187
|
end
|
|
193
188
|
end
|
|
@@ -4,85 +4,80 @@ require 'English'
|
|
|
4
4
|
|
|
5
5
|
module Storazzo
|
|
6
6
|
module Media
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module Media
|
|
10
|
-
class GcsBucket < Storazzo::Media::AbstractRicDisk
|
|
11
|
-
extend Storazzo::Common
|
|
7
|
+
class GcsBucket < Storazzo::Media::AbstractRicDisk
|
|
8
|
+
extend ::Storazzo::Common
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
attr_accessor :project_id
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
def initialize(local_mount, project_id = nil)
|
|
13
|
+
deb '[Storazzo::Media::GcsBucket] initialize'
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
@local_mountpoint = File.expand_path(local_mount)
|
|
16
|
+
@description = "MountPoint in '#{local_mount}' pointing at TODO with mount options = TODO"
|
|
17
|
+
project_id ||= _autodetect_project_id
|
|
18
|
+
@project_id = project_id
|
|
19
|
+
raise 'Sorry local mount doesnt exist!' unless File.exist?(@local_mountpoint)
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def _autodetect_project_id
|
|
33
|
-
'todo-my-project-id-123' # TODO: fix
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# (config = nil)
|
|
37
|
-
def self.list_all
|
|
38
|
-
# get lisrts from Config singletone
|
|
39
|
-
# puts " self.list_all: loading config "
|
|
40
|
-
config ||= Storazzo::RicDiskConfig.instance # # ).get_config
|
|
21
|
+
@wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
|
|
22
|
+
begin
|
|
23
|
+
super(local_mount)
|
|
24
|
+
rescue StandardError
|
|
25
|
+
"SUPER_ERROR(#{local_mount}): #{$ERROR_INFO}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# [42, 43]
|
|
46
|
-
# deb config.get_local_folders
|
|
47
|
-
# TODO
|
|
48
|
-
pverbose true,
|
|
49
|
-
"TODO(ricc): also add gsutil ls. For that please use the new 'list_all_with_type' (Id refactor it but Im afraid of leaving bad code dangling so before a proper refactor lets implement both side by side"
|
|
50
|
-
config.get_bucket_paths
|
|
51
|
-
end
|
|
29
|
+
def _autodetect_project_id
|
|
30
|
+
'todo-my-project-id-123' # TODO: fix
|
|
31
|
+
end
|
|
52
32
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# puts "GCS::list_all_with_type() -- TODO(ricc): also add gsutil ls"
|
|
59
|
-
# getFromConfig
|
|
60
|
-
deb "I'm now returning a 'complex' array to tell the caller what kind of element they're getting, eg: GCS from Config Yaml, vs GCS from gsutil ls "
|
|
61
|
-
list_from_config_with_type = config.get_bucket_paths.map do |path|
|
|
62
|
-
[:config_gcs_bucket, path]
|
|
63
|
-
end
|
|
64
|
-
ret_list = list_from_config_with_type
|
|
65
|
-
if config.gcs_enabled? # should be if GCS enabled :) project_id
|
|
66
|
-
# so I concatenate Apples with Bananas with names
|
|
67
|
-
# ret_list += list_available_buckets(config.project_id).map { |path|
|
|
68
|
-
ret_list += list_available_buckets.map do |path|
|
|
69
|
-
[:gsutil_ls_gcs_bucket, path]
|
|
70
|
-
end
|
|
71
|
-
else
|
|
72
|
-
deb 'list_all_with_type(): empty project id. Skipping'
|
|
73
|
-
end
|
|
33
|
+
# (config = nil)
|
|
34
|
+
def self.list_all
|
|
35
|
+
# get lisrts from Config singletone
|
|
36
|
+
# puts " self.list_all: loading config "
|
|
37
|
+
config ||= Storazzo::RicDiskConfig.instance # # ).get_config
|
|
74
38
|
|
|
75
|
-
|
|
76
|
-
|
|
39
|
+
config.load # in case I need to load it for the first time
|
|
40
|
+
# puts config['Config']['AdditionalMountDirs']
|
|
41
|
+
# puts "TODO see config: #{config}"
|
|
42
|
+
# [42, 43]
|
|
43
|
+
# deb config.get_local_folders
|
|
44
|
+
# TODO
|
|
45
|
+
pverbose true,
|
|
46
|
+
"TODO(ricc): also add gsutil ls. For that please use the new 'list_all_with_type' (Id refactor it but Im afraid of leaving bad code dangling so before a proper refactor lets implement both side by side"
|
|
47
|
+
config.get_bucket_paths
|
|
48
|
+
end
|
|
77
49
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
50
|
+
# (config = nil)
|
|
51
|
+
def self.list_all_with_type
|
|
52
|
+
deb 'GCS::list_all_with_type() -- pull config'
|
|
53
|
+
config ||= Storazzo::RicDiskConfig.instance
|
|
54
|
+
config.load # in case I need to load it for the first time
|
|
55
|
+
# puts "GCS::list_all_with_type() -- TODO(ricc): also add gsutil ls"
|
|
56
|
+
# getFromConfig
|
|
57
|
+
deb "I'm now returning a 'complex' array to tell the caller what kind of element they're getting, eg: GCS from Config Yaml, vs GCS from gsutil ls "
|
|
58
|
+
list_from_config_with_type = config.get_bucket_paths.map do |path|
|
|
59
|
+
[:config_gcs_bucket, path]
|
|
60
|
+
end
|
|
61
|
+
ret_list = list_from_config_with_type
|
|
62
|
+
if config.gcs_enabled? # should be if GCS enabled :) project_id
|
|
63
|
+
# so I concatenate Apples with Bananas with names
|
|
64
|
+
# ret_list += list_available_buckets(config.project_id).map { |path|
|
|
65
|
+
ret_list += list_available_buckets.map do |path|
|
|
66
|
+
[:gsutil_ls_gcs_bucket, path]
|
|
84
67
|
end
|
|
68
|
+
else
|
|
69
|
+
deb 'list_all_with_type(): empty project id. Skipping'
|
|
85
70
|
end
|
|
71
|
+
|
|
72
|
+
ret_list
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.list_available_buckets(_opts = {})
|
|
76
|
+
# project_id = opts.fetch :project_id, nil
|
|
77
|
+
# list_of_buckets = `gsutil ls --project '#{project_id}'`.chomp.split("\n")
|
|
78
|
+
list_of_buckets = `gsutil ls`.chomp.split("\n")
|
|
79
|
+
deb "list_of_buckets: #{list_of_buckets}"
|
|
80
|
+
list_of_buckets
|
|
86
81
|
end
|
|
87
82
|
end
|
|
88
83
|
end
|
|
@@ -6,57 +6,53 @@
|
|
|
6
6
|
require 'English'
|
|
7
7
|
module Storazzo
|
|
8
8
|
module Media
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rescue StandardError
|
|
29
|
-
"SUPER_ERROR(#{local_mount}): #{$ERROR_INFO}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# WRONG: config = nil
|
|
34
|
-
def self.list_all
|
|
35
|
-
# get lists from Config singleton
|
|
36
|
-
config = Storazzo::RicDiskConfig.instance # # ).get_config
|
|
37
|
-
config.load
|
|
38
|
-
config.get_local_folders
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def parse(opts = {})
|
|
42
|
-
puts "LF.parse(#{opts}): TODO Sbrodola inside the dir: #{local_mountpoint}"
|
|
43
|
-
parse_block_storage_folder
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def path
|
|
47
|
-
@local_mountpoint
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def writeable?
|
|
51
|
-
File.writable?(@local_mountpoint)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def default_stats_filename
|
|
55
|
-
# '42'
|
|
56
|
-
Storazzo::RicDiskStatsFile.default_name
|
|
57
|
-
end
|
|
9
|
+
class LocalFolder < Storazzo::Media::AbstractRicDisk
|
|
10
|
+
# extend ::Storazzo::Common
|
|
11
|
+
include ::Storazzo::Common
|
|
12
|
+
|
|
13
|
+
attr_accessor :local_mountpoint, :wr
|
|
14
|
+
|
|
15
|
+
def initialize(local_mount)
|
|
16
|
+
deb '[Storazzo::Media::LocalFolder] initialize'
|
|
17
|
+
|
|
18
|
+
@local_mountpoint = File.expand_path(local_mount)
|
|
19
|
+
@description = "Local Folder originally in '#{local_mount}'"
|
|
20
|
+
raise 'Sorry local mount doesnt exist!' unless File.exist?(@local_mountpoint)
|
|
21
|
+
|
|
22
|
+
@wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
|
|
23
|
+
# super.initialize(local_mount) rescue "SUPER_ERROR: #{$!}"
|
|
24
|
+
begin
|
|
25
|
+
super(local_mount)
|
|
26
|
+
rescue StandardError
|
|
27
|
+
"SUPER_ERROR(#{local_mount}): #{$ERROR_INFO}"
|
|
58
28
|
end
|
|
59
29
|
end
|
|
30
|
+
|
|
31
|
+
# WRONG: config = nil
|
|
32
|
+
def self.list_all
|
|
33
|
+
# get lists from Config singleton
|
|
34
|
+
config = Storazzo::RicDiskConfig.instance # # ).get_config
|
|
35
|
+
config.load
|
|
36
|
+
config.get_local_folders
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def parse(opts = {})
|
|
40
|
+
puts "LF.parse(#{opts}): TODO Sbrodola inside the dir: #{local_mountpoint}"
|
|
41
|
+
parse_block_storage_folder
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def path
|
|
45
|
+
@local_mountpoint
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def writeable?
|
|
49
|
+
File.writable?(@local_mountpoint)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def default_stats_filename
|
|
53
|
+
# '42'
|
|
54
|
+
Storazzo::RicDiskStatsFile.default_name
|
|
55
|
+
end
|
|
60
56
|
end
|
|
61
57
|
end
|
|
62
58
|
end
|
|
@@ -3,24 +3,20 @@
|
|
|
3
3
|
# TODO
|
|
4
4
|
module Storazzo
|
|
5
5
|
module Media
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class MountPoint < Storazzo::Media::AbstractRicDisk
|
|
9
|
-
# puts "[REMOVEME] Storazzo::Media::MountPoint being read. REMOVEME when you see this :)"
|
|
6
|
+
class MountPoint < AbstractRicDisk
|
|
7
|
+
# puts "[REMOVEME] Storazzo::Media::MountPoint being read. REMOVEME when you see this :)"
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
def self.list_local_mount_points
|
|
10
|
+
deb 'Maybe its abuot time you refactor that method here :)'
|
|
11
|
+
RicDisk.interesting_mount_points
|
|
12
|
+
end
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
def self.list_all
|
|
15
|
+
RicDisk.interesting_mount_points
|
|
16
|
+
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
end
|
|
18
|
+
def self.list_all_with_type
|
|
19
|
+
list_all.map { |x| [:mount_point_todo_less_generic, x] }
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
end
|