Class: Capistrano::Elobuff::Ec2::Server
- Inherits:
-
Object
- Object
- Capistrano::Elobuff::Ec2::Server
- Defined in:
- lib/capistrano/elobuff/ec2/server.rb
Instance Method Summary collapse
- #address ⇒ Object
- #available? ⇒ Boolean
- #id ⇒ Object
-
#initialize(fog_server, application) ⇒ Server
constructor
A new instance of Server.
- #name ⇒ Object
- #name=(string) ⇒ Object
- #roles ⇒ Object
- #roles=(string) ⇒ Object
- #slug ⇒ Object
- #tags ⇒ Object
- #terminate! ⇒ Object
- #to_s ⇒ Object
- #zone ⇒ Object
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
#address ⇒ Object
36 37 38 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 36 def address @server.dns_name end |
#available? ⇒ Boolean
16 17 18 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 16 def available? @server.state == "running" end |
#id ⇒ Object
20 21 22 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 20 def id @server.id end |
#name ⇒ Object
28 29 30 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 28 def name @server.["Name"] end |
#name=(string) ⇒ Object
32 33 34 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 32 def name=(string) @server.["Name"] = string end |
#roles ⇒ Object
48 49 50 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 48 def roles @server.[@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.[@application] = string end |
#slug ⇒ Object
24 25 26 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 24 def slug @server.id.gsub(/i-/, "") end |
#tags ⇒ Object
40 41 42 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 40 def @server. end |
#terminate! ⇒ Object
56 57 58 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 56 def terminate! @server.destroy end |
#to_s ⇒ Object
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 |
#zone ⇒ Object
44 45 46 |
# File 'lib/capistrano/elobuff/ec2/server.rb', line 44 def zone @server.availability_zone end |