Contextualization Overview 4.2

OpenNebula comes a method to pass information to a newly created Virtual Machine. This is very handy to configure parameters as soon as the VM is running. The most common thing configured with this system is networking.

Following are the instructions to contextualize your images to configure the network. For more in depth information and information on how to use this information for other duties head to the Contextualizing Virtual Machines guide.

Preparing the Virtual Machine Image

To enable the Virtual Machine images to use the contextualization information written by OpenNebula we need to add to it a series of scripts that will trigger the contextualization.

You can use the images available in the Marketplace, that are already prepared, or prepare your own images. To make your life easier you can use a couple of Linux packages that do the work for you.

The contextualization package will also mount any partition labeled swap as swap. OpenNebula sets this label for volatile swap disks.

  • Start a image (or finish its installation)
  • Download and install the package for your distribution:
    • DEB: Compatible with Ubuntu 11.10 to 13.04 and Debian Squeeze
    • RPM: Compatible with CentOS and RHEL 6.x
  • Shutdown the VM

Preparing the Template

We will also need to add the gateway information to the Virtual Networks that need it. This is an example of a Virtual Network with gateway information:


And then in the VM template contextualization we set NETWORK to “yes”:


When the template is instantiated, those parameters for `eth0` are automatically set in the VM as:

  TARGET="hda" ]

If you add more that one interface to a Virtual Machine you will end with same parameters changing ETH0 to ETH1, ETH2, etc.

You can also add `SSH_PUBLIC_KEY` parameter to the context to add a SSH public key to the `authorized_keys` file of root.

  SSH_PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+vPFFwem49zcepQxsyO51YMSpuywwt6GazgpJe9vQzw3BA97tFrU5zABDLV6GHnI0/ARqsXRX1mWGwOlZkVBl4yhGSK9xSnzBPXqmKdb4TluVgV5u7R5ZjmVGjCYyYVaK7BtIEx3ZQGMbLQ6Av3IFND+EEzf04NeSJYcg9LA3lKIueLHNED1x/6e7uoNW2/VvNhKK5Ajt56yupRS9mnWTjZUM9cTvlhp/Ss1T10iQ51XEVTQfS2VM2y0ZLdfY5nivIIvj5ooGLaYfv8L4VY57zTKBafyWyRZk1PugMdGHxycEh8ek8VZ3wUgltnK+US3rYUTkX9jj+Km/VGhDRehp user@host"

You can get more information about these parameters in the contextualization guide.