A XenServer can be managed with the xe Commandline Interface (CLI). Which can be run locally at the command prompt of the XenServer Console within XenCenter.
The ex.exe is also part of the XenCenter installation and allows and administrator to remotely manage a XenServer from the command prompt of the Windows desktop. With the CLI you can easily script some of the common tasks to perform on a XenServer.
Each xe.exe command starts with the connection settings for the XenServer (Pool Master), followed by the specific command(s) to be performed.
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] [xe-commands]
Which uses the following syntax:
- xenserver: ip-address or name of the XenServer (or Pool Master).
- user: name of account used to connect to the XenServer.
- password: password of the used account.
- xe-commands: the commands to be performed after the connection to the XenServer (Pool Master) is made.
The rest of this post contains some examples of the different xe-commands that can be used.
* List all XenServers in a Pool:
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] host-list
Gives a list of all XenServers (host) and their uuid.
* Remove a dead XenServer from a Pool:
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] host-forget uuid=[host-uuid]
Which uses the following additional syntax:
- host-uuid: uuid of the XenServer that is to be removed from the pool.
* Lists all VM’s on a host, except for the Control Domain:
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] vm-list resident-on=[host-uuid] is-control-domain=false
Which uses the following additional syntax:
- host-uuid: uuid of the XenServer that is checked for existing VMs.
* Force a VM to be turned off:
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] vm-reset-powerstate uuid=[vm-uuid] -force
Which uses the following additional syntax:
- vm-uuid: uuid of the VM that is forced to shut down.
* Copy a VM (using an existing VM):
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] vm-copy new-name-label=[new-vm-name] vm=[template-vm-name]
Which uses the following additional syntax:
- new-vm-name: name to asign to the newly created VM.
- template-vm-name: name of the VM used to be cloned/copied.
* Create a new disk for a specified VM:
C:\Program Files\Citrix\XenCenter>xe.exe -s [xenserver] -u [user] -pw [password] vm-disk-add disk-size=[disk-size-bytes] device=[allowed-vbd-devices] sr-uuid=[sr-uuid] vm=[vm-name]
Which uses the following additional syntax:
- disk-size-bytes: size of the new disk (bytes).
- allowed-vbd-devices: value between 0 and 15.
- sr-uuid: can be found with the sr-list command.
- vm-name: name-label of the vm.
The following sources have be used to create this post:
XenServer Administrator’s Guide – Release 5.5.0 Update 1 [Chapter 8]
Citrix Forums: How to forcefully remove a dead host
This article was originally posted at Jan 16, 2010 @ 15:00 *** Last update: Added new CLI commands. ***