QA:Testcase build an OpenStack guest image with Oz

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(remove from cloud SIG category)
m (Updated (i.e. simplified) setup instructions to reflect F16/F17 status)
 
Line 6: Line 6:
 
|setup=Install the oz image builder
 
|setup=Install the oz image builder
  
$> host=repos.fedorapeople.org
+
  $> sudo yum install oz
$> file=oz-0.8.0-1.fc15.noarch.rpm
+
  $> sudo yum install http://$host/repos/aeolus/oz/0.8.0/packages/fedora-15/x86_64/$file
+
  
 
Create a template definition file called <code>f16-jeos.tdl</code> containing:
 
Create a template definition file called <code>f16-jeos.tdl</code> containing:

Latest revision as of 14:17, 20 July 2012

Contents

Description

Building an Image With Oz

oz is a tool for automatically installing guest OSs with only minimal up-front input from the user.

Setup

Install the oz image builder

$> sudo yum install oz

Create a template definition file called f16-jeos.tdl containing:

<template>
 <name>fedora16_x86_64</name>
 <description>My Fedora 16 x86_64 template</description>
 <os>
  <name>Fedora</name>
  <version>16</version>
  <arch>x86_64</arch>
  <install type='url'>
    <url>http://download.fedoraproject.org/pub/fedora/linux/releases/16/Fedora/x86_64/os/</url>
  </install>
 </os>
 <commands>
   <command name='setup-rc-local'>
sed -i 's/rhgb quiet/console=ttyS0/' /boot/grub/grub.conf
 
cat >> /etc/rc.local &lt;&lt; EOF
if [ ! -d /root/.ssh ]; then
  mkdir -p /root/.ssh
  chmod 700 /root/.ssh
fi
 
# Fetch public key using HTTP
ATTEMPTS=10
while [ ! -f /root/.ssh/authorized_keys ]; do
    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
    if [ \$? -eq 0 ]; then
        cat /tmp/aws-key >> /root/.ssh/authorized_keys
        chmod 0600 /root/.ssh/authorized_keys
        restorecon /root/.ssh/authorized_keys
        rm -f /tmp/aws-key
        echo "Successfully retrieved AWS public key from instance metadata"
    else
        FAILED=\$((\$FAILED + 1))
        if [ \$FAILED -ge \$ATTEMPTS ]; then
            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
            break
        fi
        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
        sleep 5
    fi
done
EOF
   </command>
 </commands>
</template>
  

How to test

Build the guest image

$> sudo oz-install -d4 -u f16-jeos.tdl

Register the image with nova

$> sudo nova-manage image image_register /var/lib/libvirt/images/fedora16_x86_64.dsk 'admin' f16-jeos

Expected Results

Verify that the f16-jeos image is registered with the Glance image registry

$> glance index