Skip to content

Fix vmware SmartConnect on pyvmomi 9 (#68211)#69430

Open
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68211
Open

Fix vmware SmartConnect on pyvmomi 9 (#68211)#69430
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68211

Conversation

@dwoz

@dwoz dwoz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Stops salt.utils.vmware._get_service_instance from passing the deprecated b64token/mechanism keyword arguments to pyVim.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 with user/pwd as documented.

What issues does this PR fix or reference?

Fixes #68211

Previous Behavior

On salt-cloud 3006.14 with pyvmomi==9.0.0.0 the reporter hit:

Failed to execute 'vmware.list_nodes()' while querying for running nodes: Could not connect to host '1.1.1.1'.
...
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/vmware.py", line 316, in _get_service_instance
    service_instance = SmartConnect(...)
File "/opt/saltstack/salt/extras-3.10/pyVim/connect.py", line 310, in Connect
    raise Exception(
Exception: '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'.

The documented workaround was downgrading to pyvmomi==8.

New Behavior

  • userpass mechanism: SmartConnect is called without b64token/mechanism and without token/tokenType - credentials flow through user/pwd.
  • sspi mechanism: the gssapi token is forwarded as token=<b64token>, tokenType="sspi", matching the pyvmomi 9 API.
  • Existing unit-test expectations updated to assert the new keyword arguments; three new regression tests cover the userpass (verify_ssl true and false) and sspi code paths.

Merge requirements satisfied?

  • Docs (no documented behavior change; this is a bug fix to internal connect handling)
  • Changelog (changelog/68211.fixed.md)
  • Tests written/updated (tests/pytests/unit/utils/test_vmware.py + updated assertions in tests/unit/utils/test_vmware.py)

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from a team as a code owner June 12, 2026 00:30
@dwoz dwoz added this to the Sulphur v3006.26 milestone Jun 12, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 12, 2026
@dwoz dwoz force-pushed the fix/issue-68211 branch from 2c7125c to d98fc8c Compare June 14, 2026 02:06
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant