Sign inSign up

credkellar/cloudbase-re

By credkellar

โ€ขUpdated about 2 hours ago

CloudBase-RE: clean-room Python take on VMware VDDK - VMDK parsing, NFC/NBD streaming, safe lab use!

Image
Networking
Developer tools
Databases & storage
1

70

credkellar/cloudbase-re repository overview

โ ๐Ÿ’ฝ CloudBase-RE

๐Ÿณ Docker Hub status: image credkellar/cloudbase-re:latest โ€” the Hub page is created by the first Docker Publish run, which fires after the two workflow files are pasted into .github/workflows/ and the per-repo DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets are set on the GitHub repo. Source of truth: https://github.com/credkellar/CloudBase-REโ  (verified head 76478069, CHECKS 12/12, pytest 11 passed).

Python 3.11+ Protocol NBD + NFC model VMware VMDK descriptors Dependencies Zero stdlib Tests 11 passed Demo Checks 12/12 HOLD Gates 10 License MIT Docker python:3.12-slim pyVmomi Optional seat Gemini Carbon 4 DECIDER Meta Muse advisor

CI Docker Publish

โณ Honest workflow status: the real ci.yml + docker-publish.yml badges light up once the two workflow files are pasted into .github/workflows/ (plural) and run โ€” until then these show pending paste on purpose. The workflow files themselves are delivered with this project and are standard GitHub Actions (pytest + demo on Python 3.12; Docker Hub publish of credkellar/cloudbase-re:latest on push to main).

โ ๐Ÿงญ What is this about?

CloudBase-RE is an independent, open-source Python implementation of the OpenVixDiskLib concept, built to study and replicate the functionality of VMware's proprietary libvixDiskLib (VDDK / Virtual Disk Development Kit) - the library backup and migration tools use to read and write VMware virtual disks (.vmdk). The core challenge it takes on: interfacing with VMware vSphere/ESXi virtual disk formats and the low-level Network File Copy (NFC) and Network Block Device (NBD) protocols without closed-source SDK binaries or partner-portal downloads.

This build is a clean-room lab implementation: real VMDK descriptor parsing, a real NBD protocol codec (NBD is a public, documented protocol), a modelled NFC greeting/auth handshake, and a loopback lab fixture that stands in for an ESXi port-902 service - so the whole connect โ†’ open โ†’ read/write path runs and is tested locally, with synthetic disks only. Live connection to a real ESXi/vCenter stays behind HOLD gates.

โ ๐Ÿ› ๏ธ What this does

  • ๐Ÿ”Œ Emulates VDDK interfaces - VixDiskLibHandle exposes connect / open / read / write / get_info with sector addressing, mirroring the native SDK's shape (openvixdisklib/handles.py)
  • ๐Ÿ’ฝ Parses real VMDK descriptors - extents (RW SPARSE/FLAT), CID/parentCID, createType, DDB geometry + adapter, sector totals and capacity (vmdk.py), and creates synthetic lab disks (descriptor + zeroed flat extent)
  • ๐ŸŒ Streams blocks over NBD - the public NBD handshake + the real 28-byte request / reply structs, implemented from the spec (nbd.py)
  • ๐Ÿค Models the NFC handshake - greeting + ticket-auth framing codec (magic, version, opcode, length-prefixed payloads) as described in the study doc (nfc.py)
  • ๐ŸŽซ Models session + NFC tickets - vCenter-style login โ†’ session token โ†’ NFC lease ticket (host, port 902, datastore path, expiry), fully offline (session.py)
  • ๐Ÿ“ก Runs a loopback lab fixture - an NBD server on 127.0.0.1 serving a synthetic disk, so writes and reads are exercised end-to-end with zero infrastructure
  • ๐Ÿ—œ๏ธ Compression adapter seat - the interface a FastLZ adapter would expose, backed by an honest educational LZ77 codec (not byte-compatible FastLZ) (compression.py)
  • โ— Readable errors - Python exceptions with plain-English messages replace cryptic hex SDK codes (errors.py)
  • ๐Ÿง  Council seats - Gemini Carbon 4 Extended Thinking (DECIDER) + Muse (advisor, exactly 4 advice, never overrides) (council.py)
  • ๐Ÿ“š Full study catalogue - all 20 problems and 20 reasons from the Gemini study doc live in problems.py as data (the top 10 of each are in the sections below)

โ โš™๏ธ How this works

  1. ๐ŸŽซ Inventory & session login - (modelled) authenticate against vCenter/ESXi via standard SOAP-style login (pyVmomi is the real-world library; here it is an offline model) and receive a session token + NFC ticket.
  2. ๐Ÿค Socket handshake - open a connection to the ESXi host port 902 service: NFC greeting + ticket authentication frames negotiate the disk lease.
  3. ๐Ÿ’ฝ Disk sector operations - precise read/write block commands target the .vmdk extents on the datastore - in this build, the loopback fixture's synthetic disk, through the real NBD request/reply structs.
  4. ๐Ÿ—œ๏ธ Stream processing & decompression - incoming payload frames are parsed and decompressed through the adapter interface before raw sector data returns to the caller.

โ ๐ŸŽฏ Who is this for?

  • โ˜๏ธ Cloud & DevOps engineers - automating migrations from VMware to OpenStack, KVM, or public clouds
  • ๐Ÿ’พ Backup & disaster-recovery builders - lightweight pipelines that read/write VMDK blocks without bulky vendor SDKs
  • ๐Ÿ” Infrastructure security auditors & researchers - studying proprietary virtualization protocols via clean-room implementation

โ ๐Ÿ˜Ž Why is this cool?

  1. Clean-room engineering triumph - complex enterprise protocols rebuilt from scratch.
  2. AI-assisted protocol dissection - packet analysis + byte-struct decoding as a study method.
  3. Bypassing monopolistic SDKs - challenges gated partner portals on infrastructure interoperability.
  4. Transparent binary protocols - black-box communication turned into readable Python.
  5. Direct socket mastery - raw TCP on port 902 with hypervisor auth services.
  6. Bridge between high- and low-level - pyVmomi inventory management meets byte manipulation.
  7. Rapid modernization - legacy enterprise architecture adapted to agile workflows.
  8. Protocol agility - fork, tweak, and optimize behaviour without waiting on vendor updates.
  9. Educational goldmine - a masterclass in packet capture, frame parsing, reverse engineering.
  10. Open-source resilience - an ecosystem independent of abrupt vendor policy shifts.

โ ๐Ÿงฉ What problems this solves?

  1. Vendor SDK dependency lock-in - removes the strict requirement to download official restricted VDDK binaries - clean-room Python instead.
  2. Partner portal bottlenecks - no blocked/restricted portal download stands between a backup tool and its disk library.
  3. Heavy C/C++ binary bloat - a lightweight Python implementation replaces rigid compiled C libraries.
  4. Complex cross-compilation hurdles - no platform-specific C headers or .so/.dll juggling.
  5. Cross-platform compatibility gaps - interfaces with VMware storage backends from non-traditional environments.
  6. Integration friction with Python tooling - Python backup scripts bridge directly to low-level ESXi disk streams.
  7. License compliance friction - a clean-room implementation gives open-source developers a transparent alternative.
  8. Opaque protocol black boxes - open reverse engineering demystifies undocumented network block handshakes.
  9. CI/CD pipeline restrictions - no proprietary SDK files in pipelines and no cumbersome proxy appliances.
  10. Datastore access inefficiencies - streamlined reading and writing of .vmdk files.

๐Ÿ“š The full catalogue - all 20 problems and all 20 reasons from the study doc - is in openvixdisklib/problems.py.

โ ๐Ÿ“ฆ How to install this โ€” step-by-step

โ Option A โ€” run it locally
  1. ๐Ÿ“ฅ Clone the repo:
    git clone https://github.com/credkellar/CloudBase-RE.git
    cd CloudBase-RE
    
  2. โ–ถ๏ธ Run the end-to-end demo (synthetic disk, session, NFC model, NBD fixture, verified sector write/read):
    python3 main.py demo
    
    Expected tail: CHECKS: 12/12
  3. ๐Ÿงช Run the tests:
    pip install pytest
    python3 -m pytest -q
    
    Expected: 11 passed
โ Option B โ€” Docker
  1. ๐Ÿณ Build: docker build -t credkellar/cloudbase-re:latest .
  2. โ–ถ๏ธ Run: docker run --rm credkellar/cloudbase-re:latest
  3. ๐Ÿงฉ Or Compose: docker compose up --build

โ ๐Ÿ“‹ Requirements

  • ๐Ÿ Python 3.11+ - zero third-party dependencies (standard library only)
  • ๐Ÿงช pytest - only for running the test suite
  • ๐Ÿณ Docker - optional, for Option B
  • ๐Ÿ”‘ Optional seats, names only: GEMINI_API_KEY (Carbon 4) and MODEL_API_KEY (Muse, paid: key creation free, usage pay-as-you-go) light up the council seats; VCENTER_USER/VCENTER_PASSWORD are env names only in this build - values are never read
  • ๐Ÿšซ No VMware SDK, no vCenter, and no ESXi host are required - or contacted - by this build

โ ๐Ÿง’ Explain in 5th grade English

Imagine a computer inside a computer - that is a virtual machine. Its whole hard drive is saved as one big file, like saving an entire LEGO castle as a single box. Big companies sell a special key that lets programs open the box and read the pieces. That key is hard to get. This project is like a kid who studied how the box opens and built his own key out of regular parts, in the open, so anyone can learn from it. Talking to the box uses a secret handshake language over the network; this project writes that handshake down in plain Python anyone can read. But safety first: the key is only ever tried on toy boxes we made ourselves - never on anyone's real castle.

โ ๐Ÿ—‚๏ธ Project structure

CloudBase-RE/
โ”œโ”€โ”€ main.py                        โ–ถ๏ธ demo + CHECKS (12/12)
โ”œโ”€โ”€ openvixdisklib/
โ”‚   โ”œโ”€โ”€ __init__.py                ๐Ÿ“ฆ version
โ”‚   โ”œโ”€โ”€ vmdk.py                    ๐Ÿ’ฝ descriptor parser + synthetic disk creator
โ”‚   โ”œโ”€โ”€ session.py                 ๐ŸŽซ vCenter session + NFC ticket model (offline)
โ”‚   โ”œโ”€โ”€ nfc.py                     ๐Ÿค NFC greeting/auth framing codec (model)
โ”‚   โ”œโ”€โ”€ nbd.py                     ๐ŸŒ NBD codec + loopback lab fixture server/client
โ”‚   โ”œโ”€โ”€ handles.py                 ๐Ÿ”Œ VixDiskLibHandle API (connect/open/read/write)
โ”‚   โ”œโ”€โ”€ compression.py             ๐Ÿ—œ๏ธ LZ77 adapter (FastLZ-interface seat)
โ”‚   โ”œโ”€โ”€ errors.py                  โ— readable VixError hierarchy
โ”‚   โ”œโ”€โ”€ council.py                 ๐Ÿง  Carbon 4 DECIDER + Muse advisor
โ”‚   โ”œโ”€โ”€ gates.py                   โ›” 10 HOLD gates
โ”‚   โ””โ”€โ”€ problems.py                ๐Ÿ“š 20 problems + 20 reasons (study doc)
โ”œโ”€โ”€ tests/test_openvixdisklib.py   ๐Ÿงช pytest (11 passed)
โ”œโ”€โ”€ Dockerfile                     ๐Ÿณ python:3.12-slim
โ”œโ”€โ”€ docker-compose.yml             ๐Ÿงฉ one service
โ”œโ”€โ”€ pyproject.toml                 ๐Ÿ“ฆ package metadata
โ””โ”€โ”€ README.md                      ๐Ÿ“– this file

โ ๐Ÿ“Š Diagrams โ€” one per script

โ ๐Ÿ“œ main.py
flowchart TD
    A[python main.py demo] --> B[create synthetic VMDK]
    B --> C[parse descriptor]
    C --> D[session login + NFC ticket]
    D --> E[NFC handshake model]
    E --> F[NBD fixture stream write/read]
    F --> G[compression adapter round-trip]
    G --> H[council + gates + CHECKS 12/12]
โ ๐Ÿ“œ openvixdisklib/vmdk.py
flowchart LR
    A[create_synthetic_disk] --> B[descriptor text + flat extent]
    C[descriptor text] --> D[parse_descriptor]
    D --> E[extents + DDB + sector totals]
โ ๐Ÿ“œ openvixdisklib/session.py
flowchart TD
    A[login host + user] --> B[session token hash]
    B --> C[nfc_ticket: host port 902 + path + expiry]
    C --> D[ticket feeds the NFC auth frame]
โ ๐Ÿ“œ openvixdisklib/nfc.py
flowchart LR
    A[opcode + payload] --> B[encode_frame: NFC1 magic + version]
    B --> C[decode_frame validates magic]
    C --> D[greet / auth / open-disk ops]
โ ๐Ÿ“œ openvixdisklib/nbd.py
flowchart TD
    A[LabBlockServer on 127.0.0.1] --> B[NBDMAGIC greeting + export size]
    B --> C[NbdClient connect]
    C --> D{request: READ / WRITE / DISC}
    D --> E[reply magic + error + data]
โ ๐Ÿ“œ openvixdisklib/handles.py
flowchart TD
    A[VixDiskLibHandle.connect] --> B[open descriptor]
    B --> C{transport}
    C -->|fixture| D[NFC model + NBD client]
    C -->|file| E[local flat extent file]
    D --> F[read / write sectors with bounds checks]
    E --> F
โ ๐Ÿ“œ openvixdisklib/compression.py
flowchart LR
    A[sector bytes] --> B[compress: literal / match tokens]
    B --> C[decompress]
    C --> D[identical bytes back]
โ ๐Ÿ“œ openvixdisklib/errors.py
flowchart TD
    A[legacy hex-style code] --> B[VixError]
    B --> C[plain-English message + named subclass]
    C --> D[NotConnected / InvalidSector / Auth]
โ ๐Ÿ“œ openvixdisklib/council.py
flowchart TD
    A[Carbon 4 DECIDER: MAP-MODEL-STRESS-DECIDE] --> B{decision}
    C[Muse advisor: exactly 4 advice] --> B
    B --> D[tighten-only on HOLD gates]
โ ๐Ÿ“œ openvixdisklib/gates.py
flowchart TD
    A[10 HOLD gates] --> B[no live ESXi / no credentials / loopback only]
    B --> C[every module stays inside lab scope]
โ ๐Ÿ“œ openvixdisklib/problems.py
flowchart LR
    A[study doc catalogue] --> B[20 PROBLEMS with solutions]
    A --> C[20 REASONS it matters]
    B --> D[README top-10 sections draw from here]

โ โ›” HOLD gates (10)

  1. ๐Ÿšซ No live ESXi/vCenter connection - the only peer is the loopback lab fixture (127.0.0.1); dialing a real host on port 902 is not implemented
  2. ๐Ÿ”‘ No credential values - VCENTER_USER / VCENTER_PASSWORD are env NAMES only; values never read, stored, logged, or sent
  3. ๐Ÿ’ฝ No writes to a real datastore - sector writes land only on synthetic lab disks
  4. ๐Ÿงผ Clean-room study only - behaviour modelled from the study doc + the public NBD spec; no VMware code or binaries included
  5. โš–๏ธ No SDK-bypass for production - educational/interop research artifact, not a production backup tool or licensing workaround
  6. ๐Ÿ—œ๏ธ Compression honesty - the LZ77 adapter is NOT byte-compatible FastLZ; never feed it real FastLZ streams
  7. ๐ŸŽซ No pyVmomi live session - session + NFC ticket are offline models
  8. ๐Ÿ  Loopback only - the fixture binds 127.0.0.1, ephemeral port, exactly one connection
  9. ๐Ÿงช Synthetic disks only - never point the file transport at a production .vmdk
  10. โ— Errors stay readable - no raw hex codes surface to users

โ โœ… Verification

$ python3 main.py demo
disk: 1 MiB, 2048 sectors ... session ticket -> port 902 ... NBD write/read identical
CHECKS: 12/12
$ python3 -m pytest -q
11 passed

โ ๐Ÿ“„ License

MIT


Built from Darion's Gemini study doc on Cloudbase/OpenVixDiskLib - clean-room, lab-first, honest scope: the NBD codec and VMDK parser are real, the NFC handshake and vCenter session are models, the peer is a loopback fixture, and no real hypervisor is ever contacted by this build. ๐Ÿ’ฝ

Tag summary

Content type

Image

Digest

sha256:10f3394cbโ€ฆ

Size

44.5 MB

Last updated

about 2 hours ago

docker pull credkellar/cloudbase-re