Fix vmware SmartConnect on pyvmomi 9 (#68211)#69430
Open
dwoz wants to merge 1 commit into
Open
Conversation
pyvmomi 9 removed the deprecated b64token and mechanism keyword
arguments from SmartConnect/Connect and now raises an Exception as
soon as either argument is truthy. _get_service_instance unconditionally
forwarded both, so every connection attempt - salt-cloud, the vsphere
execution module, the vsan and pbm utilities - failed with:
'b64token' and 'mechanism' are no longer supported. The default
connection type uses credentials. If you want to authenticate with a
token, set 'token' and 'tokenType'.
Switch to the supported token/tokenType keywords (present since
pyvmomi 8), and only forward them when a token is actually present.
For the default userpass mechanism we now pass no token argument at
all and credentials flow through user/pwd as documented.
Fixes saltstack#68211
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Stops
salt.utils.vmware._get_service_instancefrom passing the deprecatedb64token/mechanismkeyword arguments topyVim.connect.SmartConnect. pyvmomi 9 raises an exception as soon as either argument is truthy, so on Salt 3006.14 with pyvmomi 9 every VMware connection - salt-cloud, the vsphere execution module, the vsan/pbm utilities - failed at connect time.The fix forwards
token/tokenType(the supported replacement keywords, present since pyvmomi 8) only when a token is actually present. The default userpass flow now passes nothing token-related and lets pyvmomi log in withuser/pwdas documented.What issues does this PR fix or reference?
Fixes #68211
Previous Behavior
On salt-cloud 3006.14 with
pyvmomi==9.0.0.0the reporter hit:The documented workaround was downgrading to
pyvmomi==8.New Behavior
userpassmechanism:SmartConnectis called withoutb64token/mechanismand withouttoken/tokenType- credentials flow throughuser/pwd.sspimechanism: the gssapi token is forwarded astoken=<b64token>, tokenType="sspi", matching the pyvmomi 9 API.Merge requirements satisfied?
changelog/68211.fixed.md)tests/pytests/unit/utils/test_vmware.py+ updated assertions intests/unit/utils/test_vmware.py)Commits signed with GPG?
Yes