rboss 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/encodings.xml +5 -0
  3. data/.idea/misc.xml +5 -0
  4. data/.idea/modules.xml +9 -0
  5. data/.idea/rboss.iml +65 -0
  6. data/.idea/scopes/scope_settings.xml +5 -0
  7. data/.idea/vcs.xml +7 -0
  8. data/Gemfile +2 -2
  9. data/README.md +34 -397
  10. data/bin/rboss-cli +77 -28
  11. data/lib/rboss.rb +10 -12
  12. data/lib/rboss/cli/invoker.rb +31 -18
  13. data/lib/rboss/cli/mappings.rb +11 -10
  14. data/lib/rboss/cli/mappings/resources/connector.yaml +2 -2
  15. data/lib/rboss/cli/mappings/resources/datasource.yaml +5 -5
  16. data/lib/rboss/cli/mappings/resources/deployment-scanner.yaml +3 -3
  17. data/lib/rboss/cli/mappings/resources/interface.yaml +2 -2
  18. data/lib/rboss/cli/mappings/resources/jdbc-driver.yaml +12 -0
  19. data/lib/rboss/cli/mappings/resources/jms-queue.yaml +44 -0
  20. data/lib/rboss/cli/mappings/resources/runtime.yaml +34 -0
  21. data/lib/rboss/cli/mappings/resources/server.yaml +8 -8
  22. data/lib/rboss/cli/resource.rb +60 -37
  23. data/lib/rboss/cli/result_parser.rb +29 -5
  24. data/lib/rboss/plaftorm.rb +2 -25
  25. data/lib/rboss/utils.rb +2 -8
  26. data/lib/rboss/version.rb +1 -1
  27. data/lib/rboss/view/colorizers.rb +4 -2
  28. data/lib/rboss/view/formatters.rb +37 -0
  29. data/lib/rboss/view/table_builder.rb +2 -2
  30. data/rboss-cli-bash-completion +82 -0
  31. data/rboss.gemspec +12 -12
  32. data/rboss.iml +6 -7
  33. data/rboss.ipr +2 -11
  34. metadata +23 -53
  35. data/bin/rboss-profile +0 -125
  36. data/bin/rboss-twiddle +0 -204
  37. data/lib/rboss/bin/command_actions.rb +0 -125
  38. data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +0 -12
  39. data/lib/rboss/component_processor.rb +0 -179
  40. data/lib/rboss/components/component.rb +0 -58
  41. data/lib/rboss/components/datasource.rb +0 -179
  42. data/lib/rboss/components/deploy_folder.rb +0 -104
  43. data/lib/rboss/components/hypersonic_replacer.rb +0 -58
  44. data/lib/rboss/components/jbossweb.rb +0 -119
  45. data/lib/rboss/components/jmx.rb +0 -88
  46. data/lib/rboss/components/mod_cluster.rb +0 -81
  47. data/lib/rboss/components/org/6.0/deploy_folder.rb +0 -33
  48. data/lib/rboss/components/org/jmx.rb +0 -59
  49. data/lib/rboss/components/profile_folder.rb +0 -44
  50. data/lib/rboss/components/resource.rb +0 -52
  51. data/lib/rboss/components/restore_slimming.rb +0 -46
  52. data/lib/rboss/components/run_conf.rb +0 -90
  53. data/lib/rboss/components/run_conf.yaml +0 -22
  54. data/lib/rboss/components/service_script.rb +0 -55
  55. data/lib/rboss/components/slimming.rb +0 -107
  56. data/lib/rboss/components/slimming.yaml +0 -110
  57. data/lib/rboss/components/soa-p/hypersonic_replacer.rb +0 -79
  58. data/lib/rboss/components/soa-p/jmx.rb +0 -47
  59. data/lib/rboss/components/xadatasource.rb +0 -67
  60. data/lib/rboss/file_processor.rb +0 -111
  61. data/lib/rboss/jboss_path.rb +0 -74
  62. data/lib/rboss/jboss_profile.rb +0 -350
  63. data/lib/rboss/resources/jboss_init_redhat.sh.erb +0 -140
  64. data/lib/rboss/resources/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml +0 -282
  65. data/lib/rboss/resources/mod_cluster.sar/mod_cluster-1.1.2.Final.jar +0 -0
  66. data/lib/rboss/resources/run.conf.bat.erb +0 -60
  67. data/lib/rboss/resources/run.conf.erb +0 -62
  68. data/lib/rboss/twiddle.rb +0 -25
  69. data/lib/rboss/twiddle/base_monitor.rb +0 -88
  70. data/lib/rboss/twiddle/mbean.rb +0 -148
  71. data/lib/rboss/twiddle/monitor.rb +0 -222
  72. data/lib/rboss/twiddle/twiddle.rb +0 -87
@@ -1,111 +0,0 @@
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
- require "rexml/document"
24
- require "fileutils"
25
- require "ostruct"
26
- require "logger"
27
-
28
- module RBoss
29
-
30
- class FileProcessor
31
-
32
- def initialize opts = {}
33
- @logger = opts[:logger]
34
- @var = opts[:var]
35
- @logger ||= Logger::new(STDOUT)
36
- @handlers = {
37
- :plain => {
38
- :load => lambda do |file|
39
- @logger.info "Loading file #{file}"
40
- File.read(file)
41
- end,
42
- :store => lambda do |file, content|
43
- @logger.info "Saving file #{file}"
44
- File.open(file, 'w+') { |f| f.write (content) }
45
- end
46
- },
47
- :xml => {
48
- :load => lambda do |file|
49
- @logger.info "Parsing file #{file}"
50
- REXML::Document::new File::new(file)
51
- end,
52
-
53
- :store => lambda do |file, xml|
54
- @logger.info "Saving file #{file}"
55
- content = ''
56
- formatter = REXML::Formatters::Pretty::new 2
57
- formatter.write xml, content
58
- File.open(file, 'w+') { |f| f.write content }
59
- end
60
- }
61
- }
62
-
63
- @actions = {}
64
- end
65
-
66
- def register type, actions
67
- @handlers[type] = actions
68
- end
69
-
70
- def with file, type = :plain
71
- @current_file = file.to_s
72
- @actions[@current_file] = {}
73
- to_load &@handlers[type][:load]
74
- to_store &@handlers[type][:store]
75
- yield self
76
- end
77
-
78
- def copy_to file
79
- @actions[@current_file][:copy] = file.to_s
80
- end
81
-
82
- def return
83
- @actions[@current_file][:return] = true
84
- end
85
-
86
- def to_load &block
87
- @actions[@current_file][:to_load] = block
88
- end
89
-
90
- def to_store &block
91
- @actions[@current_file][:to_store] = block
92
- end
93
-
94
- def to_process &block
95
- @actions[@current_file][:to_process] = block
96
- end
97
-
98
- def process
99
- @actions.each do |file, action|
100
- action[:obj] = action[:to_load].call file
101
- @logger.info "Processing file #{file}"
102
- action[:obj] = action[:to_process].call(action[:obj], @var) if action[:obj]
103
- file = action[:copy] if action[:copy]
104
- return action[:obj] if action[:return]
105
- action[:to_store].call file, action[:obj]
106
- end
107
- end
108
-
109
- end
110
-
111
- end
@@ -1,74 +0,0 @@
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
- require "logger"
24
-
25
- module RBoss
26
-
27
- # A class that represents the JBoss structure.
28
- #
29
- # author Marcelo Guimarães <ataxexe@gmail.com>
30
- class Path
31
-
32
- attr_reader :profile, :profile_name, :home, :type, :version
33
-
34
- def initialize jboss_home, params = {}
35
- params = {
36
- :profile => :custom,
37
- :type => :undefined,
38
- version => :undefined
39
- }.merge params
40
- @home = jboss_home
41
- @profile ="#{@home}/server/#{params[:profile]}"
42
- @profile_name = params[:profile].to_s
43
- @type = params[:type]
44
- @version = params[:version]
45
- @logger = params[:logger]
46
- end
47
-
48
- def to_s
49
- @home
50
- end
51
-
52
- def jboss_logging_lib_path
53
- %W{#{@home}/client/jboss-logging-spi.jar #{@home}/client/jboss-logging.jar}.each do |path|
54
- return path if File.exist? path
55
- end
56
- end
57
-
58
- def jbosssx_lib_path
59
- %W{#{@home}/lib/jbosssx.jar #{@home}/common/lib/jbosssx.jar}.each do |path|
60
- return path if File.exist? path
61
- end
62
- end
63
-
64
- # Encrypts the given password using the SecureIdentityLoginModule
65
- def encrypt password
66
- command = "java -cp #{jboss_logging_lib_path}:#{jbosssx_lib_path} org.jboss.resource.security.SecureIdentityLoginModule #{password}"
67
- @logger.debug command if @logger
68
- encrypted = `#{command}`
69
- encrypted.chomp.split(/:/)[1].strip
70
- end
71
-
72
- end
73
-
74
- end
@@ -1,350 +0,0 @@
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
- require_relative "file_processor"
24
- require_relative "utils"
25
- require_relative "component_processor"
26
- require_relative "jboss_path"
27
-
28
- require "logger"
29
- require "yummi"
30
- require "ostruct"
31
- require "fileutils"
32
-
33
- module RBoss
34
-
35
- # A Class to configure a JBoss Profile
36
- #
37
- # Basically, this class is a Component Processor with some components added to configure a JBoss profile, the built-in
38
- # components are:
39
- #
40
- # :deploy_folder => binded to a RBoss::DeployFolder
41
- #
42
- # :cluster => a shortcut component for :run_conf, sends these attributes to it:
43
- # :multicast_ip => default "239.255.0.1"
44
- # :partition_name => default "${profile name}-partition
45
- #
46
- # :jms => a shortcut component for :run_conf, sends these attributes to it:
47
- # :peer_id
48
- #
49
- # :bind => a shortcut component, sends these attributes:
50
- # To :run_conf
51
- # :ports => sends as :service_binding
52
- # To :init_script
53
- # :address => default "localhost", sends as :bind_address
54
- #
55
- # :resource => binded to a RBoss::Resource
56
- #
57
- # :jmx => binded to a RBoss::JMX, enabled by default and sends user and password
58
- # values to :init_script
59
- #
60
- # :datasource => binded to a RBoss::Datasource
61
- #
62
- # :xa_datasource => binded to a RBoss::XADatasource
63
- #
64
- # :default_ds => binded to a RBoss::HypersonicReplacer
65
- #
66
- # :mod_cluster => binded to a RBoss::ModCluster
67
- # Defaults:
68
- # :path => "resources/mod_cluster.sar"
69
- # Move to :run_conf (for externalizing mod_cluster configuration)
70
- # :advertise
71
- # :advertise_group_address
72
- # :advertise_port
73
- # :proxy_list
74
- # :excluded_contexts
75
- # :auto_enable_contexts
76
- #
77
- # :run_conf => binded to a RBoss::RunConf
78
- # Defaults:
79
- # :path => 'resources/run.conf.erb'
80
- # :stack_size => '128k'
81
- # :heap_size => '2048m'
82
- # :perm_size => '256m'
83
- #
84
- # :slimming => binded to a RBoss::Slimming
85
- #
86
- # :init_script => binded to a RBoss::ServiceScritp
87
- # Defaults:
88
- # :path => 'resources/jboss_init_redhat.sh'
89
- # :jmx_user => "admin"
90
- # :jmx_password => "admin"
91
- # :bind_address => "0.0.0.0"
92
- # :java_path => "/usr/java/default"
93
- # :jnp_port => 1099
94
- # :jboss_user => "RUNASIS"
95
- #
96
- # author Marcelo Guimarães <ataxexe@gmail.com>
97
- class Profile < RBoss::ComponentProcessor
98
- include RBoss::Platform
99
-
100
- # Priorities for components
101
- @@pre_install = 0
102
- @@install = @@pre_install + 10
103
- @@post_install = @@install + 10
104
-
105
- @@pre_setup = @@post_install + 10
106
- @@setup = @@pre_setup + 10
107
- @@post_setup = @@setup + 10
108
-
109
- @@final = @@post_setup + 10
110
-
111
- attr_reader :jboss
112
-
113
- def initialize opts = {}
114
- block = lambda { |type, config| type.new(@jboss, @logger, config).process }
115
- super &block
116
- @base_dir = File.dirname(__FILE__)
117
- @opts = {
118
- :jboss_home => ENV['JBOSS_HOME'],
119
- :base_profile => :production,
120
- :profile => :custom,
121
- :type => :undefined,
122
- :version => :undefined
123
- }.merge! opts
124
- @jboss_home = File.expand_path @opts[:jboss_home]
125
- @logger = @opts[:logger]
126
- unless @logger
127
- @logger = Logger::new STDOUT
128
- @logger.level = opts[:log_level] || Logger::INFO
129
- formatter = Yummi::Formatter::LogFormatter.new do |severity, message|
130
- "#{severity} : #{message}"
131
- end
132
-
133
- @logger.formatter = formatter
134
- end
135
- @profile = @opts[:profile].to_s
136
- @base_profile = @opts[:base_profile].to_s
137
- @jboss = RBoss::Path::new @jboss_home,
138
- :profile => @profile,
139
- :type => @opts[:type],
140
- :version => @opts[:version],
141
- :logger => @logger
142
- initialize_components
143
- end
144
-
145
- def create
146
- add :profile_folder, @base_profile
147
- process_components
148
- end
149
-
150
- alias update process_components
151
-
152
- # For making code more readable
153
- #
154
- # example: profile.install :mod_cluster
155
- alias install add
156
-
157
- # For making code more readable
158
- #
159
- # example: profile.configure :jmx, :password => "password"
160
- alias configure add
161
-
162
- # For making code more readable
163
- #
164
- # example: profile.slim :jmx_console, :admin_console
165
- def slim *args
166
- add :slimming, args
167
- end
168
-
169
- # loads extensions to components based on the type of jboss (eap, soa-p, org, epp...)
170
- def load_extensions
171
- unless @jboss.type == :undefined
172
- dir = File.join(@base_dir, "components", @jboss.type.to_s.gsub(/_/, '-'))
173
- load_scripts_in dir
174
- unless @jboss.version == :undefined
175
- dir = File.join(dir, @jboss.version.to_s)
176
- load_scripts_in dir
177
- end
178
- end
179
- end
180
-
181
- def load_scripts_in dir
182
- if File.exists? dir
183
- scripts = Dir.entries(dir).find_all { |f| f.end_with? '.rb' }
184
- scripts.each do |script|
185
- load File.join(dir, script)
186
- end
187
- end
188
- end
189
-
190
- # Loads manually every script related to jboss. This is necessary to reset the components to its natural state
191
- def load_scripts
192
- scripts = Dir.entries("#{@base_dir}/components").find_all { |f| f.end_with?('.rb') }
193
- scripts.each do |script|
194
- load File.expand_path(@base_dir) + "/components/" + script
195
- end
196
- end
197
-
198
- def initialize_components
199
- load_scripts
200
- load_extensions
201
-
202
- register :cluster,
203
-
204
- :priority => @@pre_install,
205
- :move_config => {
206
- :to_run_conf => [:multicast_ip, :partition_name],
207
- :to_jboss_web => [:jvm_route],
208
- :to_jms => [:peer_id]
209
- },
210
- :defaults => {
211
- :multicast_ip => "239.255.0.1",
212
- :partition_name => "#{@profile}-partition",
213
- :jvm_route => "#{@profile}"
214
- }
215
-
216
- register :jms,
217
-
218
- :priority => @@pre_install,
219
- :move_config => {
220
- :to_run_conf => [:peer_id]
221
- }
222
-
223
- register :bind,
224
-
225
- :priority => @@pre_install,
226
- :send_config => {
227
- :to_init_script => {
228
- :address => :bind_address
229
- }
230
- },
231
- :move_config => {
232
- :to_run_conf => {
233
- :ports => :service_binding
234
- }
235
- },
236
- :defaults => {
237
- :address => 'localhost'
238
- }
239
-
240
- register :profile_folder,
241
- :type => RBoss::ProfileFolder,
242
- :priority => @@install
243
-
244
- register :deploy_folder,
245
-
246
- :type => RBoss::DeployFolder,
247
- :priority => @@post_install,
248
- :multiple_instances => true
249
-
250
-
251
- register :resource,
252
-
253
- :type => RBoss::Resource,
254
- :priority => @@pre_setup,
255
- :multiple_instances => true
256
-
257
- register :jmx,
258
-
259
- :type => RBoss::JMX,
260
- :priority => @@setup,
261
- :send_config => {
262
- :to_init_script => {
263
- :password => :jmx_password,
264
- :user => :jmx_user
265
- }
266
- }
267
-
268
- register :datasource,
269
-
270
- :type => RBoss::Datasource,
271
- :priority => @@setup,
272
- :multiple_instances => true
273
-
274
- register :xa_datasource,
275
-
276
- :type => RBoss::XADatasource,
277
- :priority => @@setup,
278
- :multiple_instances => true
279
-
280
- register :default_ds,
281
-
282
- :type => RBoss::HypersonicReplacer,
283
- :priority => @@setup
284
-
285
- register :mod_cluster,
286
-
287
- :type => RBoss::ModCluster,
288
- :priority => @@setup,
289
- :move_config => {
290
- :to_run_conf => [
291
- :advertise,
292
- :advertise_group_address,
293
- :advertise_port,
294
- :proxy_list,
295
- :excluded_contexts,
296
- :auto_enable_contexts
297
- ]
298
- },
299
- :defaults => {
300
- :path => "#{@base_dir}/resources/mod_cluster.sar",
301
- }
302
-
303
- register :jbossweb,
304
-
305
- :type => RBoss::JBossWeb,
306
- :priority => @@setup
307
-
308
- register :run_conf,
309
-
310
- :type => RBoss::RunConf,
311
- :priority => @@post_setup,
312
- :send_config => {
313
- :to_init_script => [:service_binding]
314
- },
315
- :defaults => {
316
- :template_path => run_conf_template,
317
-
318
- :stack_size => '128k',
319
- :heap_size => '2048m',
320
- :perm_size => '256m'
321
- }
322
-
323
- register :slimming,
324
-
325
- :type => RBoss::Slimming,
326
- :priority => @@post_setup
327
-
328
- register :restore,
329
-
330
- :type => RBoss::Restore,
331
- :priority => @@post_setup + 5
332
-
333
- register :init_script,
334
-
335
- :type => RBoss::ServiceScript,
336
- :priority => @@final,
337
- :defaults => {
338
- :path => "#{@base_dir}/resources/jboss_init_redhat.sh.erb",
339
- :jmx_user => "admin",
340
- :jmx_password => "admin",
341
- :bind_address => "0.0.0.0",
342
- :java_path => "/usr/java/default",
343
- :jnp_port => 1099,
344
- :jboss_user => "RUNASIS"
345
- }
346
- end
347
-
348
- end
349
-
350
- end