f00bar.com

dev += ops

Knife-XAPI: Chef and Xenserver

| Comments

Knife-XAPI

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

1
gem install knife-xapi

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

1
2
3
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:

1
2
3
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:

1
2
3
4
5
knife xapi guest create "MySpiffyBox" "pub_network" \
 -B "dns=8.8.8.8 ks=http://192.168.6.4/repo/ks/default.ks ip=192.168.6.7 netmask=255.255.255.0 gateway=192.168.6.1" \
 -R http://192.168.6.5/repo/centos/5/os/x86_64 \
 -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.

TODO

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

Bugs

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.

Source

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

Comments