From Fedora Project Wiki
(Created page with "{{QA/Test_Case |description=A brief description of the functionality being tested. |setup=Optionally include information on preparing the test environment |actions= Be as specifi...") |
m (Updated (i.e. simplified) setup instructions to reflect F16/F17 status) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{QA/Test_Case | {{QA/Test_Case | ||
|description= | |description=Building an Image With Oz | ||
|setup= | |||
[http://www.aeolusproject.org/oz.html 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 <code>f16-jeos.tdl</code> containing: | |||
<nowiki> | |||
<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> | |||
</nowiki> | |||
|actions= | |actions= | ||
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 | |||
|results= | |results= | ||
Verify that the f16-jeos image is registered with the Glance image registry | |||
$> glance index | |||
}} | }} | ||
[[Category:OpenStack Test Cases]] | [[Category:OpenStack Test Cases]] | ||
Latest revision as of 14:17, 20 July 2012
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 << 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