diff --git a/README.md b/README.md index 254794b..4866ece 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,15 @@ from VDDK 8 NBD traffic; see `docs/`. ## Status -Implemented against vCenter 8 / ESXi 8. Default transport is `nbdssl` -(`nbd` is still available): +Supported and tested on **vCenter 8 / ESXi 8** (lab: 8.0.1). The +VixDiskLib compatibility mode is `8.0` only. VIM login requests +pyVmomi's vim25 **8.x** versions, so a newer host such as vSphere 9 stays +on 8.x SOAP instead of 9.x types. + +vSphere 9 is untested. vCenter / ESXi 7 and earlier are not supported at the +moment. + +Default transport is `nbdssl` (`nbd` is still available): - `VixDiskLib_ConnectEx` (UID credentials) - `VixDiskLib_Open` (datastore path, read-only or read-write) diff --git a/docs/nfc_auth.md b/docs/nfc_auth.md index e19b515..36e89ed 100644 --- a/docs/nfc_auth.md +++ b/docs/nfc_auth.md @@ -51,7 +51,9 @@ rather than crafting SOAP. - Endpoint: `https://:443/sdk` - Cookie: `vmware_soap_session` -- SOAPAction: `"urn:vim25/8.0.1.0"` (negotiated) +- SOAPAction: newest advertised 8.x (`SmartConnect` `preferredApiVersions` + is capped at `vim.version.v8_*` so a vSphere 9 host does not pick + pyVmomi 9 types). Lab vCenter 8.0.1 used `"urn:vim25/8.0.1.0"`. VDDK logs this as `Connected to VIM Server` / `Authenticating user` / `Logged in!`. OpenVixDiskLib keeps that `ServiceInstance` and diff --git a/openvixdisklib/nfc_auth.py b/openvixdisklib/nfc_auth.py index 49d85aa..d50744a 100644 --- a/openvixdisklib/nfc_auth.py +++ b/openvixdisklib/nfc_auth.py @@ -24,7 +24,12 @@ from pyVim.connect import Disconnect, SmartConnect from pyVmomi import vim -from pyVmomi.VmomiSupport import F_OPTIONAL, CreateManagedType, GetVmodlType +from pyVmomi.VmomiSupport import ( + F_OPTIONAL, + CreateManagedType, + GetServiceVersions, + GetVmodlType, +) NFC_SERVICE_MOID = "nfcService" AUTHD_DEFAULT_PORT = 902 @@ -132,6 +137,24 @@ def nfc_service(si: vim.ServiceInstance) -> vim.NfcService: return nfc_cls(NFC_SERVICE_MOID, si._stub) +def _vim_preferred_api_versions() -> list[str]: + """Return pyVmomi vim25 8.x versions, newest first. + + ``SmartConnect`` otherwise walks every version this pyVmomi knows, + including 9.x, so a vSphere 9 host would negotiate 9.x SOAP. NFC + was reverse-engineered on vSphere 8; keep that family so newer + hosts stay on an 8.x ``SOAPAction`` they still advertise. + """ + versions = [ + v for v in GetServiceVersions("vim25") if v.startswith("vim.version.v8_") + ] + if not versions: + raise RuntimeError( + "pyVmomi does not provide vim25 8.x types; OpenVixDiskLib requires them" + ) + return versions + + def connect_vim( host: str, username: str, @@ -171,6 +194,7 @@ def connect_vim( thumbprint=thumbprint, sslContext=ssl_context, disableSslCertValidation=skip_ca, + preferredApiVersions=_vim_preferred_api_versions(), )