rboss 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -2
- data/bin/rboss-cli +30 -10
- data/lib/rboss/cli/{jboss_cli.rb → invoker.rb} +62 -6
- data/lib/rboss/cli/mappings/resources/connector.yaml +1 -1
- data/lib/rboss/cli/mappings/resources/datasource.yaml +4 -4
- data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +1 -1
- data/lib/rboss/cli/mappings/resources/server.yaml +14 -5
- data/lib/rboss/cli/mappings.rb +4 -0
- data/lib/rboss/cli/resource.rb +133 -23
- data/lib/rboss/cli/result_parser.rb +80 -0
- data/lib/rboss/components/resource.rb +1 -2
- data/lib/rboss/components/slimming.rb +1 -1
- data/lib/rboss/twiddle/mbean.rb +2 -2
- data/lib/rboss/utils.rb +14 -1
- data/lib/rboss/version.rb +1 -1
- data/lib/rboss/view/colorizers.rb +28 -4
- data/lib/rboss.rb +4 -4
- metadata +4 -3
data/README.md
CHANGED
@@ -142,8 +142,12 @@ limits by using a :health key:
|
|
142
142
|
:properties => %W(activeCount currentFree maxAvailable),
|
143
143
|
:header => ['Active Count', 'Current Free', 'Max Available'],
|
144
144
|
:health => {
|
145
|
-
:
|
146
|
-
|
145
|
+
:active_count => {
|
146
|
+
:percentage => { # uses a percentage based check
|
147
|
+
:max => :max_available,
|
148
|
+
:using => :active_count #or use :free if you have the number of free resources
|
149
|
+
}
|
150
|
+
}
|
147
151
|
},
|
148
152
|
:scan => proc do
|
149
153
|
# queries and pass each result do the block
|
data/bin/rboss-cli
CHANGED
@@ -32,8 +32,10 @@ require 'yummi'
|
|
32
32
|
params = {}
|
33
33
|
@conf_dir = File.expand_path "~/.rboss"
|
34
34
|
servers_file = "#@conf_dir/jboss-cli-servers.yaml"
|
35
|
-
@
|
35
|
+
@resources = {}
|
36
|
+
@parameters = {}
|
36
37
|
@servers_file = File.expand_path(servers_file)
|
38
|
+
@operation = :read_resource
|
37
39
|
save = false
|
38
40
|
params[:jboss_home] = (ENV["JBOSS_HOME"] or ENV["RBOSS_CLI_JBOSS_HOME"] or Dir.pwd)
|
39
41
|
params[:host] = '127.0.0.1'
|
@@ -68,7 +70,7 @@ end
|
|
68
70
|
opts.on('--save SERVER_NAME', "Saves the server configuration in #{servers_file}") do |server|
|
69
71
|
save = server
|
70
72
|
end
|
71
|
-
opts.on('--loop INTERVAL', Float, '
|
73
|
+
opts.on('--loop INTERVAL', Float, 'Run inside a loop') do |interval|
|
72
74
|
@loop = true
|
73
75
|
@interval = interval
|
74
76
|
end
|
@@ -86,21 +88,35 @@ opts.on('-v', '--verbose', 'Displays jboss-cli commands before execution') do
|
|
86
88
|
params[:log_level] = Logger::DEBUG
|
87
89
|
end
|
88
90
|
|
91
|
+
opts.on('-o', '--operation NAME',
|
92
|
+
'Sets the operation to invoke (Defaults to "read-resource")') do |name|
|
93
|
+
@operation = name
|
94
|
+
end
|
95
|
+
|
96
|
+
opts.on('--skip-optional', 'Skips optional parameters while invoking a command ') do
|
97
|
+
params[:skip_optional] = true
|
98
|
+
end
|
99
|
+
|
100
|
+
opts.on('-a', '--args PARAMETERS', Array,
|
101
|
+
'Specifies parameters in form of (name=value) for use with operation') do |parameters|
|
102
|
+
@parameters = Hash[(parameters.collect {|p| p.split(/=/,2)})]
|
103
|
+
end
|
104
|
+
|
89
105
|
RBoss::Cli::Mappings.resource_mappings.each do |name, config|
|
90
106
|
if config[:scan]
|
91
107
|
opts.on("--#{name} [NAMES]", Array, config[:description]) do |resources|
|
92
|
-
@
|
108
|
+
@resources[name] = resources
|
93
109
|
end
|
94
110
|
else
|
95
111
|
opts.on("--#{name}", config[:description]) do
|
96
|
-
@
|
112
|
+
@resources[name] = true
|
97
113
|
end
|
98
114
|
end
|
99
115
|
end
|
100
116
|
|
101
117
|
opts.on('--all', 'Display all available info') do
|
102
118
|
RBoss::Cli::Mappings.resource_mappings.each do |name, config|
|
103
|
-
@
|
119
|
+
@resources[name] = nil unless config[:derived]
|
104
120
|
end
|
105
121
|
end
|
106
122
|
|
@@ -131,13 +147,17 @@ if save
|
|
131
147
|
puts "Configuration saved!"
|
132
148
|
end
|
133
149
|
|
134
|
-
puts opts if @
|
150
|
+
puts opts if @resources.empty?
|
135
151
|
|
136
152
|
def execute_actions
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
153
|
+
begin
|
154
|
+
content = @jboss_cli.invoke(@operation, @resources, @parameters)
|
155
|
+
system "clear" if @loop
|
156
|
+
puts Yummi.colorize(Time.now.strftime("At %H:%M:%S%n"), :white) if @loop
|
157
|
+
puts content.chomp
|
158
|
+
rescue RBoss::Cli::InvocationFailed => e
|
159
|
+
puts Yummi::colorize e.message, :intense_red
|
160
|
+
end
|
141
161
|
end
|
142
162
|
|
143
163
|
while @loop
|
@@ -20,17 +20,21 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
+
require_relative 'result_parser'
|
23
24
|
require_relative 'resource'
|
24
25
|
require_relative 'mappings'
|
25
26
|
|
26
27
|
require 'logger'
|
27
28
|
|
29
|
+
require 'yummi'
|
30
|
+
require 'yaml'
|
31
|
+
|
28
32
|
module RBoss
|
29
33
|
|
30
34
|
module Cli
|
31
35
|
|
32
36
|
class Invoker
|
33
|
-
include RBoss::Cli::Mappings, RBoss::Platform
|
37
|
+
include RBoss::Cli::Mappings, RBoss::Platform, RBoss::Cli::ResultParser
|
34
38
|
|
35
39
|
attr_reader :server, :host, :port, :user, :password
|
36
40
|
|
@@ -58,6 +62,8 @@ module RBoss
|
|
58
62
|
end
|
59
63
|
@logger.formatter = formatter
|
60
64
|
end
|
65
|
+
|
66
|
+
@skip_optional = params[:skip_optional]
|
61
67
|
end
|
62
68
|
|
63
69
|
def command
|
@@ -68,24 +74,74 @@ module RBoss
|
|
68
74
|
command
|
69
75
|
end
|
70
76
|
|
71
|
-
def
|
77
|
+
def invoke(operation, resources, parameters)
|
72
78
|
buff = ""
|
73
|
-
|
79
|
+
resources.each do |key, resource_names|
|
74
80
|
if resource_mappings.has_key? key
|
75
81
|
mapping = resource_mappings[key]
|
76
|
-
|
77
|
-
|
82
|
+
resource = RBoss::Cli::Resource::new(self, mapping)
|
83
|
+
result = resource.invoke(operation, resource_names, parameters)
|
84
|
+
buff << result.to_s if result
|
78
85
|
end
|
79
86
|
end
|
80
87
|
buff
|
81
88
|
end
|
82
89
|
|
90
|
+
def gets_and_invoke(path, operation, parameters)
|
91
|
+
result = result("#{path}:read-operation-description(name=#{operation})")
|
92
|
+
result["request-properties"] ||= {}
|
93
|
+
puts Yummi::colorize("Please input the requested parameters", :yellow)
|
94
|
+
builder = CommandBuilder::new operation
|
95
|
+
result["request-properties"].each do |name, detail|
|
96
|
+
next if (@skip_optional and not detail['required'] or detail['default'])
|
97
|
+
input = parameters[name]
|
98
|
+
unless input
|
99
|
+
puts Yummi::colorize(name, :intense_blue)
|
100
|
+
puts "Enter parameter value (type --help to get the parameter description): "
|
101
|
+
while (input = gets.chomp) == '--help'
|
102
|
+
puts Yummi::colorize(detail['description'], :intense_gray)
|
103
|
+
required = detail['required']
|
104
|
+
default_value = detail['default']
|
105
|
+
puts RBoss::Colorizers.type(detail['type']).colorize(detail['type'])
|
106
|
+
puts Yummi::colorize("Required", :red) if required
|
107
|
+
puts Yummi::colorize("Default: #{default_value}", :brown) if default_value
|
108
|
+
end
|
109
|
+
end
|
110
|
+
next if input.empty?
|
111
|
+
builder << {:name => name, :value => detail['type'].convert(input)}
|
112
|
+
end
|
113
|
+
result = result("#{path}:#{builder}")
|
114
|
+
puts YAML::dump(result)
|
115
|
+
end
|
116
|
+
|
83
117
|
def execute(*commands)
|
84
|
-
exec = "#{command} --commands=\"#{commands.join ','}\""
|
118
|
+
exec = "#{command} --command#{commands.size > 1 ? 's' : ''}=\"#{commands.join ','}\""
|
85
119
|
@logger.debug exec
|
86
120
|
`#{exec}`.chomp
|
87
121
|
end
|
88
122
|
|
123
|
+
def result(*commands)
|
124
|
+
eval_result(execute commands)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
class CommandBuilder
|
130
|
+
|
131
|
+
def initialize (operation)
|
132
|
+
@operation = operation
|
133
|
+
@params = {}
|
134
|
+
end
|
135
|
+
|
136
|
+
def << (param)
|
137
|
+
@params[param[:name]] = param[:value]
|
138
|
+
end
|
139
|
+
|
140
|
+
def to_s
|
141
|
+
params = (@params.collect() { |k, v| "#{k}=#{v}" }).join ','
|
142
|
+
"#@operation(#{params})"
|
143
|
+
end
|
144
|
+
|
89
145
|
end
|
90
146
|
|
91
147
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
description:
|
2
|
+
description: Datasource Information
|
3
3
|
path: /subsystem=datasources/data-source=${NAME}
|
4
|
-
scan: ls
|
4
|
+
scan: ls /subsystem=datasources/data-source
|
5
5
|
print:
|
6
6
|
- id: config
|
7
7
|
title: Datasource Details
|
@@ -39,7 +39,7 @@ print:
|
|
39
39
|
|
40
40
|
- id: pool
|
41
41
|
title: Datasource Pool Statistics
|
42
|
-
|
42
|
+
path: ${PATH}/statistics=pool
|
43
43
|
layout: vertical
|
44
44
|
properties:
|
45
45
|
- ActiveCount
|
@@ -76,7 +76,7 @@ print:
|
|
76
76
|
|
77
77
|
- id: jdbc
|
78
78
|
title: Datasource JDBC Statistics
|
79
|
-
|
79
|
+
path: ${PATH}/statistics=jdbc
|
80
80
|
properties:
|
81
81
|
- PreparedStatementCacheCurrentSize
|
82
82
|
- PreparedStatementCacheAccessCount
|
@@ -4,7 +4,7 @@ path: /core-service=
|
|
4
4
|
print:
|
5
5
|
- id: platform
|
6
6
|
title: Operating System Information
|
7
|
-
|
7
|
+
path: ${PATH}platform-mbean/type=operating-system
|
8
8
|
properties:
|
9
9
|
- name
|
10
10
|
- arch
|
@@ -19,10 +19,19 @@ print:
|
|
19
19
|
- System Load
|
20
20
|
format:
|
21
21
|
system_load: percentage
|
22
|
+
color:
|
23
|
+
name:
|
24
|
+
with: white
|
25
|
+
system_load:
|
26
|
+
threshold:
|
27
|
+
0.8: intense_red
|
28
|
+
0.7: red
|
29
|
+
0.5: brown
|
30
|
+
0: green
|
22
31
|
|
23
32
|
- id: env
|
24
33
|
title: Server Environment Information
|
25
|
-
|
34
|
+
path: ${PATH}server-environment
|
26
35
|
properties:
|
27
36
|
- server-name
|
28
37
|
- node-name
|
@@ -54,7 +63,7 @@ print:
|
|
54
63
|
- id: memory
|
55
64
|
title: Server Memory Usage
|
56
65
|
layout: vertical
|
57
|
-
|
66
|
+
path: ${PATH}platform-mbean/type=memory
|
58
67
|
properties:
|
59
68
|
- heap-memory-usage -> init
|
60
69
|
- heap-memory-usage -> used
|
@@ -111,7 +120,7 @@ print:
|
|
111
120
|
|
112
121
|
- id: thread
|
113
122
|
title: Server Thread Info
|
114
|
-
|
123
|
+
path: ${PATH}platform-mbean/type=threading
|
115
124
|
layout: vertical
|
116
125
|
properties:
|
117
126
|
- thread-contention-monitoring-supported
|
@@ -162,7 +171,7 @@ print:
|
|
162
171
|
|
163
172
|
- id: config
|
164
173
|
title: Server Configuration Resources
|
165
|
-
|
174
|
+
path: ${PATH}server-environment
|
166
175
|
layout: vertical
|
167
176
|
properties:
|
168
177
|
- server-name
|
data/lib/rboss/cli/mappings.rb
CHANGED
@@ -42,6 +42,10 @@ module RBoss
|
|
42
42
|
new_mapping[:print] = [table]
|
43
43
|
new_mapping[:description] = table[:title]
|
44
44
|
new_mapping[:derived] = true
|
45
|
+
if table[:path]
|
46
|
+
new_mapping[:path] = table[:path].gsub '${PATH}', mapping[:path]
|
47
|
+
table[:path] = new_mapping[:path]
|
48
|
+
end
|
45
49
|
new_key = "#{name}-#{table[:id]}"
|
46
50
|
@resource_mappings[new_key] = new_mapping
|
47
51
|
end
|
data/lib/rboss/cli/resource.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
+
|
23
24
|
module RBoss
|
24
25
|
module Cli
|
25
26
|
class Resource
|
@@ -36,22 +37,27 @@ module RBoss
|
|
36
37
|
@count = 0
|
37
38
|
end
|
38
39
|
|
39
|
-
def
|
40
|
-
if
|
41
|
-
|
40
|
+
def invoke(operation, resource_names, arguments)
|
41
|
+
if respond_to? operation.to_key
|
42
|
+
send operation.to_key, resource_names, arguments
|
43
|
+
else
|
44
|
+
interact_to_invoke operation, resource_names, arguments
|
45
|
+
Yummi.colorize('Operation Executed!', :green)
|
42
46
|
end
|
43
|
-
|
47
|
+
end
|
48
|
+
|
49
|
+
def read_resource(resources, arguments)
|
50
|
+
resources ||= scan
|
44
51
|
params = @config[:print]
|
45
52
|
params.each do |p|
|
46
53
|
table_builder = RBoss::TableBuilder::new p
|
47
54
|
table_builder.add_name_column if scannable?
|
48
55
|
@tables << table_builder.build_table
|
49
56
|
end
|
50
|
-
resources
|
51
|
-
@context[:name] = resource
|
52
|
-
@context[:path] = parse(@config[:path])
|
53
|
-
|
57
|
+
with resources do
|
54
58
|
params.each do |p|
|
59
|
+
@context[:path] = parse(@config[:path])
|
60
|
+
@context[:path] = parse(p[:path]) if p[:path]
|
55
61
|
add_row(p)
|
56
62
|
end
|
57
63
|
end
|
@@ -63,6 +69,112 @@ module RBoss
|
|
63
69
|
result
|
64
70
|
end
|
65
71
|
|
72
|
+
def read_operation_names(resource_name, arguments)
|
73
|
+
operations = Yummi::colorize('Operations:', :yellow)
|
74
|
+
operations << $/
|
75
|
+
with resource_name do
|
76
|
+
result = @invoker.result("#{@context[:path]}:read-operation-names")
|
77
|
+
result.each do |operation|
|
78
|
+
operations << Yummi::colorize('- ', :intense_purple)
|
79
|
+
operations << Yummi::colorize(operation, :intense_blue) << $/
|
80
|
+
end
|
81
|
+
end
|
82
|
+
operations
|
83
|
+
end
|
84
|
+
|
85
|
+
def read_operation_description (resource_name, arguments)
|
86
|
+
buff = ''
|
87
|
+
with resource_name do
|
88
|
+
operation_name = arguments['name']
|
89
|
+
table = Yummi::Table::new
|
90
|
+
buff << Yummi::colorize(operation_name, :intense_green) << $/
|
91
|
+
result = @invoker.result(
|
92
|
+
"#{@context[:path]}:read-operation-description(name=#{operation_name})"
|
93
|
+
)
|
94
|
+
buff << Yummi::colorize(result['description'], :intense_gray) << $/ * 2
|
95
|
+
table.title = 'Request'
|
96
|
+
table.header = %w(Parameter Type Required Default)
|
97
|
+
table.aliases = %w(name type required default)
|
98
|
+
table.colorize('name', :with => :white)
|
99
|
+
|
100
|
+
table.using_row do
|
101
|
+
table.colorize %w(type default) do |value|
|
102
|
+
RBoss::Colorizers.type(value['type']).color_for(value)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
table.format 'required', :using => RBoss::Formatters.yes_or_no
|
107
|
+
table.colorize 'required', :using => RBoss::Colorizers.boolean
|
108
|
+
result["request-properties"] ||= {}
|
109
|
+
unless result["request-properties"].empty?
|
110
|
+
result["request-properties"].each do |name, detail|
|
111
|
+
detail['name'] = name
|
112
|
+
table << detail
|
113
|
+
end
|
114
|
+
buff << table.to_s << $/
|
115
|
+
end
|
116
|
+
|
117
|
+
table = Yummi::Table::new
|
118
|
+
table.title = 'Response'
|
119
|
+
table.header = %w(Parameter Type Nilable Unit)
|
120
|
+
table.aliases = %w(name type nilable unit)
|
121
|
+
|
122
|
+
table.colorize 'name', :with => :white
|
123
|
+
|
124
|
+
table.using_row do
|
125
|
+
table.colorize 'type' do |value|
|
126
|
+
RBoss::Colorizers.type(value['type']).color_for(value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
table.format 'nilable', :using => RBoss::Formatters.yes_or_no
|
131
|
+
table.colorize 'nilable', :using => RBoss::Colorizers.boolean
|
132
|
+
result["reply-properties"] ||= {}
|
133
|
+
unless result["reply-properties"].empty?
|
134
|
+
result = result["reply-properties"]
|
135
|
+
table.description = result['description']
|
136
|
+
table << result
|
137
|
+
build_nested(result).each do |nested|
|
138
|
+
table << nested
|
139
|
+
end
|
140
|
+
buff << table.to_s << $/
|
141
|
+
end
|
142
|
+
end
|
143
|
+
buff
|
144
|
+
end
|
145
|
+
|
146
|
+
alias_method :list_operations, :read_operation_names
|
147
|
+
alias_method :detail_operation, :read_operation_description
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
def build_nested(detail, parent_name = '', result = [])
|
152
|
+
if detail['value-type']
|
153
|
+
detail['value-type'].each do |name, _detail|
|
154
|
+
name = "#{parent_name}#{name}"
|
155
|
+
_detail['name'] = name
|
156
|
+
result << _detail
|
157
|
+
build_nested(_detail, "#{name} => ", result)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
result
|
161
|
+
end
|
162
|
+
|
163
|
+
def interact_to_invoke(operation, resource_name, arguments)
|
164
|
+
with resource_name do
|
165
|
+
@invoker.gets_and_invoke(@context[:path], operation, arguments)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def with(resources)
|
170
|
+
resources ||= ''
|
171
|
+
[*resources].each do |resource|
|
172
|
+
@context[:name] = resource
|
173
|
+
@context[:path] = parse(@config[:path])
|
174
|
+
yield
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
66
178
|
def add_row(params)
|
67
179
|
data = get_data(params)
|
68
180
|
return unless data
|
@@ -76,12 +188,13 @@ module RBoss
|
|
76
188
|
result = value.scan /\$\{\w+\}/
|
77
189
|
result.each do |matched|
|
78
190
|
key = matched[2...-1].downcase.to_sym
|
79
|
-
value = value.gsub(matched, @context[key])
|
191
|
+
value = value.gsub(matched, @context[key].to_s)
|
80
192
|
end
|
81
193
|
value
|
82
194
|
end
|
83
195
|
|
84
196
|
def scan
|
197
|
+
return '' unless scannable?
|
85
198
|
result = @invoker.execute(parse @config[:scan])
|
86
199
|
result.split "\n"
|
87
200
|
end
|
@@ -91,30 +204,27 @@ module RBoss
|
|
91
204
|
end
|
92
205
|
|
93
206
|
def get_data(config)
|
94
|
-
command = (config[:command] or '${PATH}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
207
|
+
command = parse((config[:command] or '${PATH}:read-resource(include-runtime=true)'))
|
208
|
+
begin
|
209
|
+
result = @invoker.result(command)
|
210
|
+
data = []
|
211
|
+
config[:properties].each do |prop|
|
212
|
+
data << get_property(prop, result)
|
213
|
+
end
|
214
|
+
data
|
215
|
+
rescue
|
216
|
+
nil
|
100
217
|
end
|
101
|
-
data
|
102
218
|
end
|
103
219
|
|
104
220
|
def get_property(prop, result)
|
105
|
-
value = result
|
221
|
+
value = result
|
106
222
|
prop.split(/\s*->\s*/).each do |p|
|
107
223
|
value = value[p]
|
108
224
|
end
|
109
225
|
value
|
110
226
|
end
|
111
227
|
|
112
|
-
def eval_result(result)
|
113
|
-
undefined = nil #prevents error because undefined means nil in result object
|
114
|
-
result = result.gsub /(\d+)L/, '\1' #removes the long type mark
|
115
|
-
eval(result)
|
116
|
-
end
|
117
|
-
|
118
228
|
end
|
119
229
|
end
|
120
230
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module RBoss
|
24
|
+
module Cli
|
25
|
+
|
26
|
+
class InvocationFailed < Exception
|
27
|
+
|
28
|
+
def initialize(message)
|
29
|
+
super(message)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module ResultParser
|
35
|
+
|
36
|
+
class Type
|
37
|
+
|
38
|
+
attr_reader :name
|
39
|
+
|
40
|
+
def initialize (name, &block)
|
41
|
+
@name = name
|
42
|
+
@converter_block = block
|
43
|
+
end
|
44
|
+
|
45
|
+
def convert (value)
|
46
|
+
@converter_block.call value
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
@name
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
STRING = Type::new 'STRING' do |string|
|
56
|
+
"\"#{string}\""
|
57
|
+
end
|
58
|
+
BOOLEAN = Type::new 'BOOLEAN' do |string|
|
59
|
+
'true' == string.downcase
|
60
|
+
end
|
61
|
+
INT = Type::new 'INT' do |string|
|
62
|
+
string.to_i
|
63
|
+
end
|
64
|
+
LONG = Type::new 'LONG' do |string|
|
65
|
+
string.to_i
|
66
|
+
end
|
67
|
+
LIST = Type::new 'LIST'
|
68
|
+
OBJECT = Type::new 'OBJECT'
|
69
|
+
|
70
|
+
def eval_result(result)
|
71
|
+
undefined = nil #prevents error because undefined means nil in result object
|
72
|
+
result = result.gsub /(\d+)L/, '\1' #removes the long type mark
|
73
|
+
result = eval(result)
|
74
|
+
raise InvocationFailed::new(result["failure-description"]) if result["outcome"] == "failed"
|
75
|
+
result["result"]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -40,8 +40,7 @@ module RBoss
|
|
40
40
|
def process
|
41
41
|
@logger.info "Including resources..."
|
42
42
|
@config.each do |to_path, resources|
|
43
|
-
|
44
|
-
resources.each do |resource|
|
43
|
+
[*resources].each do |resource|
|
45
44
|
to_path = "#{@jboss.profile}/#{to_path}" unless to_path.to_s.start_with? '/'
|
46
45
|
cp_r File.expand_path(resource), to_path
|
47
46
|
end
|
@@ -63,7 +63,7 @@ module RBoss
|
|
63
63
|
include Component, FileUtils
|
64
64
|
|
65
65
|
def configure services_to_remove
|
66
|
-
@services_to_remove =
|
66
|
+
@services_to_remove = [*services_to_remove]
|
67
67
|
@mapping = {}
|
68
68
|
load_yaml('slimming').each do |key, values|
|
69
69
|
@mapping[key.to_sym] = values
|
data/lib/rboss/twiddle/mbean.rb
CHANGED
@@ -91,7 +91,7 @@ module RBoss
|
|
91
91
|
|
92
92
|
def name
|
93
93
|
if pattern['#{resource}'] and not @resource
|
94
|
-
domain,name = pattern.split ':'
|
94
|
+
domain, name = pattern.split ':'
|
95
95
|
name.gsub! /[^,]+\{resource\}/, ''
|
96
96
|
name << "," if name.empty?
|
97
97
|
name << "*"
|
@@ -107,7 +107,7 @@ module RBoss
|
|
107
107
|
result = @twiddle.execute(:get, query, property)
|
108
108
|
|
109
109
|
def result.value
|
110
|
-
self.split(
|
110
|
+
self.split(/=/, 2)[1]
|
111
111
|
end
|
112
112
|
|
113
113
|
result
|
data/lib/rboss/utils.rb
CHANGED
@@ -30,6 +30,18 @@ class String
|
|
30
30
|
self[0, 1].downcase + self[1..-1]
|
31
31
|
end
|
32
32
|
|
33
|
+
def to_key
|
34
|
+
self.gsub('-', '_').to_sym
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
class Symbol
|
40
|
+
|
41
|
+
def to_key
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
33
45
|
end
|
34
46
|
|
35
47
|
class Hash
|
@@ -43,7 +55,8 @@ class Hash
|
|
43
55
|
end
|
44
56
|
end
|
45
57
|
end
|
46
|
-
|
58
|
+
k = k.to_sym if k.respond_to? :to_sym
|
59
|
+
h[k] = v
|
47
60
|
h
|
48
61
|
end)
|
49
62
|
end
|
data/lib/rboss/version.rb
CHANGED
@@ -4,14 +4,38 @@ module RBoss
|
|
4
4
|
module Colorizers
|
5
5
|
|
6
6
|
def self.boolean params = {}
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
Yummi::to_colorize do |value|
|
8
|
+
value ? (params[:if_true] or :green) : (params[:if_false] or :brown)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.threshold params
|
13
|
+
colorize = lambda do |value|
|
14
|
+
params.sort.reverse_each do |limit, color|
|
15
|
+
return color if value > limit
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Yummi::to_colorize &colorize
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.type type
|
22
|
+
Yummi::to_colorize do |value|
|
23
|
+
case type
|
24
|
+
when RBoss::Cli::ResultParser::STRING then
|
25
|
+
:green
|
26
|
+
when RBoss::Cli::ResultParser::INT,
|
27
|
+
RBoss::Cli::ResultParser::LONG then
|
28
|
+
:blue
|
29
|
+
when RBoss::Cli::ResultParser::BOOLEAN then
|
30
|
+
:purple
|
31
|
+
else
|
32
|
+
:cyan
|
33
|
+
end
|
10
34
|
end
|
11
35
|
end
|
12
36
|
|
13
37
|
def self.with color
|
14
|
-
|
38
|
+
Yummi::to_colorize do |value|
|
15
39
|
color
|
16
40
|
end
|
17
41
|
end
|
data/lib/rboss.rb
CHANGED
@@ -22,11 +22,11 @@
|
|
22
22
|
|
23
23
|
require_relative "rboss/version"
|
24
24
|
require_relative "rboss/plaftorm"
|
25
|
-
require_relative "rboss/jboss_profile"
|
26
|
-
require_relative "rboss/twiddle"
|
27
|
-
require_relative "rboss/cli/jboss_cli"
|
28
|
-
require_relative "rboss/bin/command_actions"
|
29
25
|
require_relative "rboss/view/colorizers"
|
30
26
|
require_relative "rboss/view/formatters"
|
31
27
|
require_relative "rboss/view/health_checkers"
|
32
28
|
require_relative "rboss/view/table_builder"
|
29
|
+
require_relative "rboss/jboss_profile"
|
30
|
+
require_relative "rboss/twiddle"
|
31
|
+
require_relative "rboss/cli/invoker"
|
32
|
+
require_relative "rboss/bin/command_actions"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rboss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "A tool to create profiles for JBoss Application Server and use\n twiddle
|
15
15
|
to manage a running JBoss AS."
|
@@ -31,13 +31,14 @@ files:
|
|
31
31
|
- bin/twiddle
|
32
32
|
- lib/rboss.rb
|
33
33
|
- lib/rboss/bin/command_actions.rb
|
34
|
-
- lib/rboss/cli/
|
34
|
+
- lib/rboss/cli/invoker.rb
|
35
35
|
- lib/rboss/cli/mappings.rb
|
36
36
|
- lib/rboss/cli/mappings/resources/connector.yaml
|
37
37
|
- lib/rboss/cli/mappings/resources/datasource.yaml
|
38
38
|
- lib/rboss/cli/mappings/resources/jdbc_driver.yaml
|
39
39
|
- lib/rboss/cli/mappings/resources/server.yaml
|
40
40
|
- lib/rboss/cli/resource.rb
|
41
|
+
- lib/rboss/cli/result_parser.rb
|
41
42
|
- lib/rboss/component_processor.rb
|
42
43
|
- lib/rboss/components/component.rb
|
43
44
|
- lib/rboss/components/datasource.rb
|