Sha256: 11d82edfd17012987ac7142c8738e3173dcd941aa6ec6a2b7b3732fd557c5be1

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

require "fog"

module Capistrano
  module Elobuff
    module Ec2
      class Server
        def initialize(fog_server, application)
          @server = fog_server
          @application = application
        end

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

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

        def id
          @server.id
        end

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

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

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

        def address
          @server.dns_name
        end

        def tags
          @server.tags
        end

        def zone
          @server.availability_zone
        end

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

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

        def terminate!
          @server.destroy
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capistrano-elobuff-0.2.5 lib/capistrano/elobuff/ec2/server.rb
capistrano-elobuff-0.2.4 lib/capistrano/elobuff/ec2/server.rb
capistrano-elobuff-0.2.3 lib/capistrano/elobuff/ec2/server.rb
capistrano-elobuff-0.2.2 lib/capistrano/elobuff/ec2/server.rb
capistrano-elobuff-0.2.1 lib/capistrano/elobuff/ec2/server.rb
capistrano-elobuff-0.2.0 lib/capistrano/elobuff/ec2/server.rb