QA:Testcase build an OpenStack guest image with Oz

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
m (Updated (i.e. simplified) setup instructions to reflect F16/F17 status)
 
(3 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
  $> sudo yum install oz
 
  $> sudo yum install oz
  
Create a template definition file called <code>f15.tdl</code> containing:
+
Create a template definition file called <code>f16-jeos.tdl</code> containing:
  
 
  <nowiki>
 
  <nowiki>
 
<template>
 
<template>
  <name>fedora15_x86_64</name>
+
  <name>fedora16_x86_64</name>
  <description>My Fedora 15 x86_64 template</description>
+
  <description>My Fedora 16 x86_64 template</description>
 
  <os>
 
  <os>
 
   <name>Fedora</name>
 
   <name>Fedora</name>
   <version>15</version>
+
   <version>16</version>
 
   <arch>x86_64</arch>
 
   <arch>x86_64</arch>
 
   <install type='url'>
 
   <install type='url'>
     <url>http://download.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/os/</url>
+
     <url>http://download.fedoraproject.org/pub/fedora/linux/releases/16/Fedora/x86_64/os/</url>
 
   </install>
 
   </install>
 
  </os>
 
  </os>
Line 62: Line 62:
 
Build the guest image
 
Build the guest image
  
  $> sudo oz-install -d4 -u f15.tdl
+
  $> sudo oz-install -d4 -u f16-jeos.tdl
  
 
Register the image with nova
 
Register the image with nova
  
  $> sudo nova-manage image image_register /var/lib/libvirt/images/fedora15_x86_64.dsk 'admin' f15
+
  $> sudo nova-manage image image_register /var/lib/libvirt/images/fedora16_x86_64.dsk 'admin' f16-jeos
  
 
|results=
 
|results=
  
Verify that the f15 image is registered with the Glance image registry
+
Verify that the f16-jeos image is registered with the Glance image registry
  
 
  $> glance index
 
  $> glance index
Line 76: Line 76:
  
 
[[Category:OpenStack Test Cases]]
 
[[Category:OpenStack Test Cases]]
[[Category:Cloud SIG]]
 

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