Class: Capistrano::Elobuff::Ec2::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/elobuff/ec2/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(fog_server, application) ⇒ Server

Returns a new instance of Server.



7
8
9
10
# File 'lib/capistrano/elobuff/ec2/server.rb', line 7

def initialize(fog_server, application)
  @server = fog_server
  @application = application
end

Instance Method Details

#addressObject



36
37
38
# File 'lib/capistrano/elobuff/ec2/server.rb', line 36

def address
  @server.dns_name
end

#available?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/capistrano/elobuff/ec2/server.rb', line 16

def available?
  @server.state == "running"
end

#idObject



20
21
22
# File 'lib/capistrano/elobuff/ec2/server.rb', line 20

def id
  @server.id
end

#nameObject



28
29
30
# File 'lib/capistrano/elobuff/ec2/server.rb', line 28

def name
  @server.tags["Name"]
end

#name=(string) ⇒ Object



32
33
34
# File 'lib/capistrano/elobuff/ec2/server.rb', line 32

def name=(string)
  @server.tags["Name"] = string
end

#rolesObject



48
49
50
# File 'lib/capistrano/elobuff/ec2/server.rb', line 48

def roles
  @server.tags[@application].split(",").map(&:to_sym)
end

#roles=(string) ⇒ Object



52
53
54
# File 'lib/capistrano/elobuff/ec2/server.rb', line 52

def roles=(string)
  @server.tags[@application] = string
end

#slugObject



24
25
26
# File 'lib/capistrano/elobuff/ec2/server.rb', line 24

def slug
  @server.id.gsub(/i-/, "")
end

#tagsObject



40
41
42
# File 'lib/capistrano/elobuff/ec2/server.rb', line 40

def tags
  @server.tags
end

#terminate!Object



56
57
58
# File 'lib/capistrano/elobuff/ec2/server.rb', line 56

def terminate!
  @server.destroy
end

#to_sObject



12
13
14
# File 'lib/capistrano/elobuff/ec2/server.rb', line 12

def to_s
  "%-24s%-16s%-48s%-16s%-16s%-16s%-24s%s" % [name, id, address, @server.image_id, @server.availability_zone, @server.state, @server.groups.uniq.join(","), roles.join(",")]
end

#zoneObject



44
45
46
# File 'lib/capistrano/elobuff/ec2/server.rb', line 44

def zone
  @server.availability_zone
end