Initial commit: VMware vSphere API simulator scaffold.
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
**Language / Язык:** [English](vm.md) | [Русский](../ru/domains/vm.md)
|
||||
|
||||
# Virtual machines
|
||||
|
||||
Full REST lifecycle for `VirtualMachine` objects:
|
||||
[`app/vsphere/rest/router.py`](../../app/vsphere/rest/router.py),
|
||||
[`vm_ext.py`](../../app/vsphere/rest/vm_ext.py),
|
||||
[`app/vsphere/domain/vm_ops.py`](../../app/vsphere/domain/vm_ops.py).
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Method | Path | Notes |
|
||||
|---|---|---|
|
||||
| GET | `/api/vcenter/vm` | List with `names`/`power_states`/`hosts`/`folders`/`datacenters`/`clusters`/`resource_pools`/`limit`/`cursor` filters |
|
||||
| GET/DELETE | `/api/vcenter/vm/{vm}` | Get / delete (must be powered off) |
|
||||
| POST | `/api/vcenter/vm` | Create — `placement.{folder,host,datastore,resource_pool}`, `cpu.count`, `memory.size_MiB`, `disks`, `nics` |
|
||||
| GET/POST | `/api/vcenter/vm/{vm}/power` | Get power state / `?action=start\|stop\|suspend\|reset` — returns `{ "task": "task-…" }` |
|
||||
| GET | `/api/vcenter/vm/{vm}/hardware` | Summary |
|
||||
| GET/PATCH | `/api/vcenter/vm/{vm}/hardware/cpu` \| `/memory` | Change CPU count / memory (privilege-gated) |
|
||||
| GET/POST | `/api/vcenter/vm/{vm}/hardware/disk` \| `/ethernet` | Add disk / NIC |
|
||||
| GET | `/api/vcenter/vm/{vm}/hardware/boot` | Boot type/order |
|
||||
| GET/POST/DELETE | `/api/vcenter/vm/{vm}/snapshots[/{snapshot}]` | Create, revert (`?action=revert`), delete |
|
||||
| POST | `/api/vcenter/vm/{vm}/clone` \| `/relocate` | Task-returning |
|
||||
| GET/POST | `/api/vcenter/vm/{vm}/tools` | Guest tools status / upgrade |
|
||||
| GET | `/api/vcenter/vm/{vm}/guest/identity` \| `/networking` | Guest OS name, synthetic IP |
|
||||
| GET/POST | `/api/vcenter/vm/{vm}/guest/power` | Guest-level power ops |
|
||||
| POST | `/api/vcenter/vm/{vm}/guest/customization` | Sysprep/cloud-init-style customization spec |
|
||||
| POST | `/api/vcenter/vm/{vm}/console/tickets` | Console (VNC/WebMKS-style) ticket |
|
||||
| GET/PUT/DELETE | `/api/vcenter/vm/{vm}/guest/filesystem` | Lab virtual guest filesystem (Ansible/Terraform write-a-file flows) |
|
||||
| GET | `/api/vcenter/vm/{vm}/guest/filesystem/files` \| `/guest/local-filesystem` | Listing |
|
||||
|
||||
## Highlights
|
||||
|
||||
- Every VM row carries a realistic device shape: `nics`, `disks`, `cdroms`,
|
||||
`floppies`, `serials`, `scsi_adapters`, `boot`/`boot_devices`, `identity`
|
||||
(`instance_uuid`, `bios_uuid`), and a synthetic `guest_ip` /
|
||||
`guest_filesystems` map — the same fields power both the REST hardware
|
||||
endpoints and SOAP `VirtualMachineConfigInfo`.
|
||||
- Create requires `VirtualMachine.Inventory.Create`; delete requires
|
||||
`VirtualMachine.Inventory.Delete` **and** the VM must be `POWERED_OFF`.
|
||||
- Power/clone/snapshot/relocate/customize all create a durable CIS task (see
|
||||
[Tasks](tasks.md)) rather than mutating synchronously in the response body.
|
||||
- Console tickets from `/api/vcenter/vm/{vm}/console/tickets` persist in
|
||||
`vsphere_console_tickets` (migration `013`).
|
||||
- MOIDs follow the `vm-{100+n}` convention seeded by
|
||||
[`app/vsphere/profiles.py`](../../app/vsphere/profiles.py).
|
||||
|
||||
See [Storage](storage.md) for datastore/disk-file semantics and
|
||||
[SOAP / VIM](soap.md) for the equivalent `CreateVM_Task`/`PowerOnVM_Task`/…
|
||||
operations used by pyvmomi, govmomi, Terraform, and Pulumi.
|
||||
Reference in New Issue
Block a user