个人工具

UbuntuHelp:UEC/BundlingImages9.10

来自Ubuntu中文

跳转至: 导航, 搜索

Using UEC consists of creating and registering images with the Cloud Controller. There is more than one way to obtain a virtual image:

  • Download an image from the network, bundle and upload it
  • Create a custom image using VMBuilder
  • Use the Image store to download and install and image

Here we will describe the process of downloading one of the daily builds that are built and published automatically. The process is similar for Official Released Images

Note: the shell variables that are set in the below code snippets are very useful for scripts or to reuse them when typing commands.
  1. Download the UEC image for the architecture you want. You can do it from your browser or from the command line:
TIMESTAMP=$(date +%Y%m%d%H%M%S)
RELEASE=karmic
ARCH=amd64    # Or this might be i386
[ $ARCH = "amd64" ] && IARCH=x86_64 || IARCH=i386
UEC_IMG=$RELEASE-server-uec-$ARCH
URL=http://uec-images.ubuntu.com/$RELEASE/current/
[ ! -e $UEC_IMG.tar.gz ] &&  wget $URL/$UEC_IMG.tar.gz # This may take a bit, depending on your connectivity
  1. Next, you will need to bundle, upload and register. The cloud-utils package contains a utility named 'uec-publish-tarball' that makes this a one step process. Also available in that package is 'uec-publish-image' operates on an unpacked image rather than a tar file:
uec-publish-tarball ${UEC_IMG}.tar.gz "${RELEASE}-${TIMESTAMP}" "${ARCH}"
Alternate: The following is not needed if you've used uec-publish-tarball. It is left as documentation of the full process
  1. Unpack the UEC image tarball
[ ! -e $UEC_IMG.img ] && tar -S -xzf $UEC_IMG.tar.gz
  1. Bundle the kernel
BUCKET_KERNEL="k-$TIMESTAMP"
UEC_KERNEL=$UEC_IMG-vmlinuz-virtual
euca-bundle-image -i $UEC_KERNEL -r $IARCH --kernel true
euca-upload-bundle -b $BUCKET_KERNEL -m /tmp/$UEC_KERNEL.manifest.xml
EKI=$(euca-register $BUCKET_KERNEL/$UEC_KERNEL.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $EKI
  1. Bundle the initrd (Note: some kernels may not need a ramdisk. If no ramdisk is present, skip this step)
BUCKET_INITRD="r-$TIMESTAMP"
UEC_INITRD=$UEC_IMG-initrd-virtual
euca-bundle-image -i $UEC_INITRD -r $IARCH --ramdisk true
euca-upload-bundle -b $BUCKET_INITRD -m /tmp/$UEC_INITRD.manifest.xml
ERI=$(euca-register $BUCKET_INITRD/$UEC_INITRD.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $ERI
  1. Bundle the image itself (this can take some time)
BUCKET_IMAGE="i-$TIMESTAMP"
UEC_IMG=$RELEASE-server-uec-$ARCH
euca-bundle-image -i $UEC_IMG.img -r $IARCH --kernel $EKI ${ERI:+--ramdisk ${ERI}} # This will take a long time (~10m)
euca-upload-bundle -b $BUCKET_IMAGE -m /tmp/$UEC_IMG.img.manifest.xml
EMI=$(euca-register $BUCKET_IMAGE/$UEC_IMG.img.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $EMI
  1. Now, your kernel, ramdisk and image will have been uploaded into Eucalyptus and should be ready to run. To confirm, run the following command:
euca-describe-images

You should see a registered kernel, ramdisk and image and they should be marked as 'available'.