Class: Puppet_X::Coi::Jboss::Configuration
- Inherits:
-
Object
- Object
- Puppet_X::Coi::Jboss::Configuration
- Defined in:
- lib/puppet_x/coi/jboss/configuration.rb
Overview
A class for JBoss configuration
Class Method Summary collapse
-
.config_value(key) ⇒ Object
Gets configuration value by its symbol.
-
.configfile ⇒ Object
Gets the main config file.
-
.is_pre_wildfly? ⇒ Boolean
Checks is this execution is taking place on pre wildfly server.
-
.read ⇒ Hash
Read the configuration with augeas.
-
.read_raw_profile_d ⇒ Object
Method that reads file.
-
.reset_config(value = nil) ⇒ Object
Resets configuration.
-
.ruby_version ⇒ Object
Test method that return current version(for comatability with ruby 1.8).
Class Method Details
.config_value(key) ⇒ Object
Gets configuration value by its symbol
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 72 def config_value(key) @config = self.read if @config.nil? ret = nil unless @config.nil? arr = @config.map { |k,v| [k.to_s.to_sym, v] } h = Hash[arr] ret = h[key] end ret end |
.configfile ⇒ Object
Gets the main config file
13 14 15 16 17 18 19 20 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 13 def configfile content = self.read_raw_profile_d.chomp re = /export JBOSS_CONF=\'([^\']+)\'/ m = re.match(content) m[1] rescue ENV['JBOSS_CONF'] end |
.is_pre_wildfly? ⇒ Boolean
Checks is this execution is taking place on pre wildfly server
53 54 55 56 57 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 53 def is_pre_wildfly? product = self.config_value(:product) version = self.config_value(:version) product == 'jboss-as' or ( product == 'jboss-eap' and version < '6.3.0.GA' ) end |
.read ⇒ Hash
Read the configuration with augeas
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 25 def read require 'augeas' map = nil cfgfile = self.configfile unless cfgfile.nil? aug = Augeas::open('/', nil, Augeas::NO_MODL_AUTOLOAD) aug.transform(:lens => 'Shellvars.lns', :incl => cfgfile, :name => 'jboss-as.conf') aug.load is_bool = lambda { |value| !/^(true|false)$/.match(value).nil? } to_bool = lambda { |value| if !/^true$/.match(value).nil? then true else false end } map = {} aug.match("/files#{cfgfile}/*").each do |key| m = key[/(JBOSS_.+)$/] if m v = aug.get(key) v = to_bool.call(v) if is_bool.call(v) map[m.downcase.sub('jboss_', '')] = v end end aug.close end map end |
.read_raw_profile_d ⇒ Object
Method that reads file
84 85 86 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 84 def read_raw_profile_d File.read('/etc/profile.d/jboss.sh') end |
.reset_config(value = nil) ⇒ Object
Resets configuration
63 64 65 66 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 63 def reset_config(value = nil) @config = value nil end |
.ruby_version ⇒ Object
Test method that return current version(for comatability with ruby 1.8)
8 9 10 |
# File 'lib/puppet_x/coi/jboss/configuration.rb', line 8 def ruby_version RUBY_VERSION end |