1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/bin/fog

81 lines
1.6 KiB
Text
Raw Normal View History

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-15 01:03:31 -04:00
def credentials
@credentials ||= begin
if ARGV[0] && File.exists?(File.expand_path(ARGV[0]))
YAML.load(File.open(File.expand_path(ARGV[0])).read)
elsif File.exists?(File.expand_path('~/.fog'))
YAML.load(File.open(File.expand_path('~/.fog')).read)
end
end
2009-10-02 02:22:47 -04:00
end
2009-10-15 01:03:31 -04:00
module AWS
class << self
2009-10-08 02:45:33 -04:00
2009-10-15 01:03:31 -04:00
@@ec2 = Fog::AWS::EC2.new(
:aws_access_key_id => credentials[:aws_access_key_id],
:aws_secret_access_key => credentials[:aws_secret_access_key]
)
2009-10-02 02:22:47 -04:00
2009-10-15 01:03:31 -04:00
@@s3 = Fog::AWS::S3.new(
:aws_access_key_id => credentials[:aws_access_key_id],
:aws_secret_access_key => credentials[:aws_secret_access_key]
)
2009-10-08 02:45:33 -04:00
2009-10-15 01:03:31 -04:00
def addresses
@@ec2.addresses
end
2009-10-02 02:22:47 -04:00
2009-10-15 01:03:31 -04:00
def buckets
@@s3.buckets
end
2009-10-09 02:01:09 -04:00
2009-10-15 01:03:31 -04:00
def instances
@@ec2.instances
end
2009-10-08 02:45:33 -04:00
2009-10-15 01:03:31 -04:00
def key_pairs
@@ec2.key_pairs
end
2009-10-08 02:45:33 -04:00
2009-10-15 01:03:31 -04:00
def security_groups
@@ec2.security_groups
end
def snapshots
@@ec2.snapshots
end
def volumes
@@ec2.volumes
end
end
2009-10-08 02:45:33 -04:00
end
2009-10-15 01:03:31 -04:00
module Rackspace
class << self
@@servers = Fog::Rackspace::Servers.new(
:rackspace_api_key => credentials[:rackspace_api_key],
:rackspace_username => credentials[:rackspace_username]
)
def servers
@@servers.servers
end
end
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 }