Class: Puppet_X::Coi::Jboss::Provider::SecurityDomain::AbstractProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb

Overview

A module for JBoss security domain common abstract resource

Direct Known Subclasses

PostWildFlyProvider, PreWildFlyProvider

Constant Summary collapse

COMMAND_SPLITTER =
','
NEWLINE_REPLACEMENT =
' '

Instance Method Summary collapse

Constructor Details

#initialize(resource, compilator) ⇒ AbstractProvider

Standard constructor

Parameters:



7
8
9
10
# File 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb', line 7

def initialize(resource, compilator)
  @resource = resource
  @compilator = compilator
end

Instance Method Details

#build_main_commandString

Creates a parametrized command to be executed by resource

Returns:

  • (String)

    a complete command without profile



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb', line 17

def build_main_command
  res = @resource
  correct_cmd = correct_command_template_begining(res)
  options = []
  res[:moduleoptions].keys.sort.each do |key|
    value = res[:moduleoptions][key]
    val = value
    # FIXME: After coi-gov-pl/puppet-jboss#59 is resolved the fallowing lines
    # should be moved to mungle function in securitydomain type not resource
    val = 'undefined' if val.nil?
    val = val.to_s if val.is_a?(Symbol)
    # New lines in values are not supported, they can't be passed to JBoss CLI
    val = val.gsub(/\n/, NEWLINE_REPLACEMENT).strip if val.is_a?(String)
    options << module_option_template % [key.inspect, val.inspect]
  end
  correct_cmd += options.join(COMMAND_SPLITTER) + correct_command_template_ending
end

#compile_command(base_command, resource) ⇒ String

Methods that compiles jboss command

Parameters:

  • command (String)

    jboss command that will be executed

Returns:

  • (String)

    comamnd with profile if needed



45
46
47
# File 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb', line 45

def compile_command(base_command, resource)
  @compilator.compile(resource[:runasdomain], resource[:profile], base_command)
end

#get_commands(state, resource) ⇒ List

Method that decides about what commands should be executed

Parameters:

Returns:

  • (List)

    commands



38
39
40
# File 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb', line 38

def get_commands(state, resource)
  decide(resource, state)
end