module Ocular::DSL::Fog
Public Instance Methods
autoscaling()
click to toggle source
# File lib/ocular/dsl/fog.rb, line 25 def autoscaling() return ::Fog::AWS::AutoScaling.new({ :aws_access_key_id => ::Ocular::Settings::get(:aws)[:aws_access_key_id], :aws_secret_access_key => ::Ocular::Settings::get(:aws)[:aws_secret_access_key] }) end
aws()
click to toggle source
# File lib/ocular/dsl/fog.rb, line 10 def aws() if @@__aws_instance return @@__aws_instance end @@__aws_instance = ::Fog::Compute.new({ :provider => 'AWS', :aws_access_key_id => ::Ocular::Settings::get(:aws)[:aws_access_key_id], :aws_secret_access_key => ::Ocular::Settings::get(:aws)[:aws_secret_access_key] }) return @@__aws_instance end
find_server_by_id(id)
click to toggle source
# File lib/ocular/dsl/fog.rb, line 74 def find_server_by_id(id) ret = aws().servers.all("instance-id" => id) if ret.length > 1 raise "Too many matching servers by just one ip #{ip}" end if ret.length == 0 return nil end return ret.first end
find_server_by_ip(ip)
click to toggle source
# File lib/ocular/dsl/fog.rb, line 62 def find_server_by_ip(ip) ret = aws().servers.all("private-ip-address" => ip) if ret.length > 1 raise "Too many matching servers by just one ip #{ip}" end if ret.length == 0 return nil end return ret.first end
find_servers_in_autoscaling_groups(substring)
click to toggle source
# File lib/ocular/dsl/fog.rb, line 34 def find_servers_in_autoscaling_groups(substring) instances = [] for group in autoscaling.groups if group.id.include?(substring) for i in group.instances instances << aws.servers.get(i.id) end end end return instances end
get_servers_in_autoscaling_group(group_name)
click to toggle source
# File lib/ocular/dsl/fog.rb, line 48 def get_servers_in_autoscaling_group(group_name) instances = [] for group in autoscaling.groups if group.id == group_name for i in group.instances instances << aws.servers.get(i.id) end end end return instances end