Sha256: 0952fc79685b4ec622f78ccefd293b279f43266ddf2b4d928ba32d672f9bb8e9

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require 'irb'
require 'yaml'

module AWS
  class << self
    key = (ARGV.first && :"#{ARGV.first}") || :default
    unless Fog.credentials(key)
      raise ArgumentError.new("No credentials for :#{key}")
    end
    if Fog.credentials(key)[:aws_access_key_id] && Fog.credentials(key)[:aws_secret_access_key]

      @@ec2 = Fog::AWS::EC2.new(
        :aws_access_key_id => Fog.credentials[:aws_access_key_id],
        :aws_secret_access_key => Fog.credentials[:aws_secret_access_key]
      )

      @@s3 = Fog::AWS::S3.new(
        :aws_access_key_id => Fog.credentials[:aws_access_key_id],
        :aws_secret_access_key => Fog.credentials[:aws_secret_access_key]
      )

      def addresses
        @@ec2.addresses
      end

      def buckets
        @@s3.buckets
      end

      def instances
        @@ec2.instances
      end

      def key_pairs
        @@ec2.key_pairs
      end

      def security_groups
        @@ec2.security_groups
      end

      def snapshots
        @@ec2.snapshots
      end

      def volumes
        @@ec2.volumes
      end

    end
  end
end

module Rackspace
  class << self
    key = (ARGV.first && :"#{ARGV.first}") || :default
    unless Fog.credentials(key)
      raise ArgumentError.new("No credentials for :#{key}")
    end
    if Fog.credentials(key)[:rackspace_api_key] && Fog.credentials(key)[:rackspace_username]

      @@servers = Fog::Rackspace::Servers.new(
        :rackspace_api_key => Fog.credentials[:rackspace_api_key],
        :rackspace_username => Fog.credentials[:rackspace_username]
      )

      def flavors
        @@servers.flavors
      end

      def images
        @@servers.images
      end

      def servers
        @@servers.servers
      end
      
    end
  end
end

ARGV.clear # Avoid passing args to IRB
IRB.setup(nil)
@irb = IRB::Irb.new(nil)
IRB.conf[:MAIN_CONTEXT] = @irb.context
@irb.context.workspace = IRB::WorkSpace.new(binding)
catch(:IRB_EXIT) { @irb.eval_input }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-0.0.37 bin/fog
fog-0.0.36 bin/fog