Class: VGH::EC2::MetaData
- Inherits:
-
Object
- Object
- VGH::EC2::MetaData
- Defined in:
- lib/vgh/ec2/metadata.rb
Overview
This class gathers metadata information about the current instance, used by the applications in this gem.
Usage
data = Metadata.new
id = data.instance_id
root = data.root_device
Instance Method Summary collapse
-
#instance_id ⇒ String?
Query the API server for the instance ID.
-
#root_device ⇒ String?
Query the API server for the root device.
Instance Method Details
#instance_id ⇒ String?
Query the API server for the instance ID
33 34 35 36 37 38 39 |
# File 'lib/vgh/ec2/metadata.rb', line 33 def instance_id begin @instance_id = open('http://instance-data/latest/meta-data/instance-id').read rescue .fatal 'Could not get Instance ID!' end end |
#root_device ⇒ String?
Query the API server for the root device
43 44 45 46 47 48 49 |
# File 'lib/vgh/ec2/metadata.rb', line 43 def root_device begin @root_device = open('http://instance-data/latest/meta-data/block-device-mapping/root').read rescue .fatal 'Could not get the root device!' end end |