The following method was tested using OpenSUSE 11.4 on Diablo version of OpenStack. The OpenStack cloud was setup using the procedure given in the following link.
Create a raw image which emulates the Hard Drive.
kvm-img create -f qcow2 opensuse.img 5G
Start the Virtual Machine booting from the CD using the following command.
kvm -m 256 -cdrom openSUSE-11.4-DVD-x86_64.iso -drive file=opensuse.img,if=virtio,index=0 -boot d -net nic -net user -nographic -vnc :1
Connect to the Virtual Machine through VNC (use display number :1).For Example, where 10.10.10.1 is the IP address of the host machine.
vncviewer 10.10.10.1 :1
Select SSH server, Curl and other packages needed, during installation. Once the installation is over shutdown the Virtual Machine. Start the Virtual Machine to boot from the Hard Drive using the following command.
kvm -m 256 -drive file=opensuse.img,if=virtio,index=0,boot=on -boot c -net nic -net user -nographic -vnc :1
Install SSH server
zypper install openssh
zypper install curl
For SSH Key injection into the instance use the following steps:
Create a file /etc/init.d/sshkey and add the following lines
echo >> /root/.ssh/authorized_keys curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /root/.ssh/authorized_keys echo "AUTHORIZED_KEYS:" echo "************************" cat /root/.ssh/authorized_keys echo "************************"
Change the permissions for the file
chmod 755 /etc/init.d/sshkey
Configure the service to start automatically while booting
chkconfig sshkey on
Configure the firewall (Not iptables) using the following command and allow ssh service
Also remove the network persistence rules from /etc/udev/rules.d as their presence will result in the network interface in the instance coming up as an interface other than eth0.
rm -rf /etc/udev/rules.d/70-persistent-net.rules
Shutdown the Virtual Machine. Upload the image to OpenStack using the following command
cloud-publish-image amd64 opensuse.img opensusebucket
The following output shows that the image has been successfully uploaded.
Start the instance with the image that was uploaded.
euca-run-instances ami-00000001 -k mykey -t m1.tiny