Class: Chef::Provisioning::Transport::WinRM::WinRMResult

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provisioning/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.



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/chef/provisioning/transport/winrm.rb', line 119

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.



135
136
137
# File 'lib/chef/provisioning/transport/winrm.rb', line 135

def command
  @command
end

#configObject (readonly)

Returns the value of attribute config.



137
138
139
# File 'lib/chef/provisioning/transport/winrm.rb', line 137

def config
  @config
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



134
135
136
# File 'lib/chef/provisioning/transport/winrm.rb', line 134

def exitstatus
  @exitstatus
end

#optionsObject (readonly)

Returns the value of attribute options.



136
137
138
# File 'lib/chef/provisioning/transport/winrm.rb', line 136

def options
  @options
end

#stderrObject (readonly)

Returns the value of attribute stderr.



133
134
135
# File 'lib/chef/provisioning/transport/winrm.rb', line 133

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



132
133
134
# File 'lib/chef/provisioning/transport/winrm.rb', line 132

def stdout
  @stdout
end

Instance Method Details

#error!Object



139
140
141
142
143
144
145
146
# File 'lib/chef/provisioning/transport/winrm.rb', line 139

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