Class: Rudy::AWS::EC2::Instance

Inherits:
Storable
  • Object
show all
Defined in:
lib/rudy/aws/ec2/instance.rb

Constant Summary collapse

@@sformat =
"   -> %10s; %10s; %12s; %10s; groups: %s"

Instance Method Summary collapse

Instance Method Details

#degraded?Boolean

Returns:

  • (Boolean)


63
# File 'lib/rudy/aws/ec2/instance.rb', line 63

def degraded?; self.state && self.state == 'degraded'; end

#initObject



22
23
24
# File 'lib/rudy/aws/ec2/instance.rb', line 22

def init
  @groups ||= []
end

#inspectObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/rudy/aws/ec2/instance.rb', line 49

def inspect
  lines = []
  lines << liner_note
  field_names.each do |key|
    next unless self.respond_to?(key)
    val = self.send(key)
    lines << sprintf(" %22s: %s", key, (val.is_a?(Array) ? val.join(', ') : val))
  end
  lines.join($/)
end

#liner_noteObject



26
27
28
29
# File 'lib/rudy/aws/ec2/instance.rb', line 26

def liner_note
  info = self.running? ? self.dns_public : self.state
  "%s  %-30s" % [self.awsid.bright, info]
end

#pending?Boolean

Returns:

  • (Boolean)


61
# File 'lib/rudy/aws/ec2/instance.rb', line 61

def pending?; self.state && self.state == 'pending'; end

#running?Boolean

Returns:

  • (Boolean)


60
# File 'lib/rudy/aws/ec2/instance.rb', line 60

def running?; self.state && self.state == 'running'; end

#shutting_down?Boolean

Returns:

  • (Boolean)


64
# File 'lib/rudy/aws/ec2/instance.rb', line 64

def shutting_down?; self.state && self.state == 'shutting-down'; end

#terminated?Boolean

Returns:

  • (Boolean)


62
# File 'lib/rudy/aws/ec2/instance.rb', line 62

def terminated?; self.state && self.state == 'terminated'; end

#to_s(with_title = false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rudy/aws/ec2/instance.rb', line 31

def to_s(with_title=false)
  lines = []
  if @groups
    gpstr = [@groups].flatten.compact.join(', ')
    gpstr &&= "(#{gpstr})"
  else
    gpstr = ''
  end
  
  lines << "%s  %s" % [liner_note, gpstr]
  #if self.running?
  #  k, g = @keyname || 'no-keypair', self.groups.join(', ')
  #  lines << @@sformat % %w{zone size ami keyname groups} if with_title
  #  lines << @@sformat % [@zone, @size, @ami, k, g]
  #end
  lines.join($/)
end