Method: Racadm.racadm_call

Defined in:
lib/puppet_x/racadm/racadm.rb

.racadm_call(racadm_args, cmd_args, suppress_error = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet_x/racadm/racadm.rb', line 7

def self.racadm_call(racadm_args, cmd_args, suppress_error = false)
  cmd = ['/opt/dell/srvadmin/bin/idracadm7']
  unless racadm_args[:bmc_server_host].nil? ||
         racadm_args[:bmc_username].nil? ||
         racadm_args[:bmc_password].nil?

    cmd.push('-u').push(racadm_args[:bmc_username]) if racadm_args[:bmc_username]
    cmd.push('-p').push(racadm_args[:bmc_password]) if racadm_args[:bmc_password]
    cmd.push('-r').push(racadm_args[:bmc_server_host]) if racadm_args[:bmc_server_host]
  end

  cmd += cmd_args
  stdout, stderr, status = Open3.capture3(cmd.join(' '))
  nr = cmd.index('-p')
  cmd.fill('<secret>', nr + 1, 1) unless nr.nil? # password is not logged.
  Puppet.debug("#{cmd.join(' ')} executed with stdout: '#{stdout}' stderr: '#{stderr}' status: '#{status}'")
  if !status.success? && !suppress_error
    raise(Puppet::Error, "#{cmd.join(' ')} failed with #{stdout}")
  end
  stdout
end