Tech
- Details
- Category: Xenserver Howtos
Prerequisites
- XCP/Xenserver
Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an local Logical Volume.
First we need to know the name of the LVM Volume Group. This is taken from the Storage Repository's UUID. To get this we'll use xe host-list.
[root@cloud1 ~]# xe sr-list type=lvm uuid ( RO) : 36bf480a-5df9-4453-50f0-2bac4a86cb42 name-label ( RW): localsr-cloud1 name-description ( RW): host ( RO): cloud1.acs.edcc.edu type ( RO): lvm content-type ( RO): user
Using xe sr-list type=lvm shows only our local Storage Repository which has the UUID of 36bf480a-5df9-4453-50f0-2bac4a86cb42. We'll now use the vgs command to give us the names of all Volume Groups including VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 which matches our SR UUID.
- Details
- Category: Xenserver Howtos
Prerequisites
- XCP/Xenserver
Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an additional hard drive on Dom0.
First we need to know the device name of the disk.
[root@cloud1 media]# cat /proc/partitions major minor #blocks name 8 0 976762584 sda 8 1 4194304 sda1 8 2 4194304 sda2 8 3 968371393 sda3 8 16 234431064 sdb
- Details
- Category: Xenserver Howtos
Prerequisites
- XCP/Xenserver
Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an NFS share.
In our example we'll be using a share on the cloud0 host named /media/NFSISO. To set this up on cloud0 you'd log into cloud0 as root and add this line to the /etc/exports file of your NFS server.
/media/NFSISO/ *(rw)
I'd recommend that you secure your NFS share more tightly than I've done here but for the purpose of this tutorial we'll go with it. We need to make a directory that we can mount our NFS share on first.
- Details
- Category: Virtualization Blog
I've been working on ways of getting information to the XCP/Xenserver Admins eyes faster than the standard xe commandline tool provides. This tool - lshosts is a rewrite of lshostvms.sh which showed each host and how many running VMs were on it, something I often would like to know. While rewriting it to include some of the better structure of my newer tools I started adding features. Now it displays either the Host's name-label or UUID, the number of running VMs, the CPU type, CPU cores, CPU speed, Total Memory, Free Memory and Network backend type.
As an added bonus I've added a -c option so the output is in CSV format. All future commands should have this option and I'll be retrofitting older commands when I get time.
Download it from the XCP Downloads section. http://grantmcwilliams.com/tech/virtualization/downloads/category/4-xen-cloud-platform
- Details
- Category: Xenserver Howtos
Prerequisites
- XCP/Xenserver
Sometimes I get a stuck Virtual Machine that just won't go down and it's usually due to a lack of memory in the VM. When I issue a shutdown command from within the VM it starts the shutdown process but hangs part way through. Executing xe vm-shutdown --force uuid=<insert UUID here> does nothing but lock up the terminal. If this happens to you follow the steps below to forcefully shut the VM down.
- xe task-list (find the pending tasks UUID)
- xe task-cancel uuid=<task UUID>
- xe vm-list (note the VM's UUID)
- list_domains (find the VM's UUID and note the domain id)
- /opt/xensource/debug/destroy_domain -domid XX (where XX is the domain id from step 2)
- xe vm-shutdown --force uuid=<UUID from step 1>
The steps above in script form (if you trust me). Step one has to be entered in manually. The rest can be copied and pasted.
name="Name Label"
TASK=$(xe task-list status=pending --minimal)
xe task-cancel uuid="$TASK"
VMUUID=$(xe vm-list name-label="$name" --minimal)
DOMID=$(xe vm-list uuid="$VMUUID" params=dom-id --minimal) /opt/xensource/debug/destroy_domain -domid "$DOMID" xe vm-shutdown --force uuid="$VMUUID"
- Details
- Category: Virtualization Blog
My newest XCP tool is to list networks in a quick concise manner. By default lsnetworks shows the network name, the bridge it's associated with, the VLAN tag (if there is one), the VMs that have a network interface on it and the number of that interface.
It can be found in the xenapi-admin-tools github.
Because XCP/Xenserver relies so much on UUID numbers I've provided a -u option which lists every object by UUID number if it has one. This won't be quite as useful as an interactive tool but if you're copy and pasting UUID's into xe commands this will give you a quick summary of them in relation to networks.
- Details
- Category: Virtualization Blog
XCP and Xenserver store their Virtual Disk Images on storage repository. To see how much space you have on your LVM or lvmoisci storage repositories from the commandline can be quite a chore so I wrote a df command for storage repositories. My dfsr command mimics the output of the Linux df command with the human readable flag set (-h). All values will be printed in Kilobytes, Megabytes, Gigabytes and so on. It shows the size of the repository, how much is used, how much is available, the percent used and the Storage Repository type.
Get it from my Virtualization downloads section.
- Details
- Category: Virtualization Blog
I've mentioned before that XCP/Xenserver's xe command is great for scripting but not always that great for interactive use. Because XCP relies so much on using UUID's for identification it's not very human friendly. Also the xe help is quite bad leading to our team that's working on writing documentation for xe. Even so xe makes a great scripting tool.
To show the difference between xe's output and what I think it could be let me introduce my lstemplate.sh script available in the XCP Downloads Section of this website. The xe command has a tendency to show output on multiple lines which isn't very parsable and is sort of hard to read. I understand that it's easier to program though. I however, like as much info on one line as possible allowing me to send the output into awk/cut if I wish and also keeps formatting clean.
Below is the output from xe template-list
....
You can see the output doesn't wrap well and isn't that easy to read. My biggest irritation is trying to find the template for the OS I want to use. There are a lot of templates and I usually end up scrolling for quite some time to get the right one. My other choice is to pipe the output of xe template-list into grep -B1 to search for the name and print the line before the name-label which will show the UUID number. For instance xe template-list | grep -B1 'Red Hat'. As easy as that is I find myself scanning the output of xe template-list in order to know what to grep for which defeats the purpose of grepping.
To solve this I wrote a small script called lstemplate.sh (list template). Below is the output.
You can also pass a -v (verbose) flag to get the descriptions too.
- Details
- Category: Virtualization Blog
As I and the team are writing manpages for XCP's xe command and it's 361 sub commands I'm writing more XCP tools. Last night I hacked out lshostvms.sh and xcptop.sh.
The lshostvms.sh script gives a quick list of hosts and shows numerically how many VMs are currently running on each. This includes the Control Domain itself currently but I may change that in the future.
The xcptop.sh script gives a list of all hosts and for each CPU core shows the utilisation according to XCP.
- Details
- Category: Virtualization Blog
As I build tools to help manage my clouds I will upload them here. So far I have three - mktemplate.sh, lstemplate.sh and lsvms.sh.
- mktemplate.sh is a wizard that creates XCP/Xenserver templates.
- lstemplate.sh lists XCP/Xenserver templates showing name-label and UUID sorted with colors. Optionally it shows the template description.
- lsvms.sh lists XCP/Xenserver Virtual Machines including name, running state, UUID and it's host.
In each of these cases I needed this functionality in a nice easy to use command. I also wanted the output to be parsable if possible ie. it needed to be line oriented and each field separated by white space.
There will be many more tools coming as I get time and I have needs. I'd love to have a tool that lists VM hardware (nics, disks, cds) in a nice manner, a tool to list disks and the srs they reside on with flags (rw etc..). Stay tuned.
The tools have been moved to github so the most convenient way to install them is to install git and do a git clone.
Intall Git on XCP - http://grantmcwilliams.com/item/652-install-git-on-xcp-host
Git clone - git clone https://github.com/Xenapi-Admin-Project/xenapi-admin-tools