MuranoCLI 3.0.5 → 3.0.6
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/lib/MrMurano/commands/devices.rb +2 -2
- data/lib/MrMurano/commands/tsdb.rb +99 -30
- data/lib/MrMurano/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7674b5979fb03799795303b94e871e2021a2f44
|
4
|
+
data.tar.gz: 3f15da4d29cb1482e396e89d84971be9783d15b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1847646d933b575158caec9c9c3a0c2e4d092323253f077929a5dc14a5868b6fb911460ccbda8431d58384aa6ef22f0f51889c6410f02baa835046ba66a8c927
|
7
|
+
data.tar.gz: c17643abde19389b0513a27247197ea06cb64dc77f15bba0df5b37b77b84066caa8a947db90c7276f38990694ab66f9e2b3b26b24566c9fff074043a47b15799
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.10.04 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -239,7 +239,7 @@ Enables Identifiers, creating devices, or digital shadows, in Murano.
|
|
239
239
|
|
240
240
|
unless options.auth.nil?
|
241
241
|
options.auth = options.auth.to_sym
|
242
|
-
unless MrMurano::Gateway::Device
|
242
|
+
unless MrMurano::Gateway::Device::DEVICE_AUTH_TYPES.include?(options.auth)
|
243
243
|
MrMurano::Verbose.error("unrecognized --auth: #{options.auth}")
|
244
244
|
exit 1
|
245
245
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.10.05 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -156,11 +156,7 @@ Also, many date-time formats can be parsed and will be converted to microseconds
|
|
156
156
|
c.example 'murano tsdb query hum --sampling_size 30m', 'Get one hum entry from each 30 minute chunk of time'
|
157
157
|
c.example 'murano tsdb query hum --sampling_size 30m --aggregate avg', 'Get average hum entry from each 30 minute chunk of time'
|
158
158
|
|
159
|
-
|
160
|
-
# SKIP: c.verify_arg_count!(args)
|
161
|
-
|
162
|
-
sol = MrMurano::ServiceConfigs::Tsdb.new
|
163
|
-
|
159
|
+
def query_from_args(args)
|
164
160
|
query = {}
|
165
161
|
tags = {}
|
166
162
|
metrics = []
|
@@ -176,7 +172,10 @@ Also, many date-time formats can be parsed and will be converted to microseconds
|
|
176
172
|
end
|
177
173
|
query[:tags] = tags unless tags.empty?
|
178
174
|
query[:metrics] = metrics unless metrics.empty?
|
175
|
+
query
|
176
|
+
end
|
179
177
|
|
178
|
+
def query_add_options(query, options, sol)
|
180
179
|
# A query without any metrics is invalid. So if the user didn't provide any,
|
181
180
|
# look up all of them (well, frist however many) and use that list.
|
182
181
|
if query[:metrics].to_s.empty?
|
@@ -209,42 +208,112 @@ Also, many date-time formats can be parsed and will be converted to microseconds
|
|
209
208
|
query[:order_by] = options.order_by unless options.order_by.nil?
|
210
209
|
|
211
210
|
query[:fill] = options.fill unless options.fill.nil?
|
212
|
-
|
213
|
-
|
211
|
+
return if options.aggregate.nil?
|
212
|
+
query[:aggregate] = options.aggregate.split(',')
|
213
|
+
end
|
214
|
+
|
215
|
+
def unpack_aggregate(query, options, dd)
|
216
|
+
# If aggregated, then we need to break up the columns. since each is now a
|
217
|
+
# hash of the aggregated functions
|
218
|
+
|
219
|
+
# 2017-10-05: Some examples.
|
220
|
+
#
|
221
|
+
# When using, e.g., --sampling_size 30m
|
222
|
+
#
|
223
|
+
# { :values=>[["2017-10-05T13:30:00.000000+00:00", {:avg=>360.5}]],
|
224
|
+
# :tags=>{},
|
225
|
+
# :metrics=>["temperature"],
|
226
|
+
# :columns=>["time", "temperature"] }
|
227
|
+
#
|
228
|
+
# When not using --sampling_size, e.g.,
|
229
|
+
#
|
230
|
+
# { :values=>{:temperature=>{:avg=>360.5}},
|
231
|
+
# :tags=>{},
|
232
|
+
# :metrics=>["temperature"] }
|
233
|
+
#
|
234
|
+
# Or, if there are not metrics in the specified time frame,
|
235
|
+
#
|
236
|
+
# { :values=>{:temperature=>{:avg=>nil}},
|
237
|
+
# :tags=>{},
|
238
|
+
# :metrics=>["temperature"] }
|
239
|
+
|
240
|
+
if options.aggregate.nil?
|
241
|
+
# Return just :columns and :values to not pollute other
|
242
|
+
# output, i.e., --json, etc.
|
243
|
+
[dd[:columns], dd[:values]]
|
244
|
+
elsif options.sampling_size.nil?
|
245
|
+
# dd[:values] is a Hash.
|
246
|
+
unpack_grouped_values(query, dd)
|
247
|
+
else
|
248
|
+
# dd[:values] is a list.
|
249
|
+
unpack_raw_values(query, dd)
|
214
250
|
end
|
251
|
+
end
|
215
252
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
253
|
+
def unpack_raw_values(query, dd)
|
254
|
+
vals = dd[:values].map do |row|
|
255
|
+
row.map do |value|
|
256
|
+
if value.is_a? Hash
|
257
|
+
query[:aggregate].map { |qa| value[qa.to_sym] }
|
258
|
+
elsif value == 'none'
|
259
|
+
# Fill in empty cells, one for each aggregate.
|
260
|
+
query[:aggregate].map { 'none' }
|
261
|
+
else
|
262
|
+
value
|
263
|
+
end
|
264
|
+
end.flatten
|
265
|
+
end
|
266
|
+
cols = dd[:columns].map do |col|
|
267
|
+
if col == 'time'
|
268
|
+
col
|
269
|
+
else
|
270
|
+
query[:aggregate].map { |qa| "#{col}.#{qa}" }
|
271
|
+
end
|
272
|
+
end.flatten!
|
273
|
+
[cols, vals]
|
274
|
+
end
|
275
|
+
|
276
|
+
def unpack_grouped_values(query, dd)
|
277
|
+
vals = []
|
278
|
+
cols = ['metric'] + query[:aggregate]
|
279
|
+
dd[:values].map do |metric, results|
|
280
|
+
row = [metric]
|
281
|
+
query[:aggregate].each do |agg|
|
282
|
+
agg = agg.to_sym
|
283
|
+
if !results.key? agg
|
284
|
+
row += ['none']
|
285
|
+
else
|
286
|
+
row += [results[agg] || '']
|
229
287
|
end
|
230
|
-
dd[:columns].map! do |col|
|
231
|
-
if col == 'time'
|
232
|
-
col
|
233
|
-
else
|
234
|
-
query[:aggregate].map { |qa| "#{col}.#{qa}" }
|
235
|
-
end
|
236
|
-
end.flatten!
|
237
288
|
end
|
289
|
+
vals += [row]
|
290
|
+
end
|
291
|
+
[cols, vals]
|
292
|
+
end
|
293
|
+
|
294
|
+
def query_solution_query(query, options, sol)
|
295
|
+
io = File.open(options.output, 'w') if options.output
|
296
|
+
results = sol.query(query)
|
297
|
+
sol.outf(results) do |dd, ios|
|
298
|
+
cols, vals = unpack_aggregate(query, options, dd)
|
238
299
|
sol.tabularize(
|
239
300
|
{
|
240
|
-
headers:
|
241
|
-
rows:
|
301
|
+
headers: cols,
|
302
|
+
rows: vals,
|
242
303
|
},
|
243
304
|
ios
|
244
305
|
)
|
245
306
|
end
|
246
307
|
io.close unless io.nil?
|
247
308
|
end
|
309
|
+
|
310
|
+
c.action do |args, options|
|
311
|
+
# SKIP: c.verify_arg_count!(args)
|
312
|
+
query = query_from_args(args)
|
313
|
+
sol = MrMurano::ServiceConfigs::Tsdb.new
|
314
|
+
query_add_options(query, options, sol)
|
315
|
+
query_solution_query(query, options, sol)
|
316
|
+
end
|
248
317
|
end
|
249
318
|
|
250
319
|
command 'tsdb list tags' do |c|
|
data/lib/MrMurano/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.
|
1
|
+
# Last Modified: 2017.10.06 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -26,7 +26,7 @@ module MrMurano
|
|
26
26
|
# '3.0.0-beta.2' is changed to '3.0.0.pre.beta.2'
|
27
27
|
# which breaks our build (which expects the version to match herein).
|
28
28
|
# So stick to using the '.pre.X' syntax, which ruby/gems knows.
|
29
|
-
VERSION = '3.0.
|
29
|
+
VERSION = '3.0.6'
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MuranoCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: certified
|