Added execution_time_limit for WinRM.

Adds a configurable value for WinRm and the elevated permission shell ExecutionTimeLimit.

Please see mitchellh/vagrant#5506

Ex: config.winrm.execution_time_limit = "P1D"
This commit is contained in:
Jeremy Roberts 2015-08-30 13:09:25 -04:00
parent f3b31c8c9c
commit 18d229ca82
4 changed files with 11 additions and 3 deletions

View File

@ -210,7 +210,8 @@ module VagrantPlugins
"powershell -executionpolicy bypass -file \"#{guest_script_path}\" " +
"-username \"#{shell.username}\" -password \"#{shell.password}\" " +
"-encoded_command \"#{wrapped_encoded_command}\""
"-encoded_command \"#{wrapped_encoded_command}\" " +
"-execution_time_limit \"#{shell.execution_time_limit}\""
end
# Handles the raw WinRM shell result and converts it to a

View File

@ -11,6 +11,7 @@ module VagrantPlugins
attr_accessor :timeout
attr_accessor :transport
attr_accessor :ssl_peer_verification
attr_accessor :execution_time_limit
def initialize
@username = UNSET_VALUE
@ -23,6 +24,7 @@ module VagrantPlugins
@timeout = UNSET_VALUE
@transport = UNSET_VALUE
@ssl_peer_verification = UNSET_VALUE
@execution_time_limit = UNSET_VALUE
end
def finalize!
@ -37,6 +39,7 @@ module VagrantPlugins
@retry_delay = 2 if @retry_delay == UNSET_VALUE
@timeout = 1800 if @timeout == UNSET_VALUE
@ssl_peer_verification = true if @ssl_peer_verification == UNSET_VALUE
@execution_time_limit = "PT2H" if @execution_time_limit == UNSET_VALUE
end
def validate(machine)
@ -49,6 +52,7 @@ module VagrantPlugins
errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
errors << "winrm.retry_delay cannot be nil." if @max_tries.nil?
errors << "winrm.timeout cannot be nil." if @timeout.nil?
errors << "winrm.execution_time_limit cannot be nil." if @execution_time_limit.nil?
unless @ssl_peer_verification == true || @ssl_peer_verification == false
errors << "winrm.ssl_peer_verification must be a boolean."
end

View File

@ -1,4 +1,4 @@
param([String]$username, [String]$password, [String]$encoded_command)
param([String]$username, [String]$password, [String]$encoded_command, [String]$execution_time_limit)
$task_name = "WinRM_Elevated_Shell"
$out_file = "$env:SystemRoot\Temp\WinRM_Elevated_Shell.log"
@ -33,7 +33,7 @@ $task_xml = @'
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
<ExecutionTimeLimit>{execution_time_limit}</ExecutionTimeLimit>
<Priority>4</Priority>
</Settings>
<Actions Context="Author">
@ -49,6 +49,7 @@ $arguments = "/c powershell.exe -EncodedCommand $encoded_command &gt; $out_file
$task_xml = $task_xml.Replace("{arguments}", $arguments)
$task_xml = $task_xml.Replace("{username}", $username)
$task_xml = $task_xml.Replace("{execution_time_limit}", $execution_time_limit)
$schedule = New-Object -ComObject "Schedule.Service"
$schedule.Connect()

View File

@ -37,6 +37,7 @@ module VagrantPlugins
attr_reader :port
attr_reader :username
attr_reader :password
attr_reader :execution_time_limit
attr_reader :config
def initialize(host, port, config)
@ -47,6 +48,7 @@ module VagrantPlugins
@port = port
@username = config.username
@password = config.password
@execution_time_limit = config.execution_time_limit
@config = config
end