Skip to content

Commit

Permalink
Merge pull request #47167 from smitty42/vbox-skd-fix
Browse files Browse the repository at this point in the history
Adding updates for python3 compatibility and new virtualbox SDK versi…
  • Loading branch information
Nicole Thomas committed Apr 23, 2018
2 parents 976f031 + 5de5313 commit 9825065
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion salt/utils/virtualbox.py
Expand Up @@ -132,6 +132,12 @@ def vb_get_manager():
'''
global _virtualboxManager
if _virtualboxManager is None and HAS_LIBS:
try:
from importlib import reload
except ImportError:
# If we get here, we are in py2 and reload is a built-in.
pass

# Reloading the API extends sys.paths for subprocesses of multiprocessing, since they seem to share contexts
reload(vboxapi)
_virtualboxManager = vboxapi.VirtualBoxManager(None, None)
Expand All @@ -146,7 +152,13 @@ def vb_get_box():
@rtype: IVirtualBox
'''
vb_get_manager()
vbox = _virtualboxManager.vbox

try:
# This works in older versions of the SDK, but does not seem to work anymore.
vbox = _virtualboxManager.vbox
except AttributeError:
vbox = _virtualboxManager.getVirtualBox()

return vbox


Expand Down

0 comments on commit 9825065

Please sign in to comment.