Introduction

This blog entry demonstrates the XenAPINFS – Glance integration. The feature’s blueprint can be found on launchpad. At the time of writing this document, the driver only supports XenServer type ovf images (these images are specially named vhd files compressed to a .tgz archive). The cinder driver is using the nova xenapi plugins to upload/download the images. I am also working on a general case, to be able to create volumes from images with arbitrary format (such as qcow or raw). Should you wish to try out XenAPINFS, make sure that the fix for this bug already hit trunk, or cherry-pick the patch.

In this demo, I will:

  • create a volume from a glance image
  • boot an instance from the created volume
  • make changes to the filesystem
  • upload the volume to glance as a new image
  • create instances based on the newly created image

Requirements

NFS Server

For the demo, a single Ubuntu VM is serving the NFS. The following options were specified for the export:

[[code]]czo4NzpcInVidW50dUBjb3BwZXI6fiQgZ3JlcCBkZW1vIC9ldGMvZXhwb3J0cyANCi9kZW1vICoocncsbm9fc3VidHJlZV9jaGVjayx7WyYqJl19bm9fcm9vdF9zcXVhc2gpDQpcIjt7WyYqJl19[[/code]]

XenServer with OpenStack

For the demo Devstack was used to install a development OpenStack on XenServer 6.1. For the demo, only one XenServer was used, however, it is possible to use a totally different XenServer for cinder operations. The only requirement is, that Nova plugins must be installed on the XenServer used for volume operations (the one specified in cinder.conf).

Step 1. – Configure Cinder

Cinder needs to be configured to use the XenAPINFS driver. I will show two ways to do it.

Edit the Configuration File Directly

To configure cinder, go to the openstack box, and edit the configuration file /etc/cinder/cinder.conf, and make sure the following settings are there:

[[code]]czoyNzc6XCJ2b2x1bWVfZHJpdmVyID0gY2luZGVyLnZvbHVtZS5kcml2ZXJzLnhlbmFwaS5zbS5YZW5BUElORlNEcml2ZXINCnhlbmF7WyYqJl19cGlfY29ubmVjdGlvbl91cmwgPSBodHRwOi8vZXB1bi5lbmcuaHEueGVuc291cmNlLmNvbQ0KeGVuYXBpX2Nvbm5lY3Rpb25fdXNlcntbJiomXX1uYW1lID0gcm9vdA0KeGVuYXBpX2Nvbm5lY3Rpb25fcGFzc3dvcmQgPSBwYXNzd29yZA0KeGVuYXBpX25mc19zZXJ2ZXIgPSBjb3Bwe1smKiZdfWVyLmVuZy5ocS54ZW5zb3VyY2UuY29tDQp4ZW5hcGlfbmZzX3NlcnZlcnBhdGggPSAvZGVtbw0KXCI7e1smKiZdfQ==[[/code]]

After making changes to cinder’s configuration, make sure the service is restarted.

Use Devstack to Configure Cinder

You can also use devstack, to configure cinder with XenAPINFS. The variables required for the localrc file are:

[[code]]czoyNjM6XCJDSU5ERVJfRFJJVkVSPVhlbkFQSU5GUw0KQ0lOREVSX1hFTkFQSV9DT05ORUNUSU9OX1VSTD1cImVwdW4uZW5nLmhxLnhle1smKiZdfW5zb3VyY2UuY29tXCINCkNJTkRFUl9YRU5BUElfQ09OTkVDVElPTl9VU0VSTkFNRT1yb290DQpDSU5ERVJfWEVOQVBJX0NPTk5FQ1RJe1smKiZdfU9OX1BBU1NXT1JEPVwicGFzc3dvcmRcIg0KQ0lOREVSX1hFTkFQSV9ORlNfU0VSVkVSPVwiY29wcGVyLmVuZy5ocS54ZW5zb3VyY2UuY297WyYqJl19bVwiDQpDSU5ERVJfWEVOQVBJX05GU19TRVJWRVJQQVRIPVwiL2RlbW9cIg0KXCI7e1smKiZdfQ==[[/code]]

After adding these lines to your localrc file, re-stack your environment:

[[code]]czo5MjpcInN0YWNrQERldlN0YWNrT1NEb21VOn4vZGV2c3RhY2skIC4vdW5zdGFjay5zaA0Kc3RhY2tARGV2U3RhY2tPU0RvbVU6fi97WyYqJl19ZGV2c3RhY2skIC4vc3RhY2suc2gNClwiO3tbJiomXX0=[[/code]]

Please note, that by doing that, you are wiping, and re-building your OpenStack installation.

Step 2. – Upload an Image

A cirros image is provided via our github account. This image is already in XenServer format. To upload it:

[[code]]czozMDY6XCJzdGFja0BEZXZTdGFja09TRG9tVTp+JCBjZCBkZXZzdGFjay8NCnN0YWNrQERldlN0YWNrT1NEb21VOn4vZGV2c3RhY2t7WyYqJl19JCAuIG9wZW5yYyBhZG1pbg0Kc3RhY2tARGV2U3RhY2tPU0RvbVU6fi9kZXZzdGFjayQgZ2xhbmNlIGltYWdlLWNyZWF0ZSAtLW5hbXtbJiomXX1lIGRlbW9pbWFnZSBcXA0KLS1jb3B5LWZyb209aHR0cHM6Ly9naXRodWIuY29tL2Rvd25sb2Fkcy9jaXRyaXgtb3BlbnN0YWNrL3dhcntbJiomXX1laG91c2UvY2lycm9zLTAuMy4wLXg4Nl82NC1kaXNrLnZoZC50Z3ogXFwNCi0tY29udGFpbmVyLWZvcm1hdD1vdmYgLS1kaXNrLWZvcntbJiomXX1tYXQ9dmhkDQpcIjt7WyYqJl19[[/code]]

Make sure you give enough time for glance to store the image. Wait, until

[[code]]czo1MjpcInN0YWNrQERldlN0YWNrT1NEb21VOn4vZGV2c3RhY2skIGdsYW5jZSBpbWFnZS1saXN0DQpcIjt7WyYqJl19[[/code]]

shows, that demoimage is active:

[[code]]czo0OTpcIi4uLiBkZW1vaW1hZ2UgfCB2aGQgfCBvdmYgfCA5MjIwMDE4ICB8IGFjdGl2ZSB8DQpcIjt7WyYqJl19[[/code]]

Step 3. – Create a volume from an Image

First, get the id of the new image:

[[code]]czo3MjpcInN0YWNrQERldlN0YWNrT1NEb21VOn4vZGV2c3RhY2skIGdsYW5jZSBpbWFnZS1zaG93IGRlbW9pbWFnZSB8IGdyZXAgaWR7WyYqJl19DQpcIjt7WyYqJl19[[/code]]

And use that, to create a 1G volume based on that image, called demovolume_a:

[[code]]czoxMDc6XCJzdGFja0BEZXZTdGFja09TRG9tVTp+JCBjaW5kZXIgY3JlYXRlIC0tZGlzcGxheV9uYW1lPVwiZGVtb3ZvbHVtZV9hXCIgLXtbJiomXX0taW1hZ2UtaWQ9Jmx0O3B1dCBpbWFnZWlkIGhlcmUmZ3Q7IDENClwiO3tbJiomXX0=[[/code]]

Initially, the volume’s status will be downloading, and as that operation is finished, it becomes available. Check its status with:

[[code]]czozNzpcInN0YWNrQERldlN0YWNrT1NEb21VOn4kIGNpbmRlciBsaXN0DQpcIjt7WyYqJl19[[/code]]

Step 4. – Boot an Instance from the Volume

To boot an instance, first we need the id of the volume:

[[code]]czo0MTpcImNpbmRlciBzaG93IGRlbW92b2x1bWVfYSB8IGdyZXAgIFwiIGlkIFwiDQpcIjt7WyYqJl19[[/code]]

And create a new instance with that volume as its primary hard disk:

[[code]]czoxMTA6XCJzdGFja0BEZXZTdGFja09TRG9tVTp+JCBub3ZhIGJvb3QgLS1mbGF2b3I9bTEuc21hbGwgLS1ibG9ja19kZXZpY2VfbWF7WyYqJl19cHBpbmcgdmRhPSZsdDt2b2x1bWUgaWQmZ3Q7Ojo6MCBkZW1vX3ZtDQpcIjt7WyYqJl19[[/code]]

Use horizon to access the console of the new VM, and log in using the usual cirros credentials, and touch a file in the home directory. We expect to see these changes in the created image later.

[[code]]czoyNTpcIiQgdG91Y2ggSEVSRUlBTQ0KJCBzeW5jDQpcIjt7WyYqJl19[[/code]]

And use nova to shut down the instance.

[[code]]czo1NzpcInN0YWNrQERldlN0YWNrT1NEb21VOn4kIG5vdmEgZGVsZXRlICZsdDtpbnN0YW5jZSBpZCZndDsNClwiO3tbJiomXX0=[[/code]]

Step 5. – Create an Image from the Volume

[[code]]czoxMTk6XCJzdGFja0BEZXZTdGFja09TRG9tVTp+JCBjaW5kZXIgdXBsb2FkLXRvLWltYWdlIC0tY29udGFpbmVyLWZvcm1hdD1vdmZ7WyYqJl19IC0tZGlzay1mb3JtYXQ9dmhkICZsdDt2b2x1bWUgaWQmZ3Q7IGRlbW9pbWFnZV9iDQpcIjt7WyYqJl19[[/code]]

Check the status of the image, by:

[[code]]czo1NTpcInN0YWNrQERldlN0YWNrT1NEb21VOn4kIGdsYW5jZSBpbWFnZS1zaG93IGRlbW9pbWFnZV9iDQpcIjt7WyYqJl19[[/code]]

And wait until it is active.

Step 6. – Launch an Instance from the Uploaded Image

First, get the id of the newly created image:

[[code]]czo2NTpcInN0YWNrQERldlN0YWNrT1NEb21VOn4kIGdsYW5jZSBpbWFnZS1zaG93IGRlbW9pbWFnZV9iIHwgZ3JlcCBpZA0KXCI7e1smKiZdfQ==[[/code]]

And boot an instance with that image:

[[code]]czo4MzpcInN0YWNrQERldlN0YWNrT1NEb21VOn4kIG5vdmEgYm9vdCAtLWZsYXZvcj1tMS5zbWFsbCAtLWltYWdlPWRlbW9pbWFnZV97WyYqJl19YiBkZW1vX3ZtXzINClwiO3tbJiomXX0=[[/code]]

And use horizon to log in, and check the contents of the home directory:

[[code]]czozMDpcIiQgbHMgfCBncmVwIEhFUkVJQU0NCkhFUkVJQU0NClwiO3tbJiomXX0=[[/code]]