vim_vm_devices¶
Niche VM virtual-device CRUD: vTPM, vGPU, serial port, video card, USB controllers.
Uses the same device-spec idiom as vim_vm_disk and vim_vm_nic:
build a vim.vm.device.Virtual* device, wrap in a
VirtualDeviceConfigSpec with operation="add|remove|edit", and call
vm.ReconfigVM_Task.
- saltext.vcf.clients.vim_vm_devices.tpm_add(opts, vm_id_or_name, profile=None)[source]¶
Attach a vTPM 2.0 device. VM must be powered off.
- saltext.vcf.clients.vim_vm_devices.vgpu_add(opts, vm_id_or_name, profile_name, profile=None)[source]¶
Attach a vGPU (NVIDIA vGRID) device. Requires host with vGPU-capable card.
profile_name — vGPU profile string, e.g.
grid_a100d-8c.
- saltext.vcf.clients.vim_vm_devices.vgpu_remove(opts, vm_id_or_name, profile_name=None, profile=None)[source]¶
Detach a vGPU. If profile_name given, only remove that profile.
- saltext.vcf.clients.vim_vm_devices.serial_add(opts, vm_id_or_name, *, backing='network', uri=None, direction='server', file_path=None, profile=None)[source]¶
Add a serial port.
backing —
"network"(URI) or"file". For"network", supply uri (e.g.tcp://0.0.0.0:9000) and direction (server/client). For"file", supply file_path (e.g.[ds1] vm/serial.log).
- saltext.vcf.clients.vim_vm_devices.serial_remove(opts, vm_id_or_name, key=None, profile=None)[source]¶
Remove a serial port. If key is None, removes the first one.
- saltext.vcf.clients.vim_vm_devices.usb_controllers_list(opts, vm_id_or_name, profile=None)[source]¶
List USB controller devices (USB 2.0 and/or USB 3.x xHCI) on a VM.
- Parameters:
- Returns:
One
{"key", "label", "summary"}dict per USB controller device found. Empty list if the VM has none.- Return type:
- saltext.vcf.clients.vim_vm_devices.usb_controllers_remove(opts, vm_id_or_name, profile=None)[source]¶
Remove every USB controller device from a VM.
Batches all removals into one
ReconfigVM_Taskcall — the KB’s reference PowerCLI script issues a separate task per device with a sleep in between, but a VM has at most one USB 2.0 and one USB 3.x controller, so batching is both faster and atomic.- Parameters:
- Returns:
One
{"key", "label", "summary"}dict per USB controller device that was removed. Empty list, and noReconfigVM_Taskcall, if the VM had none.- Return type:
- saltext.vcf.clients.vim_vm_devices.list_vms_with_usb_controllers(opts, profile=None)[source]¶
Return every VM in the inventory that has a USB controller device.
Mirrors the KB-316384 PowerCLI audit sweep (
Get-VM | ? {...}), but across the whole inventory in one call rather than one VM at a time.- Parameters:
opts – Salt
__opts__, used to resolve the vCenter/ESXi connection.profile (str, optional) – Named connection profile. Defaults to None.
- Returns:
One entry per VM that has at least one USB controller, each shaped as:
{ "vm": str, # VM name "moid": str, # VM moId "connected": bool, # runtime.connectionState == "connected" "devices": list[dict], # see usb_controllers_list }
connected matches
VirtualMachine.runtime.connectionState == "connected", the same check the reference script makes before attempting a removal.- Return type: