In an effort to help with the automation of manpage generation I'm going to start learning OCaml.  If anyone knows of some good OCaml resources they would be much appreciated.  This is the only resource I have so far.

Read more: OCaml

I haven't written any tools for Xenapi Admin Tools in quite a while. Long enough that I forgot how getcmddata worked. Since ClassStack uses xaptools.lib to manage an XAPI stack I got a refresher do to me wanting a menu that outputed a Student's dom-id and the host their VM was running on in a menu. I wrote this out the quick way not using any functionality of xaptools.lib because that's what you do when you forget about the past.

 for i in $(seq 0 $(( ${#STUSIDS[@]} - 1 )) ) ;do	
        STUCONSOLE[$i]=$(xe vm-list name-label=${STUSIDS[$i]} params=dom-id --minimal)
	CLOUDHOSTUUID=$(xe vm-list name-label=${STUSIDS[$i]} params=resident-on --minimal)
	STUFQDN=$(xe host-list uuid=$CLOUDHOSTUUID params=name-label --minimal)

This is pretty simple - for each Student ID (STUSIDS array) get the VM's dom-id and the host it's resident on. Then get the fully qualified domain name of the host (it's name-label in my case). Use BASH pattern matching to grab the hostname portion of that. Displaying dom-id's for 15 students takes 15 seconds. This includes parsing their data from the Rosterfile, getting input from the user which class to display and executing the code above. When doing repetitive tasks 15 seconds can be pretty painful so I thought about making it faster. Halfway through hacking away at it - which mainly comprised of me trying to get rid of xe calls inside the loop - I remembered doing this before! I created a function in xaptools.lib called getcmddata that made ONE call to xe, returned the output as CSV then used BASH pattern matching to assign each portion of the CSV output to ARRAYs. It's been long enough that I had to go look up getcmddata to figure out how to use it. 

The resulting code using getcmddata from xaptools.lib.


        getcmddata vm-list params=name-label,dom-id,resident-on
	getcmddata host-list params=uuid,name-label
	for i in $(seq 0 $(( ${#vm_name_label[@]} - 1 )) ) ;do
		for j in $(seq 0 $(( ${#host_uuid[@]} - 1 )) ) ;do
			if [[ ${HOSTUUID[$i]} = ${host_uuid[$j]} ]] ;then
	for i in $(seq 0 $(( ${#STUSIDS[@]} - 1 )) ) ;do	
		for j in $(seq 0 $(( ${#VMNAME[@]} - 1 )) ) ;do
			if [[ ${STUSIDS[$i]} = ${VMNAME[$j]} ]] ;then

 Yes, it's much longer and does exactly the same thing as the first code block but it's much faster!

Execution time

  • Method one: 15 seconds
  • Method two using getcmddata: 2.3 seconds


Was it worth it? Absolutely. With a larger class the speed increase is even greater. Method one gets slower as the class gets larger eg. 30 students would have taken 30 seconds and so on. Method two is virtually the same speed no matter how many students there are because the number of xe calls are exactly the same.

Note to self: getvmdata in xaptools.lib is still using the old method and not getcmddata. If you don't look at your code you forget what's in there.


I've been hard at work this week on a few new manpages for the Host subcommands. Thank you Christina and Grant for the input on the pages. I'm pretty happy how these drafts have turned out!





Take a look!

Grant and I did some talking yesterday, and are hoping to get a "Core" release to the public with in 6 months. With the lack of contributions from old members, progress is slow, but hopefully we can get the new members writing. The pages we have so far are rendering and looking beautiful. We are making really great manpages. :)


I'm hoping to experiment with the OpenDayLight protocol stack and the SDN abilitys of XenServer. That would be a neat little research project eh?

Anyway, hope everyone is having a good week! Stay tuned!


New manpages for this week:

The *xe-host-data-source* commands are like built in data sensors. They allow you to monitor CPU usage, RAM, etc, etc via the command line..
There are old Citrix docs that show you how to write shell scripts to monitor your system.

The *xe-host-data-source-record* command is a little odd, it records to the rrd service on a machine, and so far, the only way I know how to retrieve the data is by using the HTTP API and WGET..