This document shows you how to access instance-specific metadata from inside a running virtual machine. You can access instance metadata in all Eucalyptus networking modes. However, the way you access the metadata service from within a VM differs depending on the networking mode used to configure your Eucalyptus installation. (For information on configuring Eucalyptus networking modes, see our Eucalyptus Network Configuration Guide.)
If your system is configured using MANAGED or MANAGED-NOVLAN modes, then the metadata service is available to VMs just as in Amazon EC2 as shown:
http://169.254.169.254/
If your system is configured using SYSTEM or STATIC networking modes, then retrieving data requires the IP (or hostname) and port number of the Eucalyptus Cloud Controller (CLC):
http:// :8773/
(We recommend that you set up a DNS entry for each cloud controller. This way you can configure your images to access the metadata service using a DNS name, thus avoiding the need to recreate pre-configured images in the event a specific IP address changes.)
Prerequisites for accessing instance metadata
- Eucalyptus up and running (in any networking mode)
- ssh access to running instances
- Linux command-line tools - curl, wget
Accessing metadata via curl/wget
The following example shows you how to access the metadata service from within a running VM with Eucalyptus configured in either MANAGED or MANAGED-NOVLAN networking mode. (Note that for the rest of the document we'll be using '169.254.169.254' as the meta-data service IP address. If you're in SYSTEM or STATIC mode, substitute your cloud controller IP and port as explained above.)
To access the instance metadata you must first log into the running instance. For example:
-bash-3.2$ ssh -i mykey.private root@192.168.39.65
Once you are logged into the running instance, you can use curl or wget to retrieve instance metadata at http://169.254.169.254. For example, to access the top-level metadata items, we will use curl to grab that information:
-bash-3.2# curl http://169.254.169.254/latest/meta-data/ block-device-mapping/ security-groups ami-manifest-path ancestor-ami-ids public-keys/ reservation-id ramdisk-id public-keys/0/ ami-launch-index kernel-id instance-type local-hostname local-ipv4 hostname product-codes public-ipv4 instance-id public-hostname ami-id placement/
As you can see, there are a lot of items. For example, if you want to see the format of your public key, you would run the following command:
-bash-3.2# curl http://169.254.169.254/latest/meta-data/public-keys/0/ openssh-key
Or, if you want to see the instance-id, you would run the following:
-bash-3.2# curl http://169.254.169.254/latest/meta-data/instance-id i-4C5E0827
Please note that the URL in the above example (http://169.254.169.254) is used for accessing the metadata service in MANAGED and MANAGED-NOVLAN modes only. To retrieve instance metadata in SYSTEM and STATIC mode, you must use the IP (or hostname) and port number of the Eucalyptus Cloud Controller (CLC) (http:// :8773/ ).
To see more examples of how to access metadata on running instances, refer to theAmazon's EC2 Instance Metadata documentation.
To find out all the metadata categories available, refer to Amazon's EC2 Metadata Categories documentation.
EC2 Instance Metadata Query Tool
Another way of checking out the metadata on a running instance is to download EC2 Instance Metadata Query Tool. Just copy this script onto your running instance, and you have a script that you can run to grab the information that is available.
Enjoy!
from : http://open.eucalyptus.com/participate/wiki/accessing-instance-metadata