Skip to content

Commit c3cb2c1

Browse files
mihaelabalutoiuDany9966
authored andcommitted
Add VM inventory CSV endpoint to api-ref docs
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
1 parent 5244c01 commit c3cb2c1

4 files changed

Lines changed: 78 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vm_id,vm_name,firmware,num_cpu,memory_mb,nested_virtualization,dynamic_memory_enabled,secure_boot,os_type,guest_id,disks,nics,hostname,parent_vapp,host,power_state
2+
4cb7e5e1-d3c4-4b0a-8742-f2b1b3d9a1c2,web-server-01,efi,4,8192,False,True,False,linux,ubuntu64Guest,150GB,Network adapter 1|00:50:56:aa:bb:cc|VM Network|10.0.0.10,web-server-01,,esxi-host-01.example.com,poweredOn
3+
9fa23b11-7e2a-4c10-a3f8-0d1e2f3c4a5b,db-server-01,bios,8,16384,False,False,False,windows,windows9Server64Guest,300GB,Network adapter 1|00:50:56:aa:cc:dd|VM Network|10.0.0.20,db-server-01,db-vapp,esxi-host-02.example.com,poweredOn

coriolis/api-refs/source/endpoint.inc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,64 @@ Response
325325
.. literalinclude:: ../api_samples/endpoint/endpoint-instance-show-resp.json
326326
:language: javascript
327327

328+
Get Endpoint VM Inventory
329+
=========================
330+
331+
.. rest_method:: GET /endpoints/{endpoint_id}/inventory
332+
333+
Exports the full VM inventory of an endpoint in CSV format.
334+
335+
**Preconditions**
336+
337+
The endpoint must exist and the provider must support inventory export.
338+
339+
Normal response codes: 200
340+
341+
Error response codes: unauthorized(401), forbidden(403),
342+
itemNotFound(404)
343+
344+
Request
345+
-------
346+
347+
.. rest_parameters:: parameters.yaml
348+
349+
- endpoint_id : endpoint_id_path
350+
- env : inventory_source_env
351+
352+
Response
353+
--------
354+
355+
The response body is a UTF-8 encoded CSV file with various columns returned.
356+
Each provider may return more specific fields (i.e. parentVapp when using VMWare).
357+
The example below shows the values returned by the VMWare provider.
358+
359+
- **vm_id** – Unique identifier (UUID) of the VM.
360+
- **vm_name** – Display name of the VM.
361+
- **guest_id** – Raw VMware guest OS identifier (e.g. ``ubuntu64Guest``).
362+
- **firmware** – Firmware type (``bios`` or ``efi``).
363+
- **num_cpu** – Number of vCPUs.
364+
- **memory_mb** – Memory in megabytes.
365+
- **nested_virtualization** – Whether nested virtualisation is enabled.
366+
- **dynamic_memory_enabled** – Whether dynamic memory is enabled.
367+
- **secure_boot** – Whether EFI Secure Boot is enabled.
368+
- **os_type** – Coriolis-normalised OS type (e.g. ``linux``, ``windows``).
369+
- **disks** – Total provisioned disk size for the VM (e.g. ``150GB``).
370+
- **nics** – Semicolon-separated list of NIC entries, each formatted as
371+
``label|mac[|network[|ip1,ip2,...]]``.
372+
- **hostname** – Guest hostname as reported by VMware Tools (empty if tools
373+
are not running).
374+
- **parent_vapp** – Name of the parent vApp, if any.
375+
- **host** – ESXi host the VM is currently running on.
376+
- **power_state** – Current power state (e.g. ``poweredOn``, ``poweredOff``).
377+
378+
The response is returned with ``Content-Type: text/csv`` and a
379+
``Content-Disposition: attachment`` header suggesting a filename of the form
380+
``vm_inventory_{endpoint_id}.csv``.
381+
382+
**Example VM Inventory CSV Response**
383+
384+
.. literalinclude:: ../api_samples/endpoint/endpoint-inventory-resp.csv
385+
328386
Get Endpoint Destination Options
329387
================================
330388

coriolis/api-refs/source/parameters.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ instance_refresh:
9696
required: false
9797
type: boolean
9898
default: false
99+
inventory_source_env:
100+
description: |
101+
Optional base64-encoded JSON object containing source environment options
102+
for the inventory export When omitted, the provider's defaults are used.
103+
in: query
104+
required: false
105+
type: string
99106
show_deleted:
100107
description: |
101108
Whether to include deleted resources in the response.

coriolis/providers/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,16 @@ def export_instance_inventory(
14001400
self, ctxt, connection_info, source_environment):
14011401
"""Export the full VM inventory as a CSV-formatted string.
14021402
1403-
Returns a standards-compliant CSV string with a header row and one
1404-
row per VM, sorted deterministically by VM ID.
1403+
:param ctxt: Coriolis request context
1404+
:param connection_info: endpoint connection parameters
1405+
:param source_environment: provider-specific source environment
1406+
parameters
1407+
1408+
:returns: a standards-compliant CSV string with a header row and one
1409+
row per VM, sorted deterministically by VM ID. Each row
1410+
contains fields such as VM ID, VM name, guest OS, firmware
1411+
type, number of CPUs, memory (MB), total disk size (GB),
1412+
disk details, and network interface details.
14051413
"""
14061414
raise NotImplementedError()
14071415

0 commit comments

Comments
 (0)