rboss 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/README.md +2 -2
  2. data/bin/jboss-profile +1 -1
  3. data/bin/rboss-cli +8 -2
  4. data/bin/twiddle +3 -3
  5. data/lib/rboss.rb +6 -2
  6. data/lib/rboss/bin/command_actions.rb +3 -2
  7. data/lib/rboss/cli/jboss_cli.rb +3 -3
  8. data/lib/rboss/cli/mappings.rb +12 -2
  9. data/lib/rboss/cli/mappings/resources/connector.yaml +10 -35
  10. data/lib/rboss/cli/mappings/resources/datasource.yaml +19 -26
  11. data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +0 -1
  12. data/lib/rboss/cli/mappings/resources/server.yaml +151 -34
  13. data/lib/rboss/cli/resource.rb +18 -10
  14. data/lib/rboss/component_processor.rb +87 -85
  15. data/lib/rboss/components/component.rb +2 -2
  16. data/lib/rboss/components/datasource.rb +1 -1
  17. data/lib/rboss/components/deploy_folder.rb +1 -1
  18. data/lib/rboss/components/hypersonic_replacer.rb +1 -1
  19. data/lib/rboss/components/jbossweb.rb +1 -1
  20. data/lib/rboss/components/jmx.rb +1 -1
  21. data/lib/rboss/components/mod_cluster.rb +1 -1
  22. data/lib/rboss/components/org/6.0/deploy_folder.rb +1 -1
  23. data/lib/rboss/components/org/jmx.rb +1 -1
  24. data/lib/rboss/components/profile_folder.rb +1 -1
  25. data/lib/rboss/components/resource.rb +1 -1
  26. data/lib/rboss/components/restore_slimming.rb +3 -3
  27. data/lib/rboss/components/run_conf.rb +4 -4
  28. data/lib/rboss/components/service_script.rb +1 -1
  29. data/lib/rboss/components/slimming.rb +1 -1
  30. data/lib/rboss/components/soa-p/hypersonic_replacer.rb +1 -1
  31. data/lib/rboss/components/soa-p/jmx.rb +1 -1
  32. data/lib/rboss/components/xadatasource.rb +2 -2
  33. data/lib/rboss/file_processor.rb +70 -66
  34. data/lib/rboss/jboss_path.rb +1 -1
  35. data/lib/rboss/jboss_profile.rb +28 -27
  36. data/lib/rboss/plaftorm.rb +64 -0
  37. data/lib/rboss/resources/run.conf.bat.erb +60 -0
  38. data/lib/rboss/twiddle/base_monitor.rb +2 -2
  39. data/lib/rboss/twiddle/mbean.rb +1 -1
  40. data/lib/rboss/twiddle/monitor.rb +26 -39
  41. data/lib/rboss/twiddle/twiddle.rb +3 -2
  42. data/lib/rboss/utils.rb +0 -62
  43. data/lib/rboss/version.rb +1 -1
  44. data/lib/rboss/view/colorizers.rb +20 -0
  45. data/lib/rboss/view/formatters.rb +21 -0
  46. data/lib/rboss/view/health_checkers.rb +41 -0
  47. data/lib/rboss/view/table_builder.rb +93 -0
  48. data/test/test_helper.rb +1 -1
  49. metadata +8 -6
  50. data/lib/rboss/cli.rb +0 -22
  51. data/lib/rboss/cli/colorizers.rb +0 -22
  52. data/lib/rboss/cli/formatters.rb +0 -17
  53. data/lib/rboss/cli/health_checkers.rb +0 -43
@@ -20,11 +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
- require_relative 'formatters'
24
- require_relative 'colorizers'
25
- require_relative 'health_checkers'
26
-
27
- module JBoss
23
+ module RBoss
28
24
  module Cli
29
25
  class Resource
30
26
 
@@ -32,7 +28,8 @@ module JBoss
32
28
  @config = config
33
29
  @invoker = invoker
34
30
  @context = {
35
- :name => ''
31
+ :name => '',
32
+ :read_resource => 'read-resource(include-runtime=true)'
36
33
  }
37
34
  @context[:path] = parse(@config[:path])
38
35
  @tables = []
@@ -40,13 +37,13 @@ module JBoss
40
37
  end
41
38
 
42
39
  def content(resources)
43
- if :all == resources
40
+ if :all == resources and scannable?
44
41
  resources = scan
45
42
  end
46
43
  resources = [resources] unless resources.is_a? Array
47
44
  params = @config[:print]
48
45
  params.each do |p|
49
- table_builder = TableBuilder::new p
46
+ table_builder = RBoss::TableBuilder::new p
50
47
  table_builder.add_name_column if scannable?
51
48
  @tables << table_builder.build_table
52
49
  end
@@ -61,6 +58,7 @@ module JBoss
61
58
  result = ""
62
59
  @tables.each do |table|
63
60
  result << table.to_s
61
+ result << $/
64
62
  end
65
63
  result
66
64
  end
@@ -93,17 +91,27 @@ module JBoss
93
91
  end
94
92
 
95
93
  def get_data(config)
96
- result = @invoker.execute(parse config[:command])
94
+ command = (config[:command] or '${PATH}:${READ_RESOURCE}')
95
+ result = @invoker.execute(parse command)
97
96
  result = eval_result(result)
98
97
  data = []
99
98
  config[:properties].each do |prop|
100
- data << result["result"][prop]
99
+ data << get_property(prop, result)
101
100
  end
102
101
  data
103
102
  end
104
103
 
104
+ def get_property(prop, result)
105
+ value = result["result"]
106
+ prop.split(/\s*->\s*/).each do |p|
107
+ value = value[p]
108
+ end
109
+ value
110
+ end
111
+
105
112
  def eval_result(result)
106
113
  undefined = nil #prevents error because undefined means nil in result object
114
+ result = result.gsub /(\d+)L/, '\1' #removes the long type mark
107
115
  eval(result)
108
116
  end
109
117
 
@@ -67,111 +67,113 @@
67
67
  # it will be passed to the block for processing.
68
68
  #
69
69
  # author: Marcelo Guimarães <ataxexe@gmail.com>
70
- class ComponentProcessor
70
+ module RBoss
71
+ class ComponentProcessor
71
72
 
72
- def initialize &block
73
- @process = block
74
- @process ||= lambda { |type, config| type.new(config).process }
75
- end
73
+ def initialize &block
74
+ @process = block
75
+ @process ||= lambda { |type, config| type.new(config).process }
76
+ end
76
77
 
77
- # Register a component using the given id (which must be used for adding it to process) and parameters
78
- def register component_id, params
79
- params = {
80
- :type => nil,
81
- :multiple_instances => false,
82
- :priority => 0,
83
- :enabled => false,
84
- :defaults => {}
85
- }.merge! params
86
- @components ||= {}
87
- params[:configs] ||= [] if params[:multiple_instances]
88
- @components[component_id] = params unless @components.has_key? component_id
89
- end
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
90
91
 
91
- def add component_id, config = {}
92
- registered_component = @components[component_id]
93
- return unless registered_component
94
- defaults = registered_component[:defaults]
95
- registered_component[:enabled] = true
96
- config = defaults.merge config if config.is_a? Hash
97
- if registered_component[:multiple_instances]
98
- registered_component[:configs] << config
99
- else
100
- registered_component[:config] = config
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
101
104
  end
102
- propagate_configs registered_component
103
- end
104
105
 
105
- def defaults component_id, defaults
106
- registered_component = @components[component_id]
107
- registered_component[:defaults] = defaults if registered_component
108
- end
106
+ def defaults component_id, defaults
107
+ registered_component = @components[component_id]
108
+ registered_component[:defaults] = defaults if registered_component
109
+ end
109
110
 
110
- def process_components
111
- enabled_components = @components.find_all {|component_id, params| params[:enabled]}
112
- (enabled_components.sort_by { |key, value| value[:priority] }).each do |key, component|
113
- process_component component
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
114
116
  end
115
- end
116
117
 
117
- private
118
+ private
118
119
 
119
- def process_component component
120
- return unless component[:type]
121
- if component[:multiple_instances]
122
- component[:configs].each do |config|
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]
123
129
  @process.call component[:type], config
124
130
  end
125
- else
126
- config = component[:config]
127
- config ||= component[:defaults]
128
- @process.call component[:type], config
129
131
  end
130
- end
131
132
 
132
- def propagate_configs component
133
- #TODO refactor this -----------------------------------
134
- if component[:send_config] and component[:config].is_a? Hash
135
- component[:send_config].each do |to, keys|
136
- destination = to.to_s.gsub(/^to_/, '').to_sym
137
- config = {}
138
- if keys.is_a? Array
139
- keys.each do |key|
140
- config[key] = component[:config][key] if component[:config].has_key? key
141
- end
142
- elsif keys.is_a? Hash
143
- keys.each do |k, v|
144
- config[v] = component[:config][k] if component[:config].has_key? k
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
145
147
  end
148
+ send_config destination, config
146
149
  end
147
- send_config destination, config
148
150
  end
149
- end
150
- if component[:move_config] and component[:config].is_a? Hash
151
- component[:move_config].each do |to, keys|
152
- destination = to.to_s.gsub(/^to_/, '').to_sym
153
- config = {}
154
- if keys.is_a? Array
155
- keys.each do |key|
156
- config[key] = component[:config].delete key if component[:config].has_key? key
157
- end
158
- elsif keys.is_a? Hash
159
- keys.each do |k, v|
160
- config[v] = component[:config].delete k if component[:config].has_key? k
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
161
163
  end
164
+ send_config destination, config, :enable_component => true
162
165
  end
163
- send_config destination, config, :enable_component => true
164
166
  end
167
+ #------------------------------------------------------
165
168
  end
166
- #------------------------------------------------------
167
- end
168
169
 
169
- def send_config component_id, config, opts = {}
170
- component = @components[component_id]
171
- component[:defaults] ||= {}
172
- component_config = @components[component_id][:defaults]
173
- component_config.merge! config
174
- component[:enabled] = true if opts[:enable_component]
175
- end
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
176
177
 
178
+ end
177
179
  end
@@ -26,7 +26,7 @@ require_relative "../utils"
26
26
 
27
27
  require 'yaml'
28
28
 
29
- module JBoss
29
+ module RBoss
30
30
 
31
31
  # A base helper module for JBoss Components
32
32
  #
@@ -47,7 +47,7 @@ module JBoss
47
47
  # Creates a FileProcessor using the same logger and
48
48
  # jboss path as the variable
49
49
  def new_file_processor
50
- FileProcessor::new :logger => @logger, :var => @jboss
50
+ RBoss::FileProcessor::new :logger => @logger, :var => @jboss
51
51
  end
52
52
 
53
53
  def load_yaml resource
@@ -27,7 +27,7 @@ require "rexml/document"
27
27
 
28
28
  include REXML
29
29
 
30
- module JBoss
30
+ module RBoss
31
31
 
32
32
  # A class to configure a JBoss Datasource.
33
33
  #
@@ -26,7 +26,7 @@ require "rexml/document"
26
26
 
27
27
  include REXML
28
28
 
29
- module JBoss
29
+ module RBoss
30
30
 
31
31
  # A class to add deploy folders to a JBoss Profile.
32
32
  #
@@ -23,7 +23,7 @@
23
23
  require_relative "datasource"
24
24
  require_relative "component"
25
25
 
26
- module JBoss
26
+ module RBoss
27
27
  # A class to replace the shipped Hypersonic datasource for a JBoss profile.
28
28
  #
29
29
  # Configuration:
@@ -26,7 +26,7 @@ require "rexml/document"
26
26
 
27
27
  include REXML
28
28
 
29
- module JBoss
29
+ module RBoss
30
30
  class JBossWeb
31
31
  include Component
32
32
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative "component"
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  # This class configures the JXM user for a JBoss profile.
27
27
  #
28
28
  # Configuration:
@@ -28,7 +28,7 @@ require "rexml/document"
28
28
 
29
29
  include REXML
30
30
 
31
- module JBoss
31
+ module RBoss
32
32
  # A class to install and configure a mod_cluster service in a JBoss profile
33
33
  #
34
34
  # Configuration:
@@ -20,7 +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
- module JBoss
23
+ module RBoss
24
24
 
25
25
  class DeployFolder
26
26
 
@@ -20,7 +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
- module JBoss
23
+ module RBoss
24
24
 
25
25
  # An extension to the base JXM class that secures the jmx-console
26
26
  # for the JBoss.org servers.
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative "component"
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  class ProfileFolder
27
27
  include Component, FileUtils
28
28
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative "component"
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
 
27
27
  # A class to add resources to a JBoss Profile
28
28
  #
@@ -22,15 +22,15 @@
22
22
 
23
23
  require_relative 'slimming'
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  # A class for restore slimmed services in a JBoss profile
27
27
  #
28
28
  # Configuration:
29
29
  #
30
- # See the JBoss::Slimming class for supported services
30
+ # See the RBoss::Slimming class for supported services
31
31
  #
32
32
  # author: Marcelo Guimarães <ataxexe@gmail.com>
33
- class Restore < JBoss::Slimming
33
+ class Restore < RBoss::Slimming
34
34
 
35
35
  def log service
36
36
  @logger.info "Enabling #{service}"
@@ -25,7 +25,7 @@ require_relative "component"
25
25
  require 'yaml'
26
26
  require 'erb'
27
27
 
28
- module JBoss
28
+ module RBoss
29
29
  # A class to create a custom run.conf file to a JBoss Profile
30
30
  #
31
31
  # The configuration is based on a erb template, variables and jvm args:
@@ -39,7 +39,7 @@ module JBoss
39
39
  #
40
40
  # author: Marcelo Guimarães <ataxexe@gmail.com>
41
41
  class RunConf
42
- include Component
42
+ include Component, RBoss::Platform
43
43
 
44
44
  def defaults
45
45
  {:jvm_args => []}
@@ -61,11 +61,11 @@ module JBoss
61
61
  action.to_process do |content|
62
62
  process_template content
63
63
  end
64
- processor.copy_to "#{@jboss.profile}/run.conf"
64
+ processor.copy_to run_conf
65
65
  end
66
66
  processor.process
67
67
  else
68
- File.open("#{@jboss.profile}/run.conf", "w+") { |f| f.write process_template @template }
68
+ File.open(run_conf, "w+") { |f| f.write process_template @template }
69
69
  end
70
70
  end
71
71
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative "component"
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
 
27
27
  class ServiceScript
28
28
  include Component