Class: VagrantWindows::Communication::WinRMShell

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-windows/communication/winrmshell.rb

Constant Summary collapse

@@exceptions_to_retry_on =

These are the exceptions that we retry because they represent errors that are generally fixed from a retry and don’t necessarily represent immediate failure cases.

[
  HTTPClient::KeepAliveDisconnected,
  WinRM::WinRMHTTPTransportError,
  Errno::EACCES,
  Errno::EADDRINUSE,
  Errno::ECONNREFUSED,
  Errno::ECONNRESET,
  Errno::ENETUNREACH,
  Errno::EHOSTUNREACH,
  Timeout::Error
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, username, password, options = {}) ⇒ WinRMShell

Returns a new instance of WinRMShell.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 36

def initialize(host, username, password, options = {})
  @logger = Log4r::Logger.new("vagrant_windows::communication::winrmshell")
  @logger.debug("initializing WinRMShell")
  
  @host = host
  @port = options[:port] || 5985
  @username = username
  @password = password
  @timeout_in_seconds = options[:timeout_in_seconds] || 60
  @max_tries = options[:max_tries] || 20
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



31
32
33
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 31

def host
  @host
end

#loggerObject (readonly)

Returns the value of attribute logger.



28
29
30
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 28

def logger
  @logger
end

#max_triesObject (readonly)

Returns the value of attribute max_tries.



34
35
36
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 34

def max_tries
  @max_tries
end

#passwordObject (readonly)

Returns the value of attribute password.



30
31
32
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 30

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



32
33
34
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 32

def port
  @port
end

#timeout_in_secondsObject (readonly)

Returns the value of attribute timeout_in_seconds.



33
34
35
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 33

def timeout_in_seconds
  @timeout_in_seconds
end

#usernameObject (readonly)

Returns the value of attribute username.



29
30
31
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 29

def username
  @username
end

Instance Method Details

#cmd(command, &block) ⇒ Object



52
53
54
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 52

def cmd(command, &block)
  execute_shell(command, :cmd, &block)
end

#powershell(command, &block) ⇒ Object



48
49
50
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 48

def powershell(command, &block)
  execute_shell(command, :powershell, &block)
end

#wql(query) ⇒ Object



56
57
58
# File 'lib/vagrant-windows/communication/winrmshell.rb', line 56

def wql(query)
  execute_wql(query)
end