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.



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/chef_metal/transport/winrm.rb', line 103

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.



119
120
121
# File 'lib/chef_metal/transport/winrm.rb', line 119

def command
  @command
end

#configObject (readonly)

Returns the value of attribute config.



121
122
123
# File 'lib/chef_metal/transport/winrm.rb', line 121

def config
  @config
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



118
119
120
# File 'lib/chef_metal/transport/winrm.rb', line 118

def exitstatus
  @exitstatus
end

#optionsObject (readonly)

Returns the value of attribute options.



120
121
122
# File 'lib/chef_metal/transport/winrm.rb', line 120

def options
  @options
end

#stderrObject (readonly)

Returns the value of attribute stderr.



117
118
119
# File 'lib/chef_metal/transport/winrm.rb', line 117

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



116
117
118
# File 'lib/chef_metal/transport/winrm.rb', line 116

def stdout
  @stdout
end

Instance Method Details

#error!Object



123
124
125
126
127
128
129
130
# File 'lib/chef_metal/transport/winrm.rb', line 123

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