2009-10-02 02:22:47 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
|
|
|
|
require 'irb'
|
|
|
|
require 'yaml'
|
|
|
|
|
2009-10-05 17:53:33 -04:00
|
|
|
if ARGV[0] && File.exists?(File.expand_path(ARGV[0]))
|
|
|
|
@credentials = YAML.load(File.open(File.expand_path(ARGV[0])).read)
|
|
|
|
elsif File.exists?(File.expand_path('~/.fog'))
|
2009-10-02 02:22:47 -04:00
|
|
|
@credentials = YAML.load(File.open(File.expand_path('~/.fog')).read)
|
|
|
|
end
|
|
|
|
|
2009-10-10 20:27:02 -04:00
|
|
|
def ec2
|
|
|
|
@ec2 = Fog::AWS::EC2.new(
|
|
|
|
:aws_access_key_id => @credentials[:aws_access_key_id],
|
|
|
|
:aws_secret_access_key => @credentials[:aws_secret_access_key]
|
|
|
|
)
|
|
|
|
end
|
2009-10-08 02:45:33 -04:00
|
|
|
|
2009-10-10 20:27:02 -04:00
|
|
|
def s3
|
|
|
|
@s3 = Fog::AWS::S3.new(
|
|
|
|
:aws_access_key_id => @credentials[:aws_access_key_id],
|
|
|
|
:aws_secret_access_key => @credentials[:aws_secret_access_key]
|
|
|
|
)
|
|
|
|
end
|
2009-10-02 02:22:47 -04:00
|
|
|
|
2009-10-08 02:45:33 -04:00
|
|
|
def addresses
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.addresses
|
2009-10-08 02:45:33 -04:00
|
|
|
end
|
|
|
|
|
2009-10-02 02:22:47 -04:00
|
|
|
def buckets
|
2009-10-10 20:27:02 -04:00
|
|
|
s3.buckets
|
2009-10-02 02:22:47 -04:00
|
|
|
end
|
|
|
|
|
2009-10-09 02:01:09 -04:00
|
|
|
def instances
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.instances
|
2009-10-09 02:01:09 -04:00
|
|
|
end
|
|
|
|
|
2009-10-08 02:45:33 -04:00
|
|
|
def key_pairs
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.key_pairs
|
2009-10-08 02:45:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def security_groups
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.security_groups
|
2009-10-08 02:45:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def snapshots
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.snapshots
|
2009-10-08 02:45:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def volumes
|
2009-10-10 20:27:02 -04:00
|
|
|
ec2.volumes
|
2009-10-08 02:45:33 -04:00
|
|
|
end
|
|
|
|
|
2009-10-02 02:22:47 -04:00
|
|
|
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 }
|