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.



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/chef_metal/transport/winrm.rb', line 74

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.



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

def command
  @command
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



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

def exitstatus
  @exitstatus
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#stderrObject (readonly)

Returns the value of attribute stderr.



87
88
89
# File 'lib/chef_metal/transport/winrm.rb', line 87

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



86
87
88
# File 'lib/chef_metal/transport/winrm.rb', line 86

def stdout
  @stdout
end

Instance Method Details

#error!Object



92
93
94
95
96
97
98
# File 'lib/chef_metal/transport/winrm.rb', line 92

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