Sha256: 9e4c2cde23390cb390bb5a2cdc05e56692d1caa89522ae41142abb098ed1e90a

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

module EY
  module Metadata
    # This gets pulled in when you're running directly on a cloud instance.
    module Insider
      DELEGATED_TO_AMAZON_EC2_API = %w{
        present_instance_id
        present_security_group
      }
    
      DELEGATED_TO_CHEF_DNA = KEYS - DELEGATED_TO_AMAZON_EC2_API

      DELEGATED_TO_AMAZON_EC2_API.each do |name|
        define_method name do
          amazon_ec2_api.send name
        end
      end

      DELEGATED_TO_CHEF_DNA.each do |name|
        define_method name do
          chef_dna.send name
        end
      end
      
      def clear
        @chef_dna = nil
        @amazon_ec2_api = nil
      end
      
      # An adapter that reads from the EngineYard AppCloud /etc/chef/dna.json file.
      def chef_dna
        @chef_dna ||= ChefDna.new
      end

      # An adapter that reads from Amazon's EC2 API.
      def amazon_ec2_api
        @amazon_ec2_api ||= AmazonEc2Api.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engineyard-metadata-0.1.0 lib/engineyard-metadata/insider.rb