f8d3cbdd59
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.
51 lines
3.5 KiB
Markdown
51 lines
3.5 KiB
Markdown
**Language / Язык:** [English](../../domains/vm.md) | [Русский](vm.md)
|
|
|
|
# Виртуальные машины
|
|
|
|
Полный REST lifecycle для объектов `VirtualMachine`:
|
|
[`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).
|
|
|
|
## Эндпоинты
|
|
|
|
| Метод | Путь | Заметки |
|
|
|---|---|---|
|
|
| GET | `/api/vcenter/vm` | Список с фильтрами `names`/`power_states`/`hosts`/`folders`/`datacenters`/`clusters`/`resource_pools`/`limit`/`cursor` |
|
|
| GET/DELETE | `/api/vcenter/vm/{vm}` | Get / delete (должна быть 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` — возвращает `{ "task": "task-…" }` |
|
|
| GET | `/api/vcenter/vm/{vm}/hardware` | Сводка |
|
|
| GET/PATCH | `/api/vcenter/vm/{vm}/hardware/cpu` \| `/memory` | Смена CPU count / memory (privilege-gated) |
|
|
| GET/POST | `/api/vcenter/vm/{vm}/hardware/disk` \| `/ethernet` | Добавить 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` | Возвращают задачу |
|
|
| GET/POST | `/api/vcenter/vm/{vm}/tools` | Статус guest tools / upgrade |
|
|
| GET | `/api/vcenter/vm/{vm}/guest/identity` \| `/networking` | Имя guest OS, синтетический IP |
|
|
| GET/POST | `/api/vcenter/vm/{vm}/guest/power` | Guest-level power ops |
|
|
| POST | `/api/vcenter/vm/{vm}/guest/customization` | Спека customization в стиле sysprep/cloud-init |
|
|
| POST | `/api/vcenter/vm/{vm}/console/tickets` | Console-тикет (стиль VNC/WebMKS) |
|
|
| GET/PUT/DELETE | `/api/vcenter/vm/{vm}/guest/filesystem` | Lab virtual guest filesystem (потоки write-a-file Ansible/Terraform) |
|
|
| GET | `/api/vcenter/vm/{vm}/guest/filesystem/files` \| `/guest/local-filesystem` | Listing |
|
|
|
|
## Основные моменты
|
|
|
|
- У каждой строки VM реалистичная форма устройств: `nics`, `disks`, `cdroms`,
|
|
`floppies`, `serials`, `scsi_adapters`, `boot`/`boot_devices`, `identity`
|
|
(`instance_uuid`, `bios_uuid`) и синтетическая карта `guest_ip` /
|
|
`guest_filesystems` — те же поля питают и REST hardware-эндпоинты, и SOAP
|
|
`VirtualMachineConfigInfo`.
|
|
- Create требует `VirtualMachine.Inventory.Create`; delete требует
|
|
`VirtualMachine.Inventory.Delete` **и** VM должна быть `POWERED_OFF`.
|
|
- Power/clone/snapshot/relocate/customize создают устойчивую CIS-задачу (см.
|
|
[Tasks](tasks.md)), а не мутируют синхронно в теле ответа.
|
|
- Console tickets из `/api/vcenter/vm/{vm}/console/tickets` живут в
|
|
`vsphere_console_tickets` (миграция `013`).
|
|
- MOID следуют конвенции `vm-{100+n}`, засеваемой
|
|
[`app/vsphere/profiles.py`](../../../app/vsphere/profiles.py).
|
|
|
|
Семантика datastore/disk-file — [Storage](storage.md); эквивалентные
|
|
операции `CreateVM_Task`/`PowerOnVM_Task`/… для pyvmomi, govmomi, Terraform и
|
|
Pulumi — [SOAP / VIM](soap.md).
|