Sha256: 11eb0d35c7140d02a083e4b5b063db6f4fe66b261f453f3815fcda7d1f156c51

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

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
      
      # You can't get the list of environment names while you're on the instances themselves.
      def environment_names
        raise CannotGetFromHere
      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

2 entries across 2 versions & 1 rubygems

Version Path
engineyard-metadata-0.1.2 lib/engineyard-metadata/insider.rb
engineyard-metadata-0.1.1 lib/engineyard-metadata/insider.rb