This module (mostly) uses the XenAPI to manage Xen virtual machines.
Big fat warning: the XenAPI used in this file is the one bundled with Xen Source, NOT XenServer nor Xen Cloud Platform. As a matter of fact it will fail under those platforms. From what I've read, little work is needed to adapt this code to XS/XCP, mostly playing with XenAPI version, but as XCP is not taking precedence on Xen Source on many platforms, please keep compatibility in mind.
Useful documentation:
. http://downloads.xen.org/Wiki/XenAPI/xenapi-1.0.6.pdf . http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/ . https://github.com/xapi-project/xen-api/tree/master/scripts/examples/python . http://xenbits.xen.org/gitweb/?p=xen.git;a=tree;f=tools/python/xen/xm;hb=HEAD
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>
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 a bool whether or not this node is a hypervisor of any kind
CLI Example:
salt '*' virt.is_hyper
Return a list of virtual machine names on the minion
CLI Example:
salt '*' virt.list_domains
Migrates the virtual machine to another hypervisor
CLI Example:
salt '*' virt.migrate <vm name> <target hypervisor> [live] [port] [node] [ssl] [change_home_server]
Optional values:
Use live migration
Use a specified port
Use specified NUMA node on target
use ssl connection for migration
change home server for managed domains
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>
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>
Changes the amount of memory allocated to VM.
Memory is to be specified in MB
CLI Example:
salt '*' virt.setmem myvm 768
Changes the amount of vcpus allocated to VM.
vcpus is an int representing the number to be assigned
CLI Example:
salt '*' virt.setvcpus myvm 2
Send a soft shutdown signal to the named vm
CLI Example:
salt '*' virt.shutdown <vm name>
Start a defined domain
CLI Example:
salt '*' virt.start <path to Xen cfg file>
Hard power down the virtual machine, this is equivalent to pulling the power
CLI Example:
salt '*' virt.stop <vm name>
Set which CPUs a VCPU can use.
CLI Example:
salt 'foo' virt.vcpu_pin domU-id 2 1
salt 'foo' virt.vcpu_pin domU-id 2 2-6
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': {
'io_read_kbs' : 0,
'io_write_kbs' : 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_diskstats
Return detailed information about the vms.
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': {
'io_read_kbs' : 0,
'io_total_read_kbs' : 0,
'io_total_write_kbs' : 0,
'io_write_kbs' : 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>