mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
37 lines
854 B
Ruby
37 lines
854 B
Ruby
|
module Fog
|
||
|
module AWS
|
||
|
class EC2
|
||
|
|
||
|
def instances
|
||
|
Fog::AWS::EC2::Instances.new(:connection => self)
|
||
|
end
|
||
|
|
||
|
class Instances < Fog::Collection
|
||
|
|
||
|
def all(instance_id = [])
|
||
|
data = connection.describe_instances(instance_id)
|
||
|
instances = Fog::AWS::EC2::Instances.new(:connection => connection)
|
||
|
data['instancesSet'].each do |instance|
|
||
|
instances << Fog::AWS::EC2::Instances.new({
|
||
|
:connection => connection
|
||
|
}.merge!(instance))
|
||
|
end
|
||
|
instances
|
||
|
end
|
||
|
|
||
|
def create(attributes = {})
|
||
|
instance = new(attributes)
|
||
|
instance.save
|
||
|
instance
|
||
|
end
|
||
|
|
||
|
def new(attributes = {})
|
||
|
Fog::AWS::EC2::Instance.new(attributes.merge!(:connection => connection))
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
end
|