class Quandl::Sandbox::EC2

Public Class Methods

auto_retry(attempt = 3, &block) click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 5
def auto_retry(attempt = 3, &block)
  block.call
rescue => e
  Quandl::Logger.debug("auto_retry #{e} #{attempt}")
  Quandl::Sandbox::EC2.gateway_reset!
  attempt -= 1
  auto_retry(attempt, &block) if attempt > 0
end
find(uid) click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 14
def find(uid)
  instances.filter('instance-id', uid ).collect{ |i| i }.first
end
gateway() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 29
def gateway
  @gateway ||= Net::SSH::Gateway.new( gateway_host, gateway_user )  
end
gateway_host() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 37
def gateway_host
  @gateway_host ||= Quandl::Sandbox.configuration.ssh_gateway.split("@").last
end
gateway_reset!() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 22
def gateway_reset!
  @gateway.shutdown!
  @gateway = nil
rescue => err
  Quandl::Logger.error("gateway_reset! #{err}")
end
gateway_user() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 33
def gateway_user
  @gateway_user ||= Quandl::Sandbox.configuration.ssh_gateway.split("@").first
end
instances() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 18
def instances
  interface.instances.filter('subnet-id', Quandl::Sandbox.configuration.subnet_id )
end
interface() click to toggle source
# File lib/quandl/sandbox/ec2.rb, line 41
def interface
  @interface ||= AWS::EC2.new(
    access_key_id:      Quandl::Sandbox.configuration.aws_access_key_id,
    secret_access_key:  Quandl::Sandbox.configuration.aws_secret_access_key)
end