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,204 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # The MIT License
4
- #
5
- # Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the "Software"), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- # THE SOFTWARE.
24
-
25
- require_relative '../lib/rboss'
26
- require 'optparse'
27
- require 'logger'
28
- require 'yaml'
29
- require 'fileutils'
30
- require 'yummi'
31
-
32
- params = {}
33
- @mbeans = {}
34
- @commands = {}
35
- no_details = false
36
- @conf_dir = File.expand_path "~/.rboss"
37
- servers_file = "#{@conf_dir}/twiddle.yaml"
38
- @servers_file = File.expand_path(servers_file)
39
- save = false
40
- params[:jboss_home] = (ENV["RBOSS_TWIDDLE_HOME"] or Dir.pwd)
41
-
42
- defaults = RBoss::Twiddle::Monitor::defaults
43
-
44
- def load_yaml
45
- return Hash::new unless File.exist?(@servers_file)
46
- YAML::load_file(@servers_file)
47
- end
48
-
49
- opts = OptionParser::new
50
- opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
51
- params[:jboss_home] = home
52
- end
53
- opts.on('-s URL', 'Defines the JBoss server') do |server|
54
- params[:server] = server
55
- end
56
- opts.on('--host HOST', 'Defines the JBoss host') do |host|
57
- params[:host] = host
58
- end
59
- opts.on('--port PORT', 'Defines the JBoss jnp port') do |port|
60
- params[:port] = port
61
- end
62
- opts.on('-c', '--connect SERVER_NAME',
63
- "Uses a configured server in #{servers_file}") do |server|
64
- config = load_yaml[server]
65
- abort "No configuration for #{server}" unless config
66
- config.each do |key, value|
67
- params[key.to_sym] = value
68
- end
69
- end
70
- opts.on('--save SERVER_NAME', "Saves the server configuration in #{servers_file}") do |server|
71
- save = server
72
- end
73
- opts.on('--loop INTERVAL', Float, 'Runs the mbean inside a loop') do |interval|
74
- @loop = true
75
- @interval = interval
76
- end
77
- opts.on('--all', "Detail all mapped mbeans") do
78
- defaults.each do |mbean_id, mbean|
79
- if mbean[:scan]
80
- @mbeans[mbean_id] = :all
81
- elsif mbean[:properties]
82
- @mbeans[mbean_id] = true
83
- end
84
- end
85
- end
86
-
87
- (defaults.sort_by { |k, v| k }).each do |mbean_id, mbean|
88
- next if mbean[:properties] and not mbean[:scan] and mbean[:pattern]['#{resource}']
89
- command = mbean_id.to_s.gsub(/_/, '-')
90
- if mbean[:scan]
91
- opts.on("--#{command} [name_a,name_b,...]", Array,
92
- "Detail \"#{mbean[:title]}\" based on the given names (no names for scan)") do |names|
93
- @mbeans[mbean_id] = names || :all
94
- end
95
- elsif mbean[:properties]
96
- opts.on("--#{command}", "Detail \"#{mbean[:title]}\"") do
97
- @mbeans[mbean_id] = true
98
- end
99
- end
100
- end
101
-
102
- opts.on('--set mbean_id[:resource_name],property,value', Array,
103
- 'Sets a value to a resource that the monitor knows') do |set|
104
- @commands[:set] = set
105
- end
106
- opts.on('--get mbean_id[:resource_name],property', Array,
107
- 'Gets a value to a resource that the monitor knows') do |get|
108
- @commands[:get] = get
109
- end
110
- opts.on('--query mbean_id[:resource_name],[arguments]', Array,
111
- 'Queries the mbean') do |query|
112
- @commands[:query] = query
113
- end
114
- opts.on('--info mbean_id[:resource_name],[arguments]', Array,
115
- 'List mbean info') do |info|
116
- @commands[:info] = info
117
- end
118
- opts.on('--invoke mbean_id[:resource_name],method,[,args...]', Array,
119
- 'Invokes a mbean method') do |invoke|
120
- @commands[:invoke] = invoke
121
- end
122
- opts.on("-l", "--list", "List the mbeans mappings") do
123
- (defaults.sort_by { |k, v| k }).each do |mbean_id, mbean|
124
- puts " - #{mbean_id.to_s.gsub(/_/, '-')}"
125
- [:description, :pattern].each do |detail|
126
- puts " - #{detail} : #{mbean[detail]}"
127
- end
128
- puts
129
- end
130
- exit
131
- end
132
- opts.on('--no-detail', 'Do not detail mbeans that needs a name') do
133
- no_details = true
134
- end
135
- opts.on('--no-color', 'Do not colorize output') do
136
- require 'yummi/no_colors'
137
- end
138
- opts.on('-u', '--user USER', 'Defines the JMX User') do |user|
139
- params[:user] = user
140
- end
141
- opts.on('-p', '--password PASSWORD', 'Defines the JMX Password') do |password|
142
- params[:password] = password
143
- end
144
- opts.on('-n COMMAND', '--native COMMAND', 'Executes the given command as is') do |command|
145
- @commands[:native] = command
146
- end
147
- opts.on('-v', '--verbose', 'Shows the twiddle commands before execution') do
148
- params[:log_level] = Logger::DEBUG
149
- end
150
- opts.on("-h", "--help", "Shows this help message") do
151
- puts opts; exit
152
- end
153
- opts.parse!(ARGV) #rescue abort 'Invalid Option! Use --help or -h for usage help.'
154
-
155
- @twiddle = RBoss::Twiddle::Invoker::new params
156
-
157
- if save
158
- config = load_yaml
159
- config[save] ||= {}
160
- server_config = config[save]
161
- params.delete :jboss_home
162
- params.each do |key, value|
163
- server_config[key.to_s] = value
164
- end
165
- FileUtils::mkdir_p File.expand_path(@conf_dir)
166
- FileUtils::touch @servers_file
167
- f = File.open(@servers_file, 'w')
168
- YAML::dump(config, f)
169
- f.close
170
- puts "Configuration saved!"
171
- end
172
-
173
- def extract resource
174
- mbean, name = resource.split(/:/)
175
- mbean.gsub!(/-/, '_')
176
- [mbean, name]
177
- end
178
-
179
- puts opts if @mbeans.empty? and @commands.empty?
180
-
181
- @actions = RBoss::CommandActions::Twiddle::new @twiddle,
182
- :no_details => no_details,
183
- :mbeans => defaults
184
-
185
- def execute_actions
186
- buff = ""
187
- buff << Yummi.colorize(Time.now.strftime("At %H:%M:%S%n"), :white) if @loop
188
- buff << @actions.parse_and_execute(@commands)
189
- buff << @actions.detail(@mbeans)
190
- system "clear" if @loop
191
- puts buff
192
- end
193
-
194
- begin
195
-
196
- while @loop
197
- execute_actions
198
- sleep @interval
199
- end
200
-
201
- execute_actions
202
- rescue Interrupt
203
- puts Yummi::colorize("Aborted!", :red)
204
- end
@@ -1,125 +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
- module RBoss
24
- module CommandActions
25
- class Twiddle
26
-
27
- def initialize twiddle, opts = {}
28
- @monitor = twiddle.monitor
29
- @twiddle = twiddle
30
- @opts = opts
31
- end
32
-
33
- def parse_and_execute commands
34
- buff = ""
35
- commands.each do |method, args|
36
- buff << send(method, *args)
37
- end
38
- buff
39
- end
40
-
41
- def native command
42
- @twiddle.execute(command)
43
- end
44
-
45
- def set id, property, value
46
- mbean, name = extract id
47
- @twiddle.set :mbean => mbean.to_sym,
48
- :name => name,
49
- :property => property,
50
- :value => value
51
- end
52
-
53
- def get id, property
54
- mbean, name = extract id
55
- @twiddle.get :mbean => mbean.to_sym,
56
- :name => name,
57
- :property => property
58
- end
59
-
60
- def invoke id, method, *args
61
- mbean, name = extract id
62
- @twiddle.invoke :mbean => mbean.to_sym,
63
- :name => name,
64
- :method => method,
65
- :args => normalize(args)
66
- end
67
-
68
- def query id, *args
69
- mbean, name = extract id
70
- @twiddle.query :mbean => mbean.to_sym,
71
- :name => name,
72
- :args => normalize(args)
73
- end
74
-
75
- def info id, *args
76
- mbean, name = extract id
77
- @twiddle.info :mbean => mbean.to_sym,
78
- :name => name,
79
- :args => normalize(args)
80
- end
81
-
82
- def normalize args
83
- args.collect do |arg|
84
- "\"#{arg}\""
85
- end
86
- end
87
-
88
- def detail mbeans
89
- buff = ""
90
- mbeans.each do |mbean_id, resources|
91
- builder = RBoss::TableBuilder::new @opts[:mbeans][mbean_id]
92
- rows = []
93
- if resources.is_a? TrueClass
94
- row = []
95
- @monitor.mbean(mbean_id).detail do |name, value|
96
- row << value
97
- end
98
- rows << row
99
- elsif @opts[:no_details]
100
- builder.show_only_name
101
- @monitor.mbean(mbean_id).scan.each do |name|
102
- rows << [name]
103
- end
104
- else
105
- @monitor.mbean(mbean_id).detail resources do |resource, detail|
106
- row = [resource]
107
- detail.each do |name, value|
108
- row << value
109
- end
110
- rows << row
111
- end
112
- end
113
- table = builder.build_table
114
- table.data = rows
115
- buff << table.to_s
116
- buff << $/
117
- end
118
- buff
119
- end
120
-
121
- end
122
-
123
- end
124
-
125
- end
@@ -1,12 +0,0 @@
1
- ---
2
- description: Detail JDBC Drivers
3
- path: ${DOMAIN_HOST}${DOMAIN_SERVER}/subsystem=datasources/jdbc-driver=${NAME}
4
- scan: ls ${DOMAIN_HOST}${DOMAIN_SERVER}/subsystem=datasources/jdbc-driver
5
- print:
6
- - title: JDBC Drivers
7
- properties:
8
- - driver-module-name
9
- - driver-xa-datasource-class-name
10
- header:
11
- - Module Name
12
- - XA Datasource Class
@@ -1,179 +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
- # A main class to process components based on a highly customizable set of parameters.
24
- #
25
- # 1. Creating a ComponentProcessor
26
- # A ComponentProcessor needs a block that defines how to process a component. The block
27
- # will receive the component type and the configuration.
28
- #
29
- # Example: ComponentProcessor::new do |component_type, configuration|
30
- # component_type.new(configuration).process
31
- # end
32
- #
33
- # 2. Registering a component
34
- # Components need to be registered in the processor. The registration uses an id and a hash
35
- # of parameters described bellow:
36
- #
37
- # :type => the type of the component. Only components with a defined type will be passed to the processor block
38
- #
39
- # :multiple_instances => a flag to indicate if this component can be added more than once
40
- # :priority => a number defining a priority for this component to be processed
41
- #
42
- # :enabled => a flag to indicate if this component is enabled for processing by default
43
- #
44
- # :defaults => a hash containing the default config parameters for this component (only if the configuration is a Hash)
45
- #
46
- # :send_config => a hash for sending the configurations at process time to another component (only if the configuration
47
- # is a Hash).
48
- #
49
- # The configuration keys are sending using the pattern :to_$COMPONENT_ID and supports key overriding
50
- # Example:
51
- # :send_config => {
52
- # :to_bar_service => {
53
- # :foo => :bar
54
- # }
55
- # :to_foo_service => [:foo]
56
- # }
57
- # The :foo config will be moved to the component :bar_service using :bar as the configuration key and to the component
58
- # :foo_service using the same name as the key.
59
- #
60
- # :move_config => the same as for :send_config, but the configurations moved will not be passed to the block for this
61
- # component.
62
- #
63
- # 3. Adding a component
64
- #
65
- # A component should be added by add method. You only need to specify the component id and the configuration (if needed).
66
- # When a component is added, it will be processed for sending or moving configurations and, if the component has a type,
67
- # it will be passed to the block for processing.
68
- #
69
- # author: Marcelo Guimarães <ataxexe@gmail.com>
70
- module RBoss
71
- class ComponentProcessor
72
-
73
- def initialize &block
74
- @process = block
75
- @process ||= lambda { |type, config| type.new(config).process }
76
- end
77
-
78
- # Register a component using the given id (which must be used for adding it to process) and parameters
79
- def register component_id, params
80
- params = {
81
- :type => nil,
82
- :multiple_instances => false,
83
- :priority => 0,
84
- :enabled => false,
85
- :defaults => {}
86
- }.merge! params
87
- @components ||= {}
88
- params[:configs] ||= [] if params[:multiple_instances]
89
- @components[component_id] = params unless @components.has_key? component_id
90
- end
91
-
92
- def add component_id, config = {}
93
- registered_component = @components[component_id]
94
- return unless registered_component
95
- defaults = registered_component[:defaults]
96
- registered_component[:enabled] = true
97
- config = defaults.merge config if config.is_a? Hash
98
- if registered_component[:multiple_instances]
99
- registered_component[:configs] << config
100
- else
101
- registered_component[:config] = config
102
- end
103
- propagate_configs registered_component
104
- end
105
-
106
- def defaults component_id, defaults
107
- registered_component = @components[component_id]
108
- registered_component[:defaults] = defaults if registered_component
109
- end
110
-
111
- def process_components
112
- enabled_components = @components.find_all { |component_id, params| params[:enabled] }
113
- (enabled_components.sort_by { |key, value| value[:priority] }).each do |key, component|
114
- process_component component
115
- end
116
- end
117
-
118
- private
119
-
120
- def process_component component
121
- return unless component[:type]
122
- if component[:multiple_instances]
123
- component[:configs].each do |config|
124
- @process.call component[:type], config
125
- end
126
- else
127
- config = component[:config]
128
- config ||= component[:defaults]
129
- @process.call component[:type], config
130
- end
131
- end
132
-
133
- def propagate_configs component
134
- #TODO refactor this -----------------------------------
135
- if component[:send_config] and component[:config].is_a? Hash
136
- component[:send_config].each do |to, keys|
137
- destination = to.to_s.gsub(/^to_/, '').to_sym
138
- config = {}
139
- if keys.is_a? Array
140
- keys.each do |key|
141
- config[key] = component[:config][key] if component[:config].has_key? key
142
- end
143
- elsif keys.is_a? Hash
144
- keys.each do |k, v|
145
- config[v] = component[:config][k] if component[:config].has_key? k
146
- end
147
- end
148
- send_config destination, config
149
- end
150
- end
151
- if component[:move_config] and component[:config].is_a? Hash
152
- component[:move_config].each do |to, keys|
153
- destination = to.to_s.gsub(/^to_/, '').to_sym
154
- config = {}
155
- if keys.is_a? Array
156
- keys.each do |key|
157
- config[key] = component[:config].delete key if component[:config].has_key? key
158
- end
159
- elsif keys.is_a? Hash
160
- keys.each do |k, v|
161
- config[v] = component[:config].delete k if component[:config].has_key? k
162
- end
163
- end
164
- send_config destination, config, :enable_component => true
165
- end
166
- end
167
- #------------------------------------------------------
168
- end
169
-
170
- def send_config component_id, config, opts = {}
171
- component = @components[component_id]
172
- component[:defaults] ||= {}
173
- component_config = @components[component_id][:defaults]
174
- component_config.merge! config
175
- component[:enabled] = true if opts[:enable_component]
176
- end
177
-
178
- end
179
- end