Class: ChefMetal::Transport::WinRM::WinRMResult

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_metal/transport/winrm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, options, output) ⇒ WinRMResult

Returns a new instance of WinRMResult.



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/chef_metal/transport/winrm.rb', line 77

def initialize(command, options, output)
  @command = command
  @options = options
  @exitstatus = output[:exitcode]
  @stdout = ''
  @stderr = ''
  output[:data].each do |data|
    @stdout << data[:stdout] if data[:stdout]
    @stderr << data[:stderr] if data[:stderr]
  end
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



92
93
94
# File 'lib/chef_metal/transport/winrm.rb', line 92

def command
  @command
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



91
92
93
# File 'lib/chef_metal/transport/winrm.rb', line 91

def exitstatus
  @exitstatus
end

#optionsObject (readonly)

Returns the value of attribute options.



93
94
95
# File 'lib/chef_metal/transport/winrm.rb', line 93

def options
  @options
end

#stderrObject (readonly)

Returns the value of attribute stderr.



90
91
92
# File 'lib/chef_metal/transport/winrm.rb', line 90

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



89
90
91
# File 'lib/chef_metal/transport/winrm.rb', line 89

def stdout
  @stdout
end

Instance Method Details

#error!Object



95
96
97
98
99
100
101
102
# File 'lib/chef_metal/transport/winrm.rb', line 95

def error!
  if exitstatus != 0
    msg = "Error: command '#{command}' exited with code #{exitstatus}.\n"
    msg << "STDOUT: #{stdout}" if !options[:stream] && !options[:stream_stdout] && Chef::Config.log_level != :debug
    msg << "STDERR: #{stderr}" if !options[:stream] && !options[:stream_stderr] && Chef::Config.log_level != :debug
    raise msg
  end
end