Class: AWS::EC2::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2-instance.rb

Instance Method Summary collapse

Instance Method Details

#active_instancesObject

Returns an array of instance ids which have a running or pending status



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ec2-instance.rb', line 14

def active_instances
  instances = []

  parse_instance_set(self.describe_instances).each do |instance|
    if instance.status == "running" || instance.status == "pending"
      instances.push instance
    end
  end 
 
  return instances
end

#instances_active_with_tag(tag) ⇒ Object

Return a list of active instances which have a tag value which regexp matches.



29
30
31
32
33
34
35
# File 'lib/ec2-instance.rb', line 29

def instances_active_with_tag(tag)
  matches = []
  active_instances.each do |ai|
    matches.push ai unless !ai.match?(tag)
  end
  return matches
end

#launch_timeObject

Return the launch time of this machine.



40
41
42
43
44
45
46
# File 'lib/ec2-instance.rb', line 40

def launch_time
  local_instance = parse_instance_set(self.describe_instances).detect do |inst|
    inst.instance_id.eql? AWS::EC2::Instance.local_instance_id
  end

  return local_instance.launch_time
end