CernVM Online Cloud Contextualization

Introduction

CernVM supports applying contextualization information at boot time using one of the following mechanisms:

  • User-Data: almost all of the private or public cloud infrastructures provide a mechanism of passing arbitrary data to the instance at the creation time. A good example is Amazon's Instance Metadata for EC2.
  • CD-ROM: the HEPIX startup scripts that reside in CernVM also process compatible CD-ROM images that contain contextualization information.

Both mechanisms eventually pass a string of ini-like data to the instance.

1. Preparation

If you want to instruct CernVM to download contextualization information found in the CernVM Online website you must provide the following data as user-data or CD-ROM contextualization information:

[amiconfig]
plugins=cernvm

[cernvm]
contextualization_key=[context UUID][:secret]

The part after the colon is the secret key you used to encrypt you context information on CernVM online. If you did not use a secret key, omit this part.

Almost all of the tools require those data to be encoded in base64, so first thing you should do after you have prepared your contextualization information is to generate a base64 string. For example in bash:

~$ base64 -w0 <<EOF
[amiconfig]
plugins=cernvm
[cernvm]
contextualization_key= 45596f0d1f5648d0ad64ded48496d547
EOF

This command will respond something like: W2FtaWNvbmZpZ10KcGx1Z2lucz1jZXJudm0KW2Nlcm52bV0KY29udGV4dH..... Copy this, you will need it later.

2a. Using User-Data

Amazon EC2 and many other private infrastructures have an almost identical set of command-line tools to manage their infrastructure. These tools provide the option to specify a user-data string while starting the instance.
This is usually the [prefix]-run-instances command. For example, if you want to start an instance on Amazon cloud you will use something like this:

ec2-run-instances [template id] -n [number of instances] -d [user-data]

Where user-data is the base64-encoded string you generated on the first step.

2b. Using CD-ROM

If it is not possible to use an infrastructure that supports user-data, you can still use the classic mechanism of hepix-compliant contextualization CD-ROM image. This image must contain at least one file called context.sh and this file must have at least the following two lines:

EC2_USER_DATA="[user-data]"
ONE_CONTEXT_PATH="/var/lib/amiconfig"

Where user-data is the base64-encoded string you generated on the first step.

To create the CD-ROM image (for example user-data.iso) you can then use the mkisofs utility:

~$ mkdir iso-tmp
~$ echo 'EC2_USER_DATA=45596f0d1f5648d0ad64ded48496d547' >> iso-tmp/context.sh
~$ echo 'ONE_CONTEXT_PATH="/var/lib/amiconfig"' >> iso-tmp/context.sh
~$ mkisofs -o user-data.iso iso-tmp

You must then mount this CD-ROM image to you virtual machine before you boot it. This is done differently on every hypervisor, so check your hypervisor configuration for more information.

For more details and for a complete iso creation script you can check the contextualization process of CernVM

You are here