mirror of
https://github.com/puppetlabs/vmpooler-provider-vsphere.git
synced 2026-01-26 03:18:41 -05:00
(maint) Use timeout builtin to TCPSocket when opening sockets.
This commit is contained in:
parent
87274a2d51
commit
713a4a2c9d
1 changed files with 7 additions and 9 deletions
|
|
@ -632,17 +632,15 @@ module Vmpooler
|
|||
|
||||
# This should supercede the open_socket method in the Pool Manager
|
||||
def open_socket(host, domain = nil, timeout = 5, port = 22, &_block)
|
||||
Timeout.timeout(timeout) do
|
||||
target_host = host
|
||||
target_host = "#{host}.#{domain}" if domain
|
||||
sock = TCPSocket.new target_host, port
|
||||
sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
|
||||
begin
|
||||
yield sock if block_given?
|
||||
ensure
|
||||
sock.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_vm_folder_path(vm_object)
|
||||
# This gives an array starting from the root Datacenters folder all the way to the VM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue