rboss 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/bin/jboss-profile +5 -1
- data/bin/rboss-cli +142 -0
- data/bin/twiddle +7 -3
- data/lib/rboss.rb +2 -1
- data/lib/rboss/bin/command_actions.rb +6 -7
- data/lib/rboss/cli.rb +22 -0
- data/lib/rboss/cli/colorizers.rb +22 -0
- data/lib/rboss/cli/formatters.rb +17 -0
- data/lib/rboss/cli/health_checkers.rb +43 -0
- data/lib/rboss/cli/jboss_cli.rb +93 -0
- data/lib/rboss/{table_builder.rb → cli/mappings.rb} +32 -47
- data/lib/rboss/cli/mappings/resources/connector.yaml +75 -0
- data/lib/rboss/cli/mappings/resources/datasource.yaml +113 -0
- data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +13 -0
- data/lib/rboss/cli/mappings/resources/server.yaml +74 -0
- data/lib/rboss/cli/resource.rb +112 -0
- data/lib/rboss/component_processor.rb +1 -1
- data/lib/rboss/components/component.rb +1 -1
- data/lib/rboss/components/datasource.rb +1 -1
- data/lib/rboss/components/deploy_folder.rb +1 -1
- data/lib/rboss/components/hypersonic_replacer.rb +1 -1
- data/lib/rboss/components/jbossweb.rb +1 -1
- data/lib/rboss/components/jmx.rb +1 -1
- data/lib/rboss/components/mod_cluster.rb +1 -1
- data/lib/rboss/components/org/6.0/deploy_folder.rb +1 -1
- data/lib/rboss/components/org/jmx.rb +1 -1
- data/lib/rboss/components/profile_folder.rb +1 -1
- data/lib/rboss/components/resource.rb +1 -1
- data/lib/rboss/components/restore_slimming.rb +1 -1
- data/lib/rboss/components/run_conf.rb +1 -1
- data/lib/rboss/components/service_script.rb +1 -1
- data/lib/rboss/components/slimming.rb +1 -1
- data/lib/rboss/components/soa-p/hypersonic_replacer.rb +1 -1
- data/lib/rboss/components/soa-p/jmx.rb +1 -1
- data/lib/rboss/components/xadatasource.rb +1 -1
- data/lib/rboss/file_processor.rb +1 -1
- data/lib/rboss/jboss_path.rb +1 -1
- data/lib/rboss/jboss_profile.rb +1 -1
- data/lib/rboss/twiddle.rb +1 -1
- data/lib/rboss/twiddle/base_monitor.rb +1 -1
- data/lib/rboss/twiddle/mbean.rb +1 -1
- data/lib/rboss/twiddle/monitor.rb +57 -39
- data/lib/rboss/twiddle/twiddle.rb +1 -1
- data/lib/rboss/utils.rb +80 -1
- data/lib/rboss/version.rb +2 -2
- data/test/datasource_test.rb +1 -1
- data/test/deploy_folder_test.rb +1 -1
- data/test/jbossweb_test.rb +1 -1
- data/test/mbean_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/test_suite.rb +1 -1
- metadata +16 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/components/jmx.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/file_processor.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/jboss_path.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/jboss_profile.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/twiddle.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/twiddle/mbean.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -34,7 +34,7 @@ module JBoss
|
|
34
34
|
:pattern => 'jboss.web:type=Manager,host=localhost,path=/#{resource}',
|
35
35
|
:properties => %W(activeSessions maxActive distributable maxActiveSessions
|
36
36
|
expiredSessions rejectedSessions),
|
37
|
-
:header => ["
|
37
|
+
:header => ["Active\nSessions", "Max\nSessions", "Distributable",
|
38
38
|
"Max Active\nSession", "Expired\nSessions", "Rejected\nSessions"],
|
39
39
|
:scan => proc do
|
40
40
|
query "jboss.web:type=Manager,*" do |path|
|
@@ -52,11 +52,16 @@ module JBoss
|
|
52
52
|
:description => 'JBossWeb connector',
|
53
53
|
:pattern => 'jboss.web:type=ThreadPool,name=#{resource}',
|
54
54
|
:properties => %W(maxThreads currentThreadCount currentThreadsBusy),
|
55
|
-
:header => ['
|
56
|
-
:health =>
|
57
|
-
:
|
58
|
-
|
59
|
-
|
55
|
+
:header => ['Max Threads', 'Current Threads', 'Busy Threads'],
|
56
|
+
:health => [
|
57
|
+
{:column => :current_threads,
|
58
|
+
:component => :percentage,
|
59
|
+
:params => {
|
60
|
+
:max => :max_threads,
|
61
|
+
:using => :current_threads
|
62
|
+
}
|
63
|
+
}
|
64
|
+
],
|
60
65
|
:scan => proc do
|
61
66
|
query "jboss.web:type=ThreadPool,*" do |path|
|
62
67
|
path.gsub "jboss.web:type=ThreadPool,name=", ""
|
@@ -100,11 +105,26 @@ module JBoss
|
|
100
105
|
:header => ["Active Threads", "Max Memory", "Free Memory",
|
101
106
|
"Processors", "Java Vendor", "Java Version", "OS Name", "OS Arch"],
|
102
107
|
:layout => :vertical,
|
103
|
-
:
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
+
:format => [
|
109
|
+
{
|
110
|
+
:column => :max_memory,
|
111
|
+
:component => :byte
|
112
|
+
},
|
113
|
+
{
|
114
|
+
:column => :free_memory,
|
115
|
+
:component => :byte
|
116
|
+
}
|
117
|
+
],
|
118
|
+
:health => [
|
119
|
+
{
|
120
|
+
:column => :free_memory,
|
121
|
+
:component => :percentage,
|
122
|
+
:params => {
|
123
|
+
:max => :max_memory,
|
124
|
+
:free => :free_memory
|
125
|
+
}
|
126
|
+
}
|
127
|
+
],
|
108
128
|
},
|
109
129
|
:server_config => {
|
110
130
|
:description => 'JBoss Server configuration',
|
@@ -121,11 +141,17 @@ module JBoss
|
|
121
141
|
:description => 'JBossWeb connector requests',
|
122
142
|
:pattern => 'jboss.web:type=GlobalRequestProcessor,name=#{resource}',
|
123
143
|
:properties => %W(requestCount errorCount maxTime),
|
124
|
-
:header => ['
|
125
|
-
:health =>
|
126
|
-
|
127
|
-
|
128
|
-
|
144
|
+
:header => ['Requests', 'Errors', 'Max Time'],
|
145
|
+
:health => [
|
146
|
+
{
|
147
|
+
:column => :errors,
|
148
|
+
:component => :percentage,
|
149
|
+
:params => {
|
150
|
+
:max => :requests,
|
151
|
+
:using => :errors
|
152
|
+
}
|
153
|
+
}
|
154
|
+
],
|
129
155
|
:scan => proc do
|
130
156
|
query "jboss.web:type=ThreadPool,*" do |path|
|
131
157
|
path.gsub "jboss.web:type=ThreadPool,name=", ""
|
@@ -137,12 +163,18 @@ module JBoss
|
|
137
163
|
:pattern => 'jboss.jca:service=ManagedConnectionPool,name=#{resource}',
|
138
164
|
:properties => %W(MinSize MaxSize AvailableConnectionCount
|
139
165
|
InUseConnectionCount ConnectionCount),
|
140
|
-
:header => ["
|
166
|
+
:header => ["Min\nSize", "Max\nSize", "Avaliable\nConnections",
|
141
167
|
"In Use\nConnections", "Connection\nCount"],
|
142
|
-
:health =>
|
143
|
-
|
144
|
-
|
145
|
-
|
168
|
+
:health => [
|
169
|
+
{
|
170
|
+
:column => :in_use_connections,
|
171
|
+
:component => :percentage,
|
172
|
+
:params => {
|
173
|
+
:max => :max_size,
|
174
|
+
:using => :in_use_connections
|
175
|
+
}
|
176
|
+
}
|
177
|
+
],
|
146
178
|
:scan => proc do
|
147
179
|
query "jboss.jca:service=ManagedConnectionPool,*" do |path|
|
148
180
|
path.gsub "jboss.jca:service=ManagedConnectionPool,name=", ""
|
@@ -154,7 +186,7 @@ module JBoss
|
|
154
186
|
:pattern => 'jboss.messaging.destination:service=Queue,name=#{resource}',
|
155
187
|
:properties => %W(JNDIName MessageCount DeliveringCount
|
156
188
|
ScheduledMessageCount MaxSize FullSize Clustered ConsumerCount),
|
157
|
-
:header => ['Name', '
|
189
|
+
:header => ['JNDI Name', 'Messages', 'Deliveries', 'Scheduleded', 'Max Size',
|
158
190
|
'Full Size', 'Clustered', 'Consumed'],
|
159
191
|
:scan => proc do
|
160
192
|
query "jboss.messaging.destination:service=Queue,*" do |path|
|
@@ -165,20 +197,6 @@ module JBoss
|
|
165
197
|
:jndi => {
|
166
198
|
:description => 'JNDI View',
|
167
199
|
:pattern => 'jboss:service=JNDIView'
|
168
|
-
},
|
169
|
-
:ejb => {
|
170
|
-
:description => 'EJB',
|
171
|
-
:pattern => 'jboss.j2ee:#{resource},service=EJB3',
|
172
|
-
:properties => %W(CreateCount RemoveCount CurrentSize AvailableCount),
|
173
|
-
:header => ['EJB', 'Created', 'Removed', 'Current', 'Available'],
|
174
|
-
:scan => proc do
|
175
|
-
result = query "jboss.j2ee:*"
|
176
|
-
(result.find_all do |path|
|
177
|
-
path["service=EJB3"] && path["name="] && path["jar="] && !path["ear="]
|
178
|
-
end).collect do |path|
|
179
|
-
path.gsub("jboss.j2ee:", '').gsub(/,?service=EJB3/, '')
|
180
|
-
end
|
181
|
-
end
|
182
200
|
}
|
183
201
|
}
|
184
202
|
end
|
@@ -189,11 +207,11 @@ module JBoss
|
|
189
207
|
@mbeans ||= {}
|
190
208
|
end
|
191
209
|
|
192
|
-
def monitor
|
210
|
+
def monitor(mbean_id, params)
|
193
211
|
mbeans[mbean_id] = JBoss::MBean::new params.merge(:twiddle => @twiddle)
|
194
212
|
end
|
195
213
|
|
196
|
-
def mbean
|
214
|
+
def mbean(mbean_id)
|
197
215
|
mbean = mbeans[mbean_id]
|
198
216
|
return JBoss::MBean::new :pattern => mbean_id.to_s, :twiddle => @twiddle unless mbean
|
199
217
|
if @current_resource
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rboss/utils.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -31,3 +31,82 @@ class String
|
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
34
|
+
|
35
|
+
class Hash
|
36
|
+
def symbolize_keys
|
37
|
+
replace(inject({}) do |h, (k, v)|
|
38
|
+
v = v.symbolize_keys if v.is_a? Hash
|
39
|
+
if v.is_a? Array
|
40
|
+
v.each do |e|
|
41
|
+
if e.is_a? Hash
|
42
|
+
e.symbolize_keys
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
h[k.to_sym] = v
|
47
|
+
h
|
48
|
+
end)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class TableBuilder
|
53
|
+
|
54
|
+
def initialize(config)
|
55
|
+
@config = config
|
56
|
+
add_name_column if config[:scan]
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_name_column(name = 'Name')
|
60
|
+
@name_column = name
|
61
|
+
end
|
62
|
+
|
63
|
+
def show_only_name
|
64
|
+
@only_name = true
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_table
|
68
|
+
table = Yummi::Table::new
|
69
|
+
table.title = (@config[:title] or @config[:description])
|
70
|
+
header = @config[:header]
|
71
|
+
header = [@name_column] + header if @name_column
|
72
|
+
if @config[:aliases]
|
73
|
+
aliases = @config[:aliases]
|
74
|
+
aliases = [:name] + aliases if @name_column
|
75
|
+
table.aliases = aliases
|
76
|
+
end
|
77
|
+
table.header = header
|
78
|
+
table.layout = @config[:layout].to_sym if @config[:layout]
|
79
|
+
|
80
|
+
parse_component @config[:format], JBoss::Cli::Formatters do |column, params|
|
81
|
+
table.format column, params
|
82
|
+
end
|
83
|
+
parse_component @config[:color], JBoss::Cli::Colorizers do |column, params|
|
84
|
+
table.colorize column, params
|
85
|
+
end
|
86
|
+
parse_component @config[:health], JBoss::Cli::HealthCheckers do |column, params|
|
87
|
+
table.using_row do
|
88
|
+
table.colorize column, params
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
table.header = [@name_column] if @only_name
|
93
|
+
|
94
|
+
table.format_null :with => 'undefined'
|
95
|
+
table.colorize_null :with => :red
|
96
|
+
|
97
|
+
table.colorize :name, :with => :white if @name_column
|
98
|
+
|
99
|
+
table
|
100
|
+
end
|
101
|
+
|
102
|
+
def parse_component(config, repository)
|
103
|
+
if config
|
104
|
+
config.each do |component_config|
|
105
|
+
component = repository.send(component_config[:component]) unless component_config[:params]
|
106
|
+
component ||= repository.send(component_config[:component], component_config[:params])
|
107
|
+
yield(component_config[:column].to_sym, :using => component)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|