lib/puppet_x/coi/jboss/internal/cli_executor.rb
# Method that will prepare and delegate execution of command
# @param jbosscmd     [String]  command to be execute_and_get
# @param _runasdomain [Boolean] if jboss is run in domain mode
# @param ctrlcfg      [Hash]    configuration Hash
# @param try [PuppetX::Coi::Jboss::Value::Try] the try object
# @return [PuppetX::Coi::Jboss::Internal::State::ExecutionState] a state of execution
Method that will prepare and delegate execution of command
Method that will prepare and delegate execution of command
def run_jboss_command(jbosscmd, _runasdomain, ctrlcfg, try)
    file = Tempfile.new 'jbosscli'
    path = file.path
    file.close
    file.unlink
    File.open(path, 'w') { |f| f.write(jbosscmd + "\n") }
    cmd = prepare_command(path, ctrlcfg)
    retries = 0
    result = nil
    loop do
      if retries > 0
        Puppet.warning "JBoss CLI command failed, try #{retries}/#{try.count}, last status: #{result}, message: #{result.output}"
        sleep try.timeout
      end
      Puppet.debug "OS command to be executed #{cmd.command}"
      Puppet.debug "JBoss CLI command to be executed: #{jbosscmd}"
      result = @executor.execute(cmd, jbosscmd)
      retries += 1
      break if result.success? || retries > try.count
    end
    Puppet.debug "Output from JBoss CLI [#{result.retcode}]: #{result.output}"
    result
  ensure
    File.unlink path
  end
def run_jboss_command ( jbosscmd , _runasdomain , ctrlcfg , try ) file = Tempfile . new 'jbosscli' path = file . path file . close file . unlink File . open ( path , 'w' ) { | f | f . write ( jbosscmd + "\n" ) } cmd = prepare_command ( path , ctrlcfg ) retries = 0 result = nil loop do if retries > 0 Puppet . warning "JBoss CLI command failed, try #{retries}/#{try.count}, last status: #{result}, message: #{result.output}" sleep try . timeout end Puppet . debug "OS command to be executed #{cmd.command}" Puppet . debug "JBoss CLI command to be executed: #{jbosscmd}" result = @executor . execute ( cmd , jbosscmd ) retries += 1 break if result . success? || retries > try . count end Puppet . debug "Output from JBoss CLI [#{result.retcode}]: #{result.output}" result ensure File . unlink path end
Method that will prepare and delegate execution of command
Method that will prepare and delegate execution of command
# deletes the temp file
a state of execution
a state of execution
PuppetX::Coi::Jboss::Internal::State::ExecutionState
jbosscmd
command to be execute_and_get
command to be execute_and_get
_runasdomain
if jboss is run in domain mode
if jboss is run in domain mode
ctrlcfg
None
try
the try object
the try object