I wrote a script to download the OpenStack metadata at the boot time. But the downloaded file was empty. But when I executed wget after booting it downloaded the metadata file. So I added the following to the script file to wait for the metadata service.
#!/bin/bash while ! wget --spider http://169.254.169.254/latest/user-data 2>&1 | grep --quiet "200 OK" do echo "Not available" sleep 2 done
But later I found out that the reason for not downloading metadata :). The VM Operating System was SUSE and I executed the script from boot.local (/etc/init.d/boot.local In other operating systems I add the script to rc.local). And this boot.local runs in run level 2 (with no networking :D). You can find out more about run levels from here.