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
salt.modules.xapi_virt.
freecpu
()¶Return an int representing the number of unallocated cpus on this hypervisor
CLI Example:
salt '*' virt.freecpu
salt.modules.xapi_virt.
freemem
()¶Return an int representing the amount of memory that has not been given to virtual machines on this node
CLI Example:
salt '*' virt.freemem
salt.modules.xapi_virt.
full_info
()¶Return the node_info, vm_info and freemem
CLI Example:
salt '*' virt.full_info
salt.modules.xapi_virt.
get_disks
(vm_)¶Return the disks of a named vm
CLI Example:
salt '*' virt.get_disks <vm name>
salt.modules.xapi_virt.
get_macs
(vm_)¶Return a list off MAC addresses from the named vm
CLI Example:
salt '*' virt.get_macs <vm name>
salt.modules.xapi_virt.
get_nics
(vm_)¶Return info about the network interfaces of a named vm
CLI Example:
salt '*' virt.get_nics <vm name>
salt.modules.xapi_virt.
is_hyper
()¶Returns a bool whether or not this node is a hypervisor of any kind
CLI Example:
salt '*' virt.is_hyper
salt.modules.xapi_virt.
list_domains
()¶Return a list of virtual machine names on the minion
CLI Example:
salt '*' virt.list_domains
salt.modules.xapi_virt.
migrate
(vm_, target, live=1, port=0, node=- 1, ssl=None, change_home_server=0)¶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
salt.modules.xapi_virt.
node_info
()¶Return a dict with information about this node
CLI Example:
salt '*' virt.node_info
salt.modules.xapi_virt.
pause
(vm_)¶Pause the named vm
CLI Example:
salt '*' virt.pause <vm name>
salt.modules.xapi_virt.
reboot
(vm_)¶Reboot a domain via ACPI request
CLI Example:
salt '*' virt.reboot <vm name>
salt.modules.xapi_virt.
reset
(vm_)¶Reset a VM by emulating the reset button on a physical machine
CLI Example:
salt '*' virt.reset <vm name>
salt.modules.xapi_virt.
resume
(vm_)¶Resume the named vm
CLI Example:
salt '*' virt.resume <vm name>
salt.modules.xapi_virt.
setmem
(vm_, memory)¶Changes the amount of memory allocated to VM.
Memory is to be specified in MB
CLI Example:
salt '*' virt.setmem myvm 768
salt.modules.xapi_virt.
setvcpus
(vm_, vcpus)¶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
salt.modules.xapi_virt.
shutdown
(vm_)¶Send a soft shutdown signal to the named vm
CLI Example:
salt '*' virt.shutdown <vm name>
salt.modules.xapi_virt.
start
(config_)¶Start a defined domain
CLI Example:
salt '*' virt.start <path to Xen cfg file>
salt.modules.xapi_virt.
stop
(vm_)¶Hard power down the virtual machine, this is equivalent to pulling the power
CLI Example:
salt '*' virt.stop <vm name>
salt.modules.xapi_virt.
vcpu_pin
(vm_, vcpu, cpus)¶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
salt.modules.xapi_virt.
vm_cputime
(vm_=None)¶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
salt.modules.xapi_virt.
vm_diskstats
(vm_=None)¶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
salt.modules.xapi_virt.
vm_info
(vm_=None)¶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
salt.modules.xapi_virt.
vm_netstats
(vm_=None)¶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
salt.modules.xapi_virt.
vm_state
(vm_=None)¶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>