dev += ops

Knife-XAPI: Chef and Xenserver

| Comments


Just finished making a knife plugin (my first) and gem (also my first) that enables knife xapi support. Right now it is only supporting guest create, but I plan on adding more commands in the near future.

you can install it with gem

gem install knife-xapi

Now you can spin up a guest on a Xen API host with knife. This is basic usage

knife xapi guest create "NewBox" "public"  \
  --xapi-vm-template "MyBaseBox" \
  --host http://sandbox/

The “NewBox” is the hosts name-label, and “public” would be the network name label you want to attach eth0 too. You can specify more networks as well:

knife xapi guest create "router" "public" "dmz" "private"  \
  --xapi-vm-template "MyBaseBox"  \
  --host http://sandbox/

This would build out a box basedon MyBaseBox template, and add 3 interfaces eth0/1/2 that are connected to those networks in the order specified.

The way I am using this now is to boot centos boxes and kickstart them at will. Using this more elaborate comandline:

knife xapi guest create "MySpiffyBox" "pub_network" \
 -B "dns= ks= ip= netmask= gateway=" \
 -R \
 -C 4 -M 4g -D 5g \
 -T "CentOS 5 (64-bit)" --host http://sandbox/

Here I am using the default xenserver 5 template to install a cent5 based vm with -T. Setting the VM Boot Arguments with -B that are instructing anaconda where to get the kickstart and how to setup the netinstalls networking. The -C switch is setting up 4 cpu’s on the guest. The -M is allocating 4 gigs of mem and -D is creating the root disk (xvda) as a 5GB box. This particular kickstart is a minimal centos install. This kicks off my kickstart install and in ~3 minutes i have a fresh machine installed via knife.


This is the stuff i want to add into this plugin:

  • Fix SSL issues
  • Guest Destroy
  • Guest List
  • Network List
  • Network Create
  • Network Destroy
  • SR Management

I may or may not include this in the knife command:

  • VM Metrics
  • Host Metrics
  • VIF/VBD Metrics


Right now the big one is that the XML::RPC client gem is not supporting a way for me to ignore SSL Self signed certs that xenservers ship with. So https:// will only work on properly signed api endpoints.


You can grab poke/comment and help me make this better! Codes up on github