Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion docs/nfc_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ rather than crafting SOAP.

- Endpoint: `https://<vcenter>: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
Expand Down
26 changes: 25 additions & 1 deletion openvixdisklib/nfc_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -171,6 +194,7 @@ def connect_vim(
thumbprint=thumbprint,
sslContext=ssl_context,
disableSslCertValidation=skip_ca,
preferredApiVersions=_vim_preferred_api_versions(),
)


Expand Down
Loading