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

#active_instances_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 active_instances_with_tag(tag)
  matches = []
  active_instances.each do |ai|
    matches.push ai unless !ai.match?(tag)
  end
  return matches
end

#identity_instanceObject

Return an instance object for this machine.



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

def identity_instance
  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
end

#launch_timeObject

Deprecated. Will be removed in the next couple versions.

Please use identity_instance.launch_time


51
52
53
# File 'lib/ec2-instance.rb', line 51

def launch_time
  identity_instance.launch_time
end