QA:Testcase build an OpenStack guest image with Oz
From FedoraProject
(Difference between revisions)
(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...") |
|||
| 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>f15.tdl</code> containing: | ||
| + | |||
| + | <nowiki> | ||
| + | <template> | ||
| + | <name>fedora15_x86_64</name> | ||
| + | <description>My Fedora 15 x86_64 template</description> | ||
| + | <os> | ||
| + | <name>Fedora</name> | ||
| + | <version>15</version> | ||
| + | <arch>x86_64</arch> | ||
| + | <install type='url'> | ||
| + | <url>http://download.fedoraproject.org/pub/fedora/linux/releases/15/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 f15.tdl | |
| + | |||
| + | Register the image with nova | ||
| + | |||
| + | $> sudo nova-manage image image_register /var/lib/libvirt/images/fedora15_x86_64.dsk 'admin' f15 | ||
| + | |||
|results= | |results= | ||
| − | + | ||
| − | + | Verify that the f15 image is registered with the Glance image registry | |
| − | + | ||
| − | + | $> glance index | |
}} | }} | ||
[[Category:OpenStack Test Cases]] | [[Category:OpenStack Test Cases]] | ||
[[Category:Cloud SIG]] | [[Category:Cloud SIG]] | ||
Revision as of 15:38, 19 October 2011
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 f15.tdl containing:
<template>
<name>fedora15_x86_64</name>
<description>My Fedora 15 x86_64 template</description>
<os>
<name>Fedora</name>
<version>15</version>
<arch>x86_64</arch>
<install type='url'>
<url>http://download.fedoraproject.org/pub/fedora/linux/releases/15/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 f15.tdl
Register the image with nova
$> sudo nova-manage image image_register /var/lib/libvirt/images/fedora15_x86_64.dsk 'admin' f15
Expected Results
Verify that the f15 image is registered with the Glance image registry
$> glance index