Work with virtual machines managed by libvirt
Required python modules: libvirt
Members
Start a defined domain
CLI Example:
salt '*' virt.create <vm name>
Start a defined domain
CLI Example:
salt '*' virt.create_xml_path <path to xml file on the node>
Start a domain based on the xml passed to the function
CLI Example:
salt '*' virt.create_xml_str <xml in string format>
Hard power down the virtual machine, this is equivalent to pulling the power
CLI Example:
salt '*' virt.destroy <vm name>
Return an int representing the number of unallocated cpus on this hypervisor
CLI Example:
salt '*' virt.freecpu
Return an int representing the amount of memory that has not been given to virtual machines on this node
CLI Example:
salt '*' virt.freemem
Return the node_info, vm_info and freemem
CLI Example:
salt '*' virt.full_info
Return the disks of a named vm
CLI Example:
salt '*' virt.get_disks <vm name>
Returns the information on vnc for a given vm
CLI Example:
salt '*' virt.get_graphics <vm name>
Return a list off MAC addresses from the named vm
CLI Example:
salt '*' virt.get_macs <vm name>
Return info about the network interfaces of a named vm
CLI Example:
salt '*' virt.get_nics <vm name>
Returns the xml for a given vm
CLI Example:
salt '*' virt.get_xml <vm name>
Returns a bool whether or not this node is a hypervisor of any kind
CLI Example:
salt '*' virt.is_hyper
Returns a bool whether or not this node is a KVM hypervisor
CLI Example:
salt '*' virt.is_kvm_hyper
Returns a bool whether or not this node is a XEN hypervisor
CLI Example:
salt '*' virt.is_xen_hyper
Return a list of names for active virtual machine on the minion
CLI Example:
salt '*' virt.list_active_vms
Return a list of names for inactive virtual machine on the minion
CLI Example:
salt '*' virt.list_inactive_vms
Return a list of virtual machine names on the minion
CLI Example:
salt '*' virt.list_vms
Shared storage migration
CLI Example:
salt '*' virt.migrate <vm name> <target hypervisor>
Return a dict with information about this node
CLI Example:
salt '*' virt.node_info
Recursively destroy and delete a virtual machine, pass True for dir's to also delete the directories containing the virtual machine disk images - USE WITH EXTREME CAUTION!
CLI Example:
salt '*' virt.purge <vm name>
Resume the named vm
CLI Example:
salt '*' virt.resume <vm name>
Set the autostart flag on a VM so that the VM will start with the host system on reboot.
CLI Example:
salt "*" virt.set_autostart <vm name> <on | off>
Send a soft shutdown signal to the named vm
CLI Example:
salt '*' virt.shutdown <vm name>
Alias for the obscurely named 'create' function
CLI Example:
salt '*' virt.start <vm name>
Remove a defined vm, this does not purge the virtual machine image, and this only works if the vm is powered down
CLI Example:
salt '*' virt.undefine <vm name>
Returns the virtual machine type as a string
CLI Example:
salt '*' virt.virt_type
Return detailed information about the vms on this hyper in a list of dicts:
[
'your-vm': {
'cpu': <int>,
'maxMem': <int>,
'mem': <int>,
'state': '<state>',
'cputime' <int>
},
...
]
If you pass a VM name in as an argument then it will return info for just the named VM, otherwise it will return all VMs.
CLI Example:
salt '*' virt.vm_info