Sha256: 81d683efbb0f0942d637d033f8d915498b3e3a9c1bfbf51b263abf97b724273d
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
module Fog module AWS class EC2 def instances Fog::AWS::EC2::Instances.new(:connection => self) end class Instances < Fog::Collection attribute :instance_id def initialize(attributes) @instance_id ||= [] super end def all(instance_id = []) data = connection.describe_instances(instance_id).body instances = Fog::AWS::EC2::Instances.new({ :connection => connection, :instance_id => instance_id }.merge!(attributes)) data['reservationSet'].each do |reservation| reservation['instancesSet'].each do |instance| instances << Fog::AWS::EC2::Instance.new({ :connection => connection, :instances => self }.merge!(instance)) end end instances end def create(attributes = {}) instance = new(attributes) instance.save instance end def get(instance_id) if instance_id all(instance_id).first end rescue Fog::Errors::BadRequest nil end def new(attributes = {}) Fog::AWS::EC2::Instance.new( attributes.merge!( :connection => connection, :instances => self ) ) end def reload all(instance_id) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems