Accessing Instance Metadata

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

  1. Eucalyptus up and running (in any networking mode)
  2. ssh access to running instances
  3. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值