mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
use already created vsphere connection
If we have connected to this host before, just reconnect. If the host is different than what is in the already configured connection, make sure we are disconnected, and connect to the new one. Fixes #31776 There is still a memory leak in this somewhere.
This commit is contained in:
parent
26ff46dbc6
commit
070eaf07f0
1 changed files with 8 additions and 1 deletions
|
@ -86,7 +86,7 @@ import salt.utils
|
|||
|
||||
# Import Third Party Libs
|
||||
try:
|
||||
from pyVim.connect import SmartConnect, Disconnect
|
||||
from pyVim.connect import GetSi, SmartConnect, Disconnect
|
||||
from pyVmomi import vim, vmodl
|
||||
HAS_PYVMOMI = True
|
||||
except ImportError:
|
||||
|
@ -184,6 +184,13 @@ def get_service_instance(host, username, password, protocol=None, port=None):
|
|||
if port is None:
|
||||
port = 443
|
||||
|
||||
service_instance = GetSi()
|
||||
if service_instance:
|
||||
if service_instance._GetStub().host == ':'.join([host, str(port)]):
|
||||
service_instance._GetStub().GetConnection()
|
||||
return service_instance
|
||||
Disconnect(service_instance)
|
||||
|
||||
try:
|
||||
service_instance = SmartConnect(
|
||||
host=host,
|
||||
|
|
Loading…
Add table
Reference in a new issue