Class: Cloudfinder::EC2::Detector
- Inherits:
-
Object
- Object
- Cloudfinder::EC2::Detector
- Defined in:
- lib/cloudfinder-ec2/detector.rb
Constant Summary collapse
- EC2_METADATA_TIMEOUT =
5
- EC2_METADATA_BASE_URL =
'http://169.254.169.254/latest/meta-data'
Instance Method Summary collapse
-
#detect_cluster ⇒ Hash
Detects the cluster for the current instance using the instance metadata service and the AWS API to fetch tags.
Instance Method Details
#detect_cluster ⇒ Hash
Detects the cluster for the current instance using the instance metadata service and the AWS API to fetch tags.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloudfinder-ec2/detector.rb', line 12 def detect_cluster result = { region: @region, instance_id: @instance_id, cluster_name: nil, cluster_role: nil } .each do |tag| if tag[:key] === CLUSTER_TAG_NAME result[:cluster_name] = tag[:value] elsif tag[:key] === ROLE_TAG_NAME result[:cluster_role] = tag[:value].to_sym end end if result[:cluster_name].nil? || result[:cluster_role].nil? result[:cluster_name] = nil result[:cluster_role] = nil end result end |