Class: Fog::AWS::EC2::Servers
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::EC2::Servers
- Defined in:
- lib/fog/aws/models/ec2/servers.rb
Instance Method Summary collapse
- #all(server_id = @server_id) ⇒ Object
- #get(server_id) ⇒ Object
-
#initialize(attributes) ⇒ Servers
constructor
A new instance of Servers.
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #merge_attributes, model, #model, #new, #reload
Constructor Details
#initialize(attributes) ⇒ Servers
Returns a new instance of Servers.
15 16 17 18 |
# File 'lib/fog/aws/models/ec2/servers.rb', line 15 def initialize(attributes) @server_id ||= [] super end |
Instance Method Details
#all(server_id = @server_id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/aws/models/ec2/servers.rb', line 20 def all(server_id = @server_id) @server_id = server_id if @loaded clear end @loaded = true data = connection.describe_instances(server_id).body data['reservationSet'].each do |reservation| reservation['instancesSet'].each do |instance| self << new(instance.merge(:groups => reservation['groupSet'])) end end self end |
#get(server_id) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/fog/aws/models/ec2/servers.rb', line 35 def get(server_id) if server_id all(server_id).first end rescue Excon::Errors::BadRequest nil end |