Skip to content

Commit

Permalink
Issue #105: regenerate resources for JBoss EAP 6.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
itewk committed Mar 13, 2016
1 parent 1060bd3 commit 4a83a32
Show file tree
Hide file tree
Showing 35 changed files with 1,132 additions and 43,544 deletions.
Empty file added config/schema.eap
Empty file.
43,134 changes: 0 additions & 43,134 deletions config/schema.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/tasks/manifest.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ define jboss_admin::resource::<%= type[:name] %> (
if $<%= puppet_name attr %> == undef or $<%= puppet_name attr %> == undefined { fail('The attribute <%= puppet_name attr %> is undefined but required') }
<% end -%>
<% if !attribute[:type].nil?
if ['INT', 'LONG'].include? attribute[:type][:'TYPE_MODEL_VALUE'] -%>
if ['INT', 'LONG'].include? attribute[:type] -%>
if $<%= puppet_name attr %> != undef and $<%= puppet_name attr %> != undefined and !is_integer($<%= puppet_name attr %>) {
fail('The attribute <%= puppet_name attr %> is not an integer')
}
<% end -%>
<% if attribute[:type][:'TYPE_MODEL_VALUE'] == 'STRING' -%>
<% if attribute[:type] == 'STRING' -%>
<% if attribute[:allowed]
allowed_values = attribute[:allowed].collect{|a| "'#{a}'"}.join(',') -%>
if $<%= puppet_name attr %> != undef and $<%= puppet_name attr %> != undefined and !($<%= puppet_name attr %> in [<%= allowed_values %>]) {
fail('The attribute <%= puppet_name attr %> is not an allowed value: <%= allowed_values.gsub(/'/, '"') %>')
}
<% end
end -%>
<% if attribute[:type][:'TYPE_MODEL_VALUE'] == 'BOOLEAN' -%>
<% if attribute[:type] == 'BOOLEAN' -%>
if $<%= puppet_name attr %> != undef and $<%= puppet_name attr %> != undefined {
validate_bool($<%= puppet_name attr %>)
}
<% end -%>
<% if attribute[:type][:'TYPE_MODEL_VALUE'] == 'LIST' -%>
<% if attribute[:type] == 'LIST' -%>
if $<%= puppet_name attr %> != undef and $<%= puppet_name attr %> != undefined and !is_array($<%= puppet_name attr %>) {
fail('The attribute <%= puppet_name attr %> is not an array')
}
Expand Down
40 changes: 37 additions & 3 deletions lib/tasks/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ def schema_path
File.join Rake.application.original_dir, 'config/schema.json'
end

def schema_eap_path
File.join Rake.application.original_dir, 'config/schema.eap'
end

desc 'Cleans all resource manifests'
task :clean do
FileUtils.rm Dir.glob(File.join(resource_dir, '*'))
end

desc 'Generates resources based on config schema'
task :generate_schema => :clean do
task :generate_from_schema => :clean do
generate_from_schema schema_path, resource_dir
end

Expand All @@ -29,7 +33,37 @@ def schema_path
end

desc 'Generates resources bease on schema and custom resources'
task :generate => [:generate_schema, :overlay_custom] do

task :generate => [:generate_from_schema, :overlay_custom] do
end

desc 'Gets the CLI resource descriptions from JBoss EAP CLI'
task :get_cli_resource_descriptions do
schema_eap = `/usr/share/jbossas/bin/jboss-cli.sh -c "/:read-resource-description(recursive=true)"`
IO.write(schema_eap_path, schema_eap)
end

desc 'Create the json schema from the CLI resource descriptions'
task :create_schema do
schema_text = IO.read(schema_eap_path)

# convert the eap output to json
schema_json = schema_text
.gsub(/ => undefined/, ': null')
.gsub(/ => big decimal/, ': ')
.gsub(/=>/, ':')
.gsub(/: expression/, ': ')
.gsub(/^\s*"(type|value-type)"\s*:\s+([^{,\n]+)/,'"\1": "\2"')
.gsub(/\}\n\{/m, "},{")
.gsub(/\n/, '')
.gsub(/\t/, ' ')
.gsub(/ (-?\d+)L/, ' \1')
.gsub(/bytes\s*\{([^\}]*)\}/,'"bytes {\1}"')

# write out the json
IO.write(schema_path, schema_json)
end

desc 'Update the schema from the JBoss CLI'
task :generate_schema => [:get_cli_resource_descriptions, :create_schema] do
end
end
13 changes: 12 additions & 1 deletion lib/tasks/schema_generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
def generate_from_schema schema_path, output_dir

schema_text = IO.read(schema_path)
schema = JSON.parse schema_text, :symbolize_names => true
schema_json = schema_text
.gsub(/ => undefined/, ': null')
.gsub(/ => big decimal/, ': ')
.gsub(/=>/, ':')
.gsub(/: expression/, ': ')
.gsub(/^\s*"(type|value-type)"\s*:\s+([^{,\n]+)/,'"\1": "\2"')
.gsub(/\}\n\{/m, "},{")
.gsub(/\n/, '')
.gsub(/\t/, ' ')
.gsub(/ (-?\d+)L/, ' \1')
.gsub(/bytes\s*\{([^\}]*)\}/,'"bytes {\1}"')
schema = JSON.parse schema_json, :symbolize_names => true

manifest_template_text = IO.read(File.expand_path('../manifest.erb', __FILE__))
manifest_template = ERB.new(manifest_template_text, safe_mode = nil, trim_mode = '-')
Expand Down
41 changes: 41 additions & 0 deletions manifests/resource/authentication_kerberos.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# == Defines jboss_admin::authentication_kerberos
#
# Configuration to use Kerberos to authenticate the users.
#
# === Parameters
#
# [*remove_realm*]
# After authentication should the realm name be stripped from the users name.
#
#
define jboss_admin::resource::authentication_kerberos (
$server,
$remove_realm = undef,
$ensure = present,
$cli_path = $name,
) {
if $ensure == present {
if $remove_realm != undef and $remove_realm != undefined {
validate_bool($remove_realm)
}

$raw_options = {
'remove-realm' => $remove_realm,
}
$options = delete_undef_values($raw_options)

jboss_resource { $name:
address => $cli_path,
ensure => $ensure,
server => $server,
options => $options
}
}

if $ensure == absent {
jboss_resource { $cli_path:
ensure => $ensure,
server => $server
}
}
}
65 changes: 65 additions & 0 deletions manifests/resource/cache_by_access_time.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# == Defines jboss_admin::cache_by_access_time
#
# A cache to hold the results of previous LDAP interactions.
#
# === Parameters
#
# [*cache_failures*]
# Should failures be cached?
#
# [*cache_size*]
# The current size of the cache.
#
# [*eviction_time*]
# The time in seconds until an entry should be evicted from the cache.
#
# [*max_cache_size*]
# The maximum size of the cache before the oldest items are removed to make room for new entries.
#
#
define jboss_admin::resource::cache_by_access_time (
$server,
$cache_failures = undef,
$cache_size = undef,
$eviction_time = undef,
$max_cache_size = undef,
$ensure = present,
$cli_path = $name,
) {
if $ensure == present {
if $cache_failures != undef and $cache_failures != undefined {
validate_bool($cache_failures)
}
if $cache_size != undef and $cache_size != undefined and !is_integer($cache_size) {
fail('The attribute cache_size is not an integer')
}
if $eviction_time != undef and $eviction_time != undefined and !is_integer($eviction_time) {
fail('The attribute eviction_time is not an integer')
}
if $max_cache_size != undef and $max_cache_size != undefined and !is_integer($max_cache_size) {
fail('The attribute max_cache_size is not an integer')
}

$raw_options = {
'cache-failures' => $cache_failures,
'cache-size' => $cache_size,
'eviction-time' => $eviction_time,
'max-cache-size' => $max_cache_size,
}
$options = delete_undef_values($raw_options)

jboss_resource { $name:
address => $cli_path,
ensure => $ensure,
server => $server,
options => $options
}
}

if $ensure == absent {
jboss_resource { $cli_path:
ensure => $ensure,
server => $server
}
}
}
65 changes: 65 additions & 0 deletions manifests/resource/cache_by_search_time.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# == Defines jboss_admin::cache_by_search_time
#
# A cache to hold the results of previous LDAP interactions.
#
# === Parameters
#
# [*cache_failures*]
# Should failures be cached?
#
# [*cache_size*]
# The current size of the cache.
#
# [*eviction_time*]
# The time in seconds until an entry should be evicted from the cache.
#
# [*max_cache_size*]
# The maximum size of the cache before the oldest items are removed to make room for new entries.
#
#
define jboss_admin::resource::cache_by_search_time (
$server,
$cache_failures = undef,
$cache_size = undef,
$eviction_time = undef,
$max_cache_size = undef,
$ensure = present,
$cli_path = $name,
) {
if $ensure == present {
if $cache_failures != undef and $cache_failures != undefined {
validate_bool($cache_failures)
}
if $cache_size != undef and $cache_size != undefined and !is_integer($cache_size) {
fail('The attribute cache_size is not an integer')
}
if $eviction_time != undef and $eviction_time != undefined and !is_integer($eviction_time) {
fail('The attribute eviction_time is not an integer')
}
if $max_cache_size != undef and $max_cache_size != undefined and !is_integer($max_cache_size) {
fail('The attribute max_cache_size is not an integer')
}

$raw_options = {
'cache-failures' => $cache_failures,
'cache-size' => $cache_size,
'eviction-time' => $eviction_time,
'max-cache-size' => $max_cache_size,
}
$options = delete_undef_values($raw_options)

jboss_resource { $name:
address => $cli_path,
ensure => $ensure,
server => $server,
options => $options
}
}

if $ensure == absent {
jboss_resource { $cli_path:
ensure => $ensure,
server => $server
}
}
}
8 changes: 8 additions & 0 deletions manifests/resource/configuration_sso.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# [*domain*]
# The cookie domain that will be used.
#
# [*http_only*]
# The cookie http-only flag will be set.
#
# [*reauthenticate*]
# Enables reauthentication with the realm when using SSO.
#
Expand All @@ -22,11 +25,15 @@
$cache_container = undef,
$cache_name = undef,
$domain = undef,
$http_only = undef,
$reauthenticate = undef,
$ensure = present,
$cli_path = $name,
) {
if $ensure == present {
if $http_only != undef and $http_only != undefined {
validate_bool($http_only)
}
if $reauthenticate != undef and $reauthenticate != undefined {
validate_bool($reauthenticate)
}
Expand All @@ -35,6 +42,7 @@
'cache-container' => $cache_container,
'cache-name' => $cache_name,
'domain' => $domain,
'http-only' => $http_only,
'reauthenticate' => $reauthenticate,
}
$options = delete_undef_values($raw_options)
Expand Down
56 changes: 0 additions & 56 deletions manifests/resource/custom_load_metric.pp

This file was deleted.

4 changes: 2 additions & 2 deletions manifests/resource/data_source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# Defines the JDBC driver the datasource should use. It is a symbolic name matching the the name of installed driver. In case the driver is deployed as jar, the name is the name of deployment unit
#
# [*enabled*]
# Specifies if the datasource should be enabled
# Specifies if the datasource should be enabled. Note this attribute will not be supported runtime in next versions.
#
# [*exception_sorter_class_name*]
# An org.jboss.jca.adapters.jdbc.ExceptionSorter that provides an isExceptionFatal(SQLException) method to validate if an exception should broadcast an error
Expand Down Expand Up @@ -110,7 +110,7 @@
# The stale connection checker properties
#
# [*statistics_enabled*]
# define if runtime statistics is enabled or not
# define if runtime statistics is enabled or not.
#
# [*track_statements*]
# Whether to check for unclosed statements when a connection is returned to the pool, result sets are closed, a statement is closed or return to the prepared statement cache. Valid values are: "false" - do not track statements, "true" - track statements and result sets and warn when they are not closed, "nowarn" - track statements but do not warn about them being unclosed
Expand Down
Loading

0 comments on commit 4a83a32

Please sign in to comment.