Method: Windows::Exec#ssh_service_restart

Defined in:
lib/beaker/host/windows/exec.rb

#ssh_service_restartResult

Restarts the SSH service.

Returns:

  • (Result)

    result of starting SSH service



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/beaker/host/windows/exec.rb', line 66

def ssh_service_restart
  command_result = nil
  # we get periodic failures to restart the service, so looping these with re-attempts
  repeat_fibonacci_style_for(5) do
    0 == exec(Beaker::Command.new("cygrunsrv -E sshd"), :acceptable_exit_codes => [0, 1] ).exit_code
  end
  repeat_fibonacci_style_for(5) do
    command_result = exec(Beaker::Command.new("cygrunsrv -S sshd"), :acceptable_exit_codes => [0, 1] )
    0 == command_result.exit_code
  end
  command_result
end