Class: Phase::Adapters::AWS::Server
- Inherits:
-
Phase::Adapters::Abstract::Server
- Object
- Phase::Adapters::Abstract::Base
- Phase::Adapters::Abstract::Server
- Phase::Adapters::AWS::Server
- Defined in:
- lib/phase/adapters/aws/server.rb
Instance Attribute Summary
Attributes inherited from Phase::Adapters::Abstract::Base
Class Method Summary collapse
-
.all ⇒ Array<AWS::Server>
All known EC2 instances.
-
.find(instance_id, options = {}) ⇒ AWS::Server
The requested EC2 instance.
-
.where(options = {}) ⇒ Array<AWS::Server>
Finds servers through the provided filter options.
Methods inherited from Phase::Adapters::Abstract::Base
Constructor Details
This class inherits a constructor from Phase::Adapters::Abstract::Base
Class Method Details
.all ⇒ Array<AWS::Server>
Returns All known EC2 instances.
8 9 10 |
# File 'lib/phase/adapters/aws/server.rb', line 8 def all where end |
.find(instance_id, options = {}) ⇒ AWS::Server
Returns The requested EC2 instance.
14 15 16 |
# File 'lib/phase/adapters/aws/server.rb', line 14 def find(instance_id, = {}) new(api.servers.get(instance_id)) end |
.where(options = {}) ⇒ Array<AWS::Server>
Finds servers through the provided filter options.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/phase/adapters/aws/server.rb', line 28 def where( = {}) filters = {} filters["vpc-id"] = .delete(:vpc_id) if .has_key?(:vpc_id) filters["tag:Name"] = .delete(:name) if .has_key?(:name) filters["instance-ids"] = .delete(:ids) if .has_key?(:ids) filters["subnet-id"] = .delete(:subnet_id) if .has_key?(:subnet_id) filters["tag:Role"] = .delete(:role) if .has_key?(:role) filters["tag:Environment"] = .delete(:environment) if .has_key?(:environment) if .any? raise ArgumentError, "Unknown filters '#{.keys.join(", ")}'!" end api.servers.all(filters).map {|server| new(server) } end |