MrMurano 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO.taskpaper +1 -0
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/commands/config.rb +5 -6
- data/lib/MrMurano/commands/keystore.rb +34 -6
- data/lib/MrMurano/commands/logs.rb +78 -75
- data/lib/MrMurano/commands/productWrite.rb +25 -0
- data/lib/MrMurano/http.rb +1 -1
- data/lib/MrMurano/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb66958edb807052d6d7e8ea8673cf1137dea0f7
|
4
|
+
data.tar.gz: 84d50836cafec96fb0bd3c6cc92ecd2c78b92a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bafcf0de9d2466d5e6262217317ee7f3824baf012645ed5136388a99e34cd91bf87b73751435c78ef62acbcd656723a7c28988ce23b98dd7e566c0355429f42f
|
7
|
+
data.tar.gz: d09ef03f75a47cb230949635d1562e9ce2e076a2acc617cfd4281ff486146884ea79ad89b63582bca687314623848dc41316be2446e4deb8b69ab338084674a1
|
data/TODO.taskpaper
CHANGED
data/lib/MrMurano/commands.rb
CHANGED
@@ -9,6 +9,7 @@ require 'MrMurano/commands/exportImport'
|
|
9
9
|
require 'MrMurano/commands/keystore'
|
10
10
|
require 'MrMurano/commands/logs'
|
11
11
|
require 'MrMurano/commands/productSpec'
|
12
|
+
require 'MrMurano/commands/productWrite'
|
12
13
|
require 'MrMurano/commands/status'
|
13
14
|
require 'MrMurano/commands/sync'
|
14
15
|
require 'MrMurano/commands/timeseries'
|
@@ -11,7 +11,6 @@ command :config do |c|
|
|
11
11
|
c.example %{See what the current combined config is}, 'mr config --dump'
|
12
12
|
c.example %{Query a value}, 'mr config solution.id'
|
13
13
|
c.example %{Set a new value; writing to the project config file}, 'mr config solution.id XXXXXXXX'
|
14
|
-
c.example %{Set a new value; writing to the private config file}, 'mr config --private solution.id XXXXXXXX'
|
15
14
|
c.example %{Set a new value; writing to the user config file}, 'mr config --user user.name my@email.address'
|
16
15
|
c.example %{Unset a value in a configfile. (lower scopes will become visible if set)},
|
17
16
|
'mr config diff.cmd --unset'
|
@@ -20,7 +19,7 @@ command :config do |c|
|
|
20
19
|
c.option '--system', 'Use only the system config file. (/etc/mrmuranorc)'
|
21
20
|
c.option '--user', 'Use only the config file in $HOME (.mrmuranorc)'
|
22
21
|
c.option '--project', 'Use only the config file in the project (.mrmuranorc)'
|
23
|
-
c.option '--
|
22
|
+
c.option '--env', 'Use only the config file from $MR_CONFIGFILE'
|
24
23
|
c.option '--specified', 'Use only the config file from the --config option.'
|
25
24
|
|
26
25
|
c.option '--unset', 'Remove key from config file.'
|
@@ -34,14 +33,14 @@ command :config do |c|
|
|
34
33
|
say_error "Need a config key"
|
35
34
|
elsif args.count == 1 and not options.unset then
|
36
35
|
options.defaults :system=>false, :user=>false, :project=>false,
|
37
|
-
:specified=>false, :
|
36
|
+
:specified=>false, :env=>false
|
38
37
|
|
39
38
|
# For read, if no scopes, than all. Otherwise just those specified
|
40
39
|
scopes = []
|
41
40
|
scopes << :system if options.system
|
42
41
|
scopes << :user if options.user
|
43
42
|
scopes << :project if options.project
|
44
|
-
scopes << :
|
43
|
+
scopes << :env if options.env
|
45
44
|
scopes << :specified if options.specified
|
46
45
|
scopes = MrMurano::Config::CFG_SCOPES if scopes.empty?
|
47
46
|
|
@@ -49,13 +48,13 @@ command :config do |c|
|
|
49
48
|
else
|
50
49
|
|
51
50
|
options.defaults :system=>false, :user=>false, :project=>true,
|
52
|
-
:specified=>false, :
|
51
|
+
:specified=>false, :env=>false
|
53
52
|
# For write, if scope is specified, only write to that scope.
|
54
53
|
scope = :project
|
55
54
|
scope = :system if options.system
|
56
55
|
scope = :user if options.user
|
57
56
|
scope = :project if options.project
|
58
|
-
scope = :
|
57
|
+
scope = :env if options.env
|
59
58
|
scope = :specified if options.specified
|
60
59
|
|
61
60
|
args[1] = nil if options.unset
|
@@ -84,23 +84,51 @@ command 'keystore delete' do |c|
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
alias_command 'keystore rm', 'keystore delete'
|
87
|
+
alias_command 'keystore del', 'keystore delete'
|
87
88
|
|
88
89
|
command 'keystore command' do |c|
|
89
|
-
c.syntax = %{mr keystore command <
|
90
|
+
c.syntax = %{mr keystore command <command> <key> <args...>}
|
90
91
|
c.summary = %{Call some Redis commands in the Keystore}
|
91
92
|
c.description = %{Call some Redis commands in the Keystore.
|
92
93
|
|
93
94
|
Only a subset of all Redis commands is supported.
|
94
95
|
See http://docs.exosite.com/murano/services/keystore/#command for current list.
|
95
96
|
}
|
96
|
-
c.example %{mr keystore command mykey
|
97
|
-
c.example %{mr keystore command mykey
|
98
|
-
c.example %{mr keystore command mykey
|
97
|
+
c.example %{mr keystore command lpush mykey myvalue}, %{Push a value onto list}
|
98
|
+
c.example %{mr keystore command lpush mykey A B C}, %{Push three values onto list}
|
99
|
+
c.example %{mr keystore command lrem mykey 0 B}, %{Remove all B values from list}
|
99
100
|
c.action do |args,options|
|
100
|
-
|
101
|
-
|
101
|
+
if args.count < 2 then
|
102
|
+
say_error "Not enough params"
|
103
|
+
else
|
104
|
+
sol = MrMurano::Keystore.new
|
105
|
+
ret = sol.command(args[1], args[0], args[2..-1])
|
106
|
+
if ret.has_key?(:value) then
|
107
|
+
puts ret[:value]
|
108
|
+
else
|
109
|
+
say_error "#{ret[:code]}: #{ret.message}"
|
110
|
+
pp ret[:error] if ($cfg['tool.debug'] and ret.has_key?(:error))
|
111
|
+
end
|
112
|
+
end
|
102
113
|
end
|
103
114
|
end
|
104
115
|
alias_command 'keystore cmd', 'keystore command'
|
105
116
|
|
117
|
+
# A bunch of common REDIS commands that are suported in Murano
|
118
|
+
alias_command 'keystore lpush', 'keystore command', 'lpush'
|
119
|
+
alias_command 'keystore lindex', 'keystore command', 'lindex'
|
120
|
+
alias_command 'keystore llen', 'keystore command', 'llen'
|
121
|
+
alias_command 'keystore linsert', 'keystore command', 'linsert'
|
122
|
+
alias_command 'keystore lrange', 'keystore command', 'lrange'
|
123
|
+
alias_command 'keystore lrem', 'keystore command', 'lrem'
|
124
|
+
alias_command 'keystore lset', 'keystore command', 'lset'
|
125
|
+
alias_command 'keystore ltrim', 'keystore command', 'ltrim'
|
126
|
+
alias_command 'keystore rpop', 'keystore command', 'rpop'
|
127
|
+
alias_command 'keystore rpush', 'keystore command', 'rpush'
|
128
|
+
alias_command 'keystore sadd', 'keystore command', 'sadd'
|
129
|
+
alias_command 'keystore srem', 'keystore command', 'srem'
|
130
|
+
alias_command 'keystore scard', 'keystore command', 'scard'
|
131
|
+
alias_command 'keystore smembers', 'keystore command', 'smembers'
|
132
|
+
alias_command 'keystore spop', 'keystore command', 'spop'
|
133
|
+
|
106
134
|
# vim: set ai et sw=2 ts=2 :
|
@@ -20,100 +20,103 @@ command :logs do |c|
|
|
20
20
|
|
21
21
|
sol = MrMurano::Solution.new
|
22
22
|
begin
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ret
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
line.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
|
40
|
-
if options.pretty then
|
41
|
-
js = JSON.parse(m, {:allow_nan=>true, :create_additions=>false})
|
42
|
-
ret = JSON.pretty_generate(js).to_s
|
43
|
-
ret[0] = ret[0].color(:magenta)
|
44
|
-
ret[-1] = ret[-1].color(:magenta)
|
45
|
-
ret
|
46
|
-
else
|
47
|
-
m.sub!(/^{/){|ml| ml.color(:magenta)}
|
48
|
-
m.sub!(/}$/){|ml| ml.color(:magenta)}
|
49
|
-
m
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
out = line
|
54
|
-
|
55
|
-
elsif line.kind_of?(Hash) then
|
56
|
-
out=""
|
57
|
-
|
58
|
-
if line.has_key?(:type) then
|
59
|
-
out << "#{line[:type]} ".upcase.color(:red).background(:aliceblue)
|
60
|
-
end
|
61
|
-
out << "[#{line[:subject]}]".color(:red).background(:aliceblue)
|
62
|
-
out << " "
|
63
|
-
if options.localtime then
|
64
|
-
curtime = Time.at(line[:timestamp]).localtime.to_datetime.iso8601(3)
|
65
|
-
else
|
66
|
-
curtime = Time.at(line[:timestamp]).to_datetime.iso8601(3)
|
67
|
-
end
|
68
|
-
out << curtime.color(:blue)
|
69
|
-
out << ":\n"
|
70
|
-
if line.has_key?(:data) then
|
71
|
-
data = line[:data]
|
23
|
+
begin
|
24
|
+
ret = sol.get('/logs') # TODO: ('/logs?polling=true') Currently ignored.
|
25
|
+
|
26
|
+
if ret.kind_of?(Hash) and ret.has_key?(:items) then
|
27
|
+
ret[:items].reverse.each do |line|
|
28
|
+
curtime = ""
|
29
|
+
if line.kind_of?(String) then
|
30
|
+
|
31
|
+
line.sub!(/^\[[^\]]*\]/) {|m| m.color(:red).background(:aliceblue)}
|
32
|
+
line.sub!(/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)(?:\+\d\d:\d\d)/) {|m|
|
33
|
+
if options.localtime then
|
34
|
+
m = DateTime.parse(m).to_time.localtime.to_datetime.iso8601(3)
|
35
|
+
end
|
36
|
+
curtime = m
|
37
|
+
m.color(:blue)
|
38
|
+
}
|
72
39
|
|
73
|
-
|
74
|
-
out << "---------\nrequest:"
|
40
|
+
line.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
|
75
41
|
if options.pretty then
|
76
|
-
|
42
|
+
js = JSON.parse(m, {:allow_nan=>true, :create_additions=>false})
|
43
|
+
ret = JSON.pretty_generate(js).to_s
|
77
44
|
ret[0] = ret[0].color(:magenta)
|
78
45
|
ret[-1] = ret[-1].color(:magenta)
|
79
|
-
|
46
|
+
ret
|
80
47
|
else
|
81
|
-
|
48
|
+
m.sub!(/^{/){|ml| ml.color(:magenta)}
|
49
|
+
m.sub!(/}$/){|ml| ml.color(:magenta)}
|
50
|
+
m
|
82
51
|
end
|
52
|
+
end
|
53
|
+
|
54
|
+
out = line
|
55
|
+
|
56
|
+
elsif line.kind_of?(Hash) then
|
57
|
+
out=""
|
58
|
+
|
59
|
+
if line.has_key?(:type) then
|
60
|
+
out << "#{line[:type]} ".upcase.color(:red).background(:aliceblue)
|
61
|
+
end
|
62
|
+
out << "[#{line[:subject]}]".color(:red).background(:aliceblue)
|
63
|
+
out << " "
|
64
|
+
if options.localtime then
|
65
|
+
curtime = Time.at(line[:timestamp]).localtime.to_datetime.iso8601(3)
|
66
|
+
else
|
67
|
+
curtime = Time.at(line[:timestamp]).to_datetime.iso8601(3)
|
68
|
+
end
|
69
|
+
out << curtime.color(:blue)
|
70
|
+
out << ":\n"
|
71
|
+
if line.has_key?(:data) then
|
72
|
+
data = line[:data]
|
73
|
+
|
74
|
+
if data.kind_of?(Hash) and data.has_key?(:request) and data.has_key?(:response) then
|
75
|
+
out << "---------\nrequest:"
|
76
|
+
if options.pretty then
|
77
|
+
ret = JSON.pretty_generate(data[:request]).to_s
|
78
|
+
ret[0] = ret[0].color(:magenta)
|
79
|
+
ret[-1] = ret[-1].color(:magenta)
|
80
|
+
out << ret
|
81
|
+
else
|
82
|
+
out << data[:request].to_json
|
83
|
+
end
|
84
|
+
|
85
|
+
out << "\n---------\nresponse:"
|
86
|
+
if options.pretty then
|
87
|
+
ret = JSON.pretty_generate(data[:response]).to_s
|
88
|
+
ret[0] = ret[0].color(:magenta)
|
89
|
+
ret[-1] = ret[-1].color(:magenta)
|
90
|
+
out << ret
|
91
|
+
else
|
92
|
+
out << data[:response].to_json
|
93
|
+
end
|
83
94
|
|
84
|
-
out << "\n---------\nresponse:"
|
85
|
-
if options.pretty then
|
86
|
-
ret = JSON.pretty_generate(data[:response]).to_s
|
87
|
-
ret[0] = ret[0].color(:magenta)
|
88
|
-
ret[-1] = ret[-1].color(:magenta)
|
89
|
-
out << ret
|
90
95
|
else
|
91
|
-
out << data
|
96
|
+
out << data.to_s
|
92
97
|
end
|
93
98
|
|
94
99
|
else
|
95
|
-
out <<
|
100
|
+
out << line.to_s
|
96
101
|
end
|
97
102
|
|
98
|
-
else
|
99
|
-
out << line.to_s
|
100
103
|
end
|
101
104
|
|
102
|
-
|
105
|
+
if curtime > lasttime then
|
106
|
+
lasttime = curtime
|
107
|
+
puts out
|
108
|
+
end
|
103
109
|
|
104
|
-
if curtime > lasttime then
|
105
|
-
lasttime = curtime
|
106
|
-
puts out
|
107
110
|
end
|
108
|
-
|
111
|
+
else
|
112
|
+
say_error "Couldn't get logs: #{ret}"
|
113
|
+
break
|
109
114
|
end
|
110
|
-
else
|
111
|
-
say_error "Couldn't get logs: #{ret}"
|
112
|
-
break
|
113
|
-
end
|
114
115
|
|
115
|
-
|
116
|
-
|
116
|
+
sleep(options.pollrate) if options.follow
|
117
|
+
end while options.follow
|
118
|
+
rescue Interrupt => e
|
119
|
+
end
|
117
120
|
|
118
121
|
end
|
119
122
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'MrMurano/Product'
|
2
|
+
|
3
|
+
command 'product write' do |c|
|
4
|
+
c.syntax = %{mr product write <sn> <alias> <value> ([<alias> <value>]…)}
|
5
|
+
c.summary = %{Write values into the product}
|
6
|
+
|
7
|
+
c.action do |args,options|
|
8
|
+
sn = args.shift
|
9
|
+
if (args.count % 2) != 0 then
|
10
|
+
say_error "Last alias is missing a value to write."
|
11
|
+
else
|
12
|
+
data = Hash[*args]
|
13
|
+
prd = MrMurano::Product.new
|
14
|
+
ret = prd.write(sn, data)
|
15
|
+
ret.each_pair do |k,v|
|
16
|
+
if v == 'ok' then
|
17
|
+
say "#{k.to_s}: #{v}"
|
18
|
+
else
|
19
|
+
say_error "#{k.to_s}: #{v}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# vim: set ai et sw=2 ts=2 :
|
data/lib/MrMurano/http.rb
CHANGED
data/lib/MrMurano/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MrMurano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
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: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/MrMurano/commands/keystore.rb
|
219
219
|
- lib/MrMurano/commands/logs.rb
|
220
220
|
- lib/MrMurano/commands/productSpec.rb
|
221
|
+
- lib/MrMurano/commands/productWrite.rb
|
221
222
|
- lib/MrMurano/commands/status.rb
|
222
223
|
- lib/MrMurano/commands/sync.rb
|
223
224
|
- lib/MrMurano/commands/timeseries.rb
|