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, config, output) ⇒ WinRMResult

Returns a new instance of WinRMResult.



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

def initialize(command, options, config, output)
  @command = command
  @options = options
  @config = config
  @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.



95
96
97
# File 'lib/chef_metal/transport/winrm.rb', line 95

def command
  @command
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



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

def exitstatus
  @exitstatus
end

#optionsObject (readonly)

Returns the value of attribute options.



96
97
98
# File 'lib/chef_metal/transport/winrm.rb', line 96

def options
  @options
end

#stderrObject (readonly)

Returns the value of attribute stderr.



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

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



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

def stdout
  @stdout
end

Instance Method Details

#error!Object



98
99
100
101
102
103
104
105
# File 'lib/chef_metal/transport/winrm.rb', line 98

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