Work with virtual machines managed by libvirt
depends: | libvirt Python module |
---|
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>
Sends CTRL+ALT+DEL to a VM
CLI Example:
salt '*' virt.ctrl_alt_del <vm name>
Define a domain based on the XML passed to the function
CLI Example:
salt '*' virt.define_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>
Initialize a new vm
CLI Example:
salt 'hypervisor' vm_name 4 512 salt://path/to/image.raw
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>
Attempt to execute non-shared storage "all" migration
CLI Example:
salt '*' virt.migrate_non_shared <vm name> <target hypervisor>
Attempt to execute non-shared storage "all" migration
CLI Example:
salt '*' virt.migrate_non_shared_inc <vm name> <target hypervisor>
Return a dict with information about this node
CLI Example:
salt '*' virt.node_info
Pause the named vm
CLI Example:
salt '*' virt.pause <vm name>
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>
Reboot a domain via ACPI request
CLI Example:
salt '*' virt.reboot <vm name>
Reset a VM by emulating the reset button on a physical machine
CLI Example:
salt '*' virt.reset <vm name>
Resume the named vm
CLI Example:
salt '*' virt.resume <vm name>
Non shared migration requires that the disks be present on the migration destination, pass the disks information via this function, to the migration destination before executing the migration.
CLI Example:
salt '*' virt.seed_non_shared_migrate <disks>
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>
Changes the amount of memory allocated to VM. The VM must be shutdown for this to work.
memory is to be specified in MB If config is True then we ask libvirt to modify the config as well
CLI Example:
salt '*' virt.setmem myvm 768
Changes the amount of vcpus allocated to VM. The VM must be shutdown for this to work.
vcpus is an int representing the number to be assigned If config is True then we ask libvirt to modify the config as well
CLI Example:
salt '*' virt.setvcpus myvm 2
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 cputime used by the vms on this hyper in a list of dicts:
[
'your-vm': {
'cputime' <int>
'cputime_percent' <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_cputime
Return disk usage counters used by the vms on this hyper in a list of dicts:
[
'your-vm': {
'rd_req' : 0,
'rd_bytes' : 0,
'wr_req' : 0,
'wr_bytes' : 0,
'errs' : 0
},
...
]
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_blockstats
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
Return combined network counters used by the vms on this hyper in a list of dicts:
[
'your-vm': {
'rx_bytes' : 0,
'rx_packets' : 0,
'rx_errs' : 0,
'rx_drop' : 0,
'tx_bytes' : 0,
'tx_packets' : 0,
'tx_errs' : 0,
'tx_drop' : 0
},
...
]
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_netstats
Return list of all the vms and their state.
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_state <vm name>