Class: Redfish::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/redfish/executor.rb

Instance Method Summary collapse

Instance Method Details

#exec(context, asadmin_command, args = [], options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/redfish/executor.rb', line 3

def exec(context, asadmin_command, args = [], options = {})
  raise 'args should be an array' unless args.is_a?(Array)

  cmd = build_command(context, asadmin_command, args, options)

  output = nil
  IO.popen(cmd,'r') do |pipe|
    output = pipe.read
  end

  raise "Asadmin command failed #{asadmin_command} with exist status #{last_exitstatus}" if 0 != last_exitstatus
  output
end