simp-metadata 0.4.4 → 0.5.2
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 +5 -5
- data/README.md +494 -0
- data/Rakefile +19 -22
- data/exe/simp-install +1 -1
- data/exe/simp-media +1 -1
- data/exe/simp-metadata +1 -1
- data/lib/simp/install/command.rb +34 -35
- data/lib/simp/media.rb +0 -1
- data/lib/simp/media/command.rb +34 -35
- data/lib/simp/media/engine.rb +29 -35
- data/lib/simp/media/type.rb +1 -2
- data/lib/simp/media/type/base.rb +12 -4
- data/lib/simp/media/type/control-repo.rb +96 -107
- data/lib/simp/media/type/internet.rb +8 -8
- data/lib/simp/media/type/iso.rb +0 -1
- data/lib/simp/media/type/local.rb +18 -19
- data/lib/simp/media/type/tar.rb +37 -37
- data/lib/simp/metadata.rb +240 -258
- data/lib/simp/metadata/bootstrap_source.rb +93 -89
- data/lib/simp/metadata/buildinfo.rb +23 -23
- data/lib/simp/metadata/command.rb +60 -58
- data/lib/simp/metadata/commands.rb +1 -1
- data/lib/simp/metadata/commands/base.rb +28 -25
- data/lib/simp/metadata/commands/clone.rb +3 -5
- data/lib/simp/metadata/commands/component.rb +128 -90
- data/lib/simp/metadata/commands/delete.rb +4 -5
- data/lib/simp/metadata/commands/pry.rb +1 -3
- data/lib/simp/metadata/commands/release.rb +22 -23
- data/lib/simp/metadata/commands/releases.rb +1 -3
- data/lib/simp/metadata/commands/save.rb +10 -13
- data/lib/simp/metadata/commands/script.rb +11 -14
- data/lib/simp/metadata/commands/search.rb +15 -20
- data/lib/simp/metadata/commands/set-write-url.rb +1 -3
- data/lib/simp/metadata/commands/set-write.rb +1 -3
- data/lib/simp/metadata/commands/update.rb +9 -10
- data/lib/simp/metadata/component.rb +310 -154
- data/lib/simp/metadata/components.rb +15 -16
- data/lib/simp/metadata/engine.rb +31 -39
- data/lib/simp/metadata/fake_uri.rb +2 -0
- data/lib/simp/metadata/location.rb +99 -105
- data/lib/simp/metadata/locations.rb +19 -21
- data/lib/simp/metadata/release.rb +30 -39
- data/lib/simp/metadata/releases.rb +14 -15
- data/lib/simp/metadata/source.rb +69 -79
- data/lib/simp/metadata/version.rb +9 -0
- data/spec/simp/media/command_spec.rb +4 -5
- data/spec/simp/media/engine_spec.rb +14 -14
- data/spec/simp/media/type/control_repo_spec.rb +10 -12
- data/spec/simp/media/type/internet_spec.rb +11 -11
- data/spec/simp/media/type/iso_spec.rb +6 -7
- data/spec/simp/media/type/local_spec.rb +6 -8
- data/spec/simp/media/type/tar_spec.rb +6 -8
- data/spec/simp/metadata/buildinfo_spec.rb +19 -17
- data/spec/simp/metadata/commands/clone_spec.rb +4 -3
- data/spec/simp/metadata/component_spec.rb +43 -54
- data/spec/simp/metadata/engine_spec.rb +38 -41
- data/spec/simp/metadata/release_spec.rb +72 -79
- data/spec/simp/metadata/source_spec.rb +8 -6
- data/spec/simp/metadata_spec.rb +95 -98
- data/spec/spec_helper.rb +33 -21
- metadata +5 -3
data/lib/simp/metadata.rb
CHANGED
@@ -8,34 +8,31 @@ require 'openssl'
|
|
8
8
|
require 'json'
|
9
9
|
require 'simp/metadata/engine'
|
10
10
|
require 'simp/metadata/fake_uri'
|
11
|
-
|
12
11
|
require 'simp/metadata/source'
|
13
12
|
require 'simp/metadata/bootstrap_source'
|
14
|
-
|
15
13
|
require 'simp/metadata/releases'
|
16
14
|
require 'simp/metadata/release'
|
17
|
-
|
18
15
|
require 'simp/metadata/components'
|
19
16
|
require 'simp/metadata/component'
|
20
17
|
require 'simp/metadata/buildinfo'
|
21
|
-
|
22
18
|
require 'simp/metadata/locations'
|
23
19
|
require 'simp/metadata/location'
|
20
|
+
require 'simp/metadata/version'
|
24
21
|
|
25
22
|
module Simp
|
26
23
|
module Metadata
|
27
|
-
|
28
24
|
def self.directory_name(component, options)
|
29
|
-
if
|
30
|
-
basedir = options["target"]
|
31
|
-
else
|
25
|
+
if options['target'].nil?
|
32
26
|
raise "Must specify 'target'"
|
27
|
+
else
|
28
|
+
basedir = options['target']
|
33
29
|
end
|
30
|
+
|
34
31
|
case component.class.to_s
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
when 'String'
|
33
|
+
"#{basedir}/#{component}"
|
34
|
+
when 'Simp::Metadata::Component'
|
35
|
+
"#{basedir}/#{component.output_filename}"
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
@@ -45,290 +42,277 @@ module Simp
|
|
45
42
|
directory_name = self.directory_name(component, options)
|
46
43
|
retval = {}
|
47
44
|
case component.class.to_s
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
},
|
45
|
+
when 'String'
|
46
|
+
retval['path'] = self.directory_name(component, options)
|
47
|
+
# XXX: ToDo We can bootstrap this with a hard coded source in the simp engine
|
48
|
+
bootstrapped_components = {
|
49
|
+
'simp-metadata' => {
|
50
|
+
'url' => 'https://github.com/simp/simp-metadata',
|
51
|
+
'method' => 'git'
|
52
|
+
},
|
53
|
+
'enterprise-metadata' => {
|
54
|
+
'url' => 'simp-enterprise:///enterprise-metadata?version=master&filetype=tgz',
|
55
|
+
'method' => 'file',
|
56
|
+
'extract' => true
|
61
57
|
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
`tar -xvpf #{tarball} -C #{retval["path"]}`
|
71
|
-
else
|
72
|
-
fetch_from_url(componentspec, retval["path"], nil, options)
|
73
|
-
end
|
74
|
-
when "Simp::Metadata::Component"
|
75
|
-
retval["path"] = directory_name
|
76
|
-
if (options["url"])
|
77
|
-
location = component.primary
|
78
|
-
location.url = options["url"]
|
79
|
-
urlspec = location
|
80
|
-
location.method = "git"
|
81
|
-
else
|
82
|
-
urlspec = component.primary
|
83
|
-
end
|
84
|
-
fetch_from_url(urlspec, retval["path"], component, options)
|
58
|
+
}
|
59
|
+
# All this should be removed and be based on component.file_type
|
60
|
+
componentspec = bootstrapped_components[component]
|
61
|
+
if componentspec['extract']
|
62
|
+
tarball = "#{directory_name}.tgz"
|
63
|
+
fetch_from_url(componentspec, tarball, nil, options)
|
64
|
+
Dir.mkdir(retval['path']) unless Dir.exist?(retval['path'])
|
65
|
+
`tar -xvpf #{tarball} -C #{retval['path']}`
|
85
66
|
else
|
86
|
-
|
67
|
+
fetch_from_url(componentspec, retval['path'], nil, options)
|
68
|
+
end
|
69
|
+
when 'Simp::Metadata::Component'
|
70
|
+
retval['path'] = directory_name
|
71
|
+
if options['url']
|
72
|
+
location = component.primary
|
73
|
+
location.url = options['url']
|
74
|
+
urlspec = location
|
75
|
+
location.method = 'git'
|
76
|
+
else
|
77
|
+
urlspec = component.primary
|
78
|
+
end
|
79
|
+
fetch_from_url(urlspec, retval['path'], component, options)
|
80
|
+
else
|
81
|
+
raise "component.class=#{component.class}, #{component.class} is not in ['String', 'Simp::Metadata::Component']"
|
87
82
|
end
|
88
|
-
|
83
|
+
retval
|
89
84
|
end
|
90
85
|
|
91
86
|
def self.uri(url)
|
92
87
|
case url
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
88
|
+
when /git@/
|
89
|
+
uri = Simp::Metadata::FakeURI.new(uri)
|
90
|
+
uri.scheme = 'ssh'
|
91
|
+
uri
|
92
|
+
else
|
93
|
+
URI(url)
|
99
94
|
end
|
100
95
|
end
|
101
96
|
|
102
97
|
def self.fetch_from_url(urlspec, target, component = nil, options)
|
103
98
|
case urlspec.class.to_s
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
99
|
+
when 'Simp::Metadata::Location'
|
100
|
+
url = urlspec.url
|
101
|
+
uri = uri(url)
|
102
|
+
method = urlspec.method
|
103
|
+
when 'Hash'
|
104
|
+
url = urlspec['url']
|
105
|
+
uri = uri(urlspec['url'])
|
106
|
+
if urlspec.key?('method')
|
107
|
+
method = urlspec['method']
|
108
|
+
else
|
109
|
+
# XXX ToDo remove once the upstream simp-metadata has been updated so type != method
|
110
|
+
if urlspec.key?('type')
|
111
|
+
method = if urlspec['type'] == 'git'
|
112
|
+
'git'
|
113
|
+
else
|
114
|
+
'file'
|
115
|
+
end
|
113
116
|
else
|
114
|
-
|
115
|
-
if (urlspec.key?("type"))
|
116
|
-
if (urlspec["type"] == "git")
|
117
|
-
method = "git"
|
118
|
-
else
|
119
|
-
method = "file"
|
120
|
-
end
|
121
|
-
else
|
122
|
-
method = "file"
|
123
|
-
end
|
117
|
+
method = 'file'
|
124
118
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
119
|
+
end
|
120
|
+
when 'String'
|
121
|
+
url = urlspec
|
122
|
+
uri = uri(urlspec)
|
123
|
+
method = 'file'
|
129
124
|
end
|
125
|
+
|
130
126
|
case method
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
end
|
148
|
-
when "file"
|
149
|
-
case uri.scheme
|
150
|
-
when "simp"
|
151
|
-
fetch_simp_enterprise(url, target, component, urlspec, options)
|
152
|
-
when "simp-enterprise"
|
153
|
-
fetch_simp_enterprise(url, target, component, urlspec, options)
|
154
|
-
when "http"
|
155
|
-
fetch_simp_enterprise(url, target, component, urlspec, options)
|
156
|
-
when "https"
|
157
|
-
fetch_simp_enterprise(url, target, component, urlspec, options)
|
158
|
-
else
|
159
|
-
raise "unsupported url type #{uri.scheme}"
|
127
|
+
when 'git'
|
128
|
+
case uri.scheme
|
129
|
+
when 'simp'
|
130
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
131
|
+
when 'simp-enterprise'
|
132
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
133
|
+
else
|
134
|
+
if Dir.exist?(target)
|
135
|
+
Dir.chdir(target) do
|
136
|
+
info("Updating from #{url}")
|
137
|
+
run('git pull origin')
|
138
|
+
end
|
139
|
+
else
|
140
|
+
info("Cloning from #{url}")
|
141
|
+
run("git clone #{url} #{target}")
|
160
142
|
end
|
143
|
+
end
|
144
|
+
when 'file'
|
145
|
+
case uri.scheme
|
146
|
+
when 'simp'
|
147
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
148
|
+
when 'simp-enterprise'
|
149
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
150
|
+
when 'http'
|
151
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
152
|
+
when 'https'
|
153
|
+
fetch_simp_enterprise(url, target, component, urlspec, options)
|
154
|
+
else
|
155
|
+
raise "unsupported url type #{uri.scheme}"
|
156
|
+
end
|
161
157
|
end
|
162
158
|
end
|
163
159
|
|
164
160
|
def self.get_license_data(filename)
|
165
161
|
ret_filename = nil
|
166
|
-
ret_data =
|
162
|
+
ret_data = ''
|
167
163
|
license_data = ENV.fetch('SIMP_LICENSE_KEY', nil)
|
168
|
-
if
|
164
|
+
if !license_data.nil?
|
169
165
|
# Environment data trumps all
|
170
166
|
ret_data = license_data
|
171
|
-
if
|
167
|
+
if $simp_license_temp.nil?
|
172
168
|
$simp_license_temp = Tempfile.new('license_data')
|
173
169
|
$simp_license_temp.write(license_data)
|
174
170
|
end
|
175
171
|
ret_filename = $simp_license_temp.path
|
176
172
|
else
|
177
|
-
if
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
if
|
173
|
+
ret_filename = if filename.class.to_s == 'String'
|
174
|
+
# Attempt to load from the filename passed
|
175
|
+
filename
|
176
|
+
else
|
177
|
+
# Try to load from /etc/simp/license.key file
|
178
|
+
'/etc/simp/license.key'
|
179
|
+
end
|
180
|
+
if File.exist?(ret_filename)
|
185
181
|
ret_data = File.read(ret_filename)
|
186
182
|
else
|
187
|
-
if
|
183
|
+
if $simp_license_temp.nil?
|
188
184
|
$simp_license_temp = Tempfile.new('license_data')
|
189
|
-
$simp_license_temp.write(
|
185
|
+
$simp_license_temp.write('')
|
190
186
|
end
|
191
187
|
ret_filename = $simp_license_temp.path
|
192
188
|
end
|
193
189
|
end
|
194
|
-
|
190
|
+
[ret_filename, ret_data]
|
195
191
|
end
|
196
192
|
|
197
193
|
def self.fetch_simp_enterprise(url, destination, component, location = nil, options)
|
198
|
-
if
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
194
|
+
extract = if location.class.to_s == 'Simp::Metadata::Location'
|
195
|
+
location.extract
|
196
|
+
else
|
197
|
+
false
|
198
|
+
end
|
203
199
|
uri = uri(url)
|
200
|
+
|
204
201
|
case uri.scheme
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
version = '
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
when "version"
|
227
|
-
version = elements[1]
|
228
|
-
when "filetype"
|
229
|
-
filetype = elements[1]
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
202
|
+
when 'simp-enterprise'
|
203
|
+
scheme = 'https'
|
204
|
+
host = 'enterprise-download.simp-project.com'
|
205
|
+
filetype = 'tgz'
|
206
|
+
unless component.nil?
|
207
|
+
filetype = component.extension if component.extension != ''
|
208
|
+
end
|
209
|
+
version = 'latest'
|
210
|
+
unless component.nil?
|
211
|
+
version = component.version if component.version != ''
|
212
|
+
end
|
213
|
+
unless uri.query.nil?
|
214
|
+
uri.query.split('&').each do |element|
|
215
|
+
next unless element.class.to_s == 'String'
|
216
|
+
elements = element.split('=')
|
217
|
+
next unless elements.size > 1
|
218
|
+
case elements[0]
|
219
|
+
when 'version'
|
220
|
+
version = elements[1]
|
221
|
+
when 'filetype'
|
222
|
+
filetype = elements[1]
|
233
223
|
end
|
234
224
|
end
|
225
|
+
end
|
235
226
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
version = '
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
when "version"
|
264
|
-
version = elements[1]
|
265
|
-
when "filetype"
|
266
|
-
filetype = elements[1]
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
227
|
+
name = if !component.nil?
|
228
|
+
"/#{component.name}/#{component.binaryname}"
|
229
|
+
else
|
230
|
+
"#{uri.path}#{uri.path}#{name}-#{version}.#{filetype}"
|
231
|
+
end
|
232
|
+
path = "/products/simp-enterprise#{name}"
|
233
|
+
when 'simp'
|
234
|
+
scheme = 'https'
|
235
|
+
host = 'download.simp-project.com'
|
236
|
+
filetype = 'tgz'
|
237
|
+
unless component.nil?
|
238
|
+
filetype = component.extension if component.extension != ''
|
239
|
+
end
|
240
|
+
version = 'latest'
|
241
|
+
unless component.nil?
|
242
|
+
version = component.version if component.version != ''
|
243
|
+
end
|
244
|
+
unless uri.query.nil?
|
245
|
+
uri.query.split('&').each do |element|
|
246
|
+
next unless element.class.to_s == 'String'
|
247
|
+
elements = element.split('=')
|
248
|
+
next unless elements.size > 1
|
249
|
+
case elements[0]
|
250
|
+
when 'version'
|
251
|
+
version = elements[1]
|
252
|
+
when 'filetype'
|
253
|
+
filetype = elements[1]
|
270
254
|
end
|
271
255
|
end
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
256
|
+
end
|
257
|
+
name = if !component.nil?
|
258
|
+
"/#{component.name}/#{component.binaryname}"
|
259
|
+
else
|
260
|
+
"#{uri.path}#{uri.path}#{name}-#{version}.#{filetype}"
|
261
|
+
end
|
262
|
+
path = "/SIMP/assets#{name}"
|
263
|
+
else
|
264
|
+
scheme = uri.scheme
|
265
|
+
host = uri.host
|
266
|
+
path = uri.path
|
282
267
|
end
|
283
268
|
port = uri.port ? uri.port : 443
|
284
269
|
http = Net::HTTP.new(host, port)
|
285
|
-
case scheme
|
286
|
-
when "https"
|
287
|
-
http.use_ssl = true
|
288
|
-
case uri.scheme
|
289
|
-
when "simp-enterprise"
|
290
|
-
filename, data = self.get_license_data(options["license"])
|
291
|
-
unless (filename == nil)
|
292
|
-
http.ca_file = filename
|
293
|
-
end
|
294
|
-
unless (data == nil)
|
295
|
-
http.cert = OpenSSL::X509::Certificate.new(data)
|
296
|
-
http.key = OpenSSL::PKey::RSA.new(data)
|
297
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
298
|
-
end
|
299
270
|
|
300
|
-
|
271
|
+
case scheme
|
272
|
+
when 'https'
|
273
|
+
http.use_ssl = true
|
274
|
+
case uri.scheme
|
275
|
+
when 'simp-enterprise'
|
276
|
+
filename, data = get_license_data(options['license'])
|
277
|
+
http.ca_file = filename unless filename.nil?
|
278
|
+
unless data.nil?
|
279
|
+
http.cert = OpenSSL::X509::Certificate.new(data)
|
280
|
+
http.key = OpenSSL::PKey::RSA.new(data)
|
281
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
301
282
|
end
|
283
|
+
|
284
|
+
debug2("using the following certificate (#{filename}) for client certificate auth: #{http.cert.subject}")
|
285
|
+
end
|
302
286
|
end
|
303
287
|
info("Fetching from #{scheme}://#{host}:#{port}#{path}")
|
304
288
|
req = Net::HTTP::Get.new(path)
|
305
289
|
response = http.request(req)
|
306
290
|
case response.code
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
end
|
312
|
-
FileUtils.mkdir_p(destination)
|
313
|
-
run("tar -xvpf #{destination}.tgz -C #{destination}")
|
314
|
-
else
|
315
|
-
File.open(destination, 'w') do |f|
|
316
|
-
f.write response.body
|
317
|
-
end
|
291
|
+
when '200'
|
292
|
+
if extract
|
293
|
+
File.open("#{destination}.tgz", 'w') do |f|
|
294
|
+
f.write response.body
|
318
295
|
end
|
319
|
-
|
320
|
-
|
321
|
-
when '301'
|
322
|
-
fetch_simp_enterprise(response['location'], destination, component, location)
|
296
|
+
FileUtils.mkdir_p(destination)
|
297
|
+
run("tar -xvpf #{destination}.tgz -C #{destination}")
|
323
298
|
else
|
324
|
-
|
325
|
-
|
299
|
+
File.open(destination, 'w') do |f|
|
300
|
+
f.write response.body
|
301
|
+
end
|
302
|
+
end
|
303
|
+
when '302'
|
304
|
+
fetch_simp_enterprise(response['location'], destination, component, location)
|
305
|
+
when '301'
|
306
|
+
fetch_simp_enterprise(response['location'], destination, component, location)
|
307
|
+
else
|
308
|
+
$errorcode = response.code.to_i
|
309
|
+
raise "HTTP Error Code: #{response.code}"
|
326
310
|
end
|
327
311
|
end
|
328
312
|
|
329
313
|
def self.run(command)
|
330
314
|
exitcode = nil
|
331
|
-
Open3.popen3(command) do |
|
315
|
+
Open3.popen3(command) do |_stdin, stdout, stderr, thread|
|
332
316
|
pid = thread.pid
|
333
317
|
Simp::Metadata.debug2(stdout.read.chomp)
|
334
318
|
Simp::Metadata.debug1(stderr.read.chomp)
|
@@ -340,7 +324,7 @@ module Simp
|
|
340
324
|
def self.level?(level)
|
341
325
|
setlevel = Simp::Metadata.convert_level($simp_metadata_debug_level)
|
342
326
|
checklevel = Simp::Metadata.convert_level(level)
|
343
|
-
if
|
327
|
+
if checklevel <= setlevel
|
344
328
|
true
|
345
329
|
else
|
346
330
|
false
|
@@ -349,67 +333,65 @@ module Simp
|
|
349
333
|
|
350
334
|
def self.convert_level(level)
|
351
335
|
case level
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
336
|
+
when 'disabled'
|
337
|
+
0
|
338
|
+
when 'critical'
|
339
|
+
1
|
340
|
+
when 'error'
|
341
|
+
2
|
342
|
+
when 'warning'
|
343
|
+
3
|
344
|
+
when 'info'
|
345
|
+
4
|
346
|
+
when 'debug1'
|
347
|
+
5
|
348
|
+
when 'debug2'
|
349
|
+
6
|
350
|
+
else
|
351
|
+
3
|
368
352
|
end
|
369
353
|
end
|
370
354
|
|
371
355
|
def self.print_message(prefix, message)
|
372
356
|
message.split("\n").each do |line|
|
373
357
|
output = "#{prefix}: #{line}"
|
374
|
-
unless
|
375
|
-
STDERR.puts output
|
376
|
-
end
|
358
|
+
STDERR.puts output unless $simp_metadata_debug_output_disabled
|
377
359
|
end
|
378
360
|
end
|
379
361
|
|
380
362
|
def self.debug1(message)
|
381
363
|
if Simp::Metadata.level?('debug1')
|
382
|
-
Simp::Metadata.print_message(
|
364
|
+
Simp::Metadata.print_message('DEBUG1', message)
|
383
365
|
end
|
384
366
|
end
|
385
367
|
|
386
368
|
def self.debug2(message)
|
387
369
|
if Simp::Metadata.level?('debug2')
|
388
|
-
Simp::Metadata.print_message(
|
370
|
+
Simp::Metadata.print_message('DEBUG2', message)
|
389
371
|
end
|
390
372
|
end
|
391
373
|
|
392
374
|
def self.info(message)
|
393
375
|
if Simp::Metadata.level?('info')
|
394
|
-
Simp::Metadata.print_message(
|
376
|
+
Simp::Metadata.print_message('INFO', message)
|
395
377
|
end
|
396
378
|
end
|
397
379
|
|
398
380
|
def self.warning(message)
|
399
381
|
if Simp::Metadata.level?('warning')
|
400
|
-
Simp::Metadata.print_message(
|
382
|
+
Simp::Metadata.print_message('WARN', message)
|
401
383
|
end
|
402
384
|
end
|
403
385
|
|
404
386
|
def self.error(message)
|
405
387
|
if Simp::Metadata.level?('error')
|
406
|
-
Simp::Metadata.print_message(
|
388
|
+
Simp::Metadata.print_message('ERROR', message)
|
407
389
|
end
|
408
390
|
end
|
409
391
|
|
410
392
|
def self.critical(message)
|
411
393
|
if Simp::Metadata.level?('critical')
|
412
|
-
Simp::Metadata.print_message(
|
394
|
+
Simp::Metadata.print_message('CRITICAL', message)
|
413
395
|
end
|
414
396
|
end
|
415
397
|
end
|