1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

fill in other collection methods on ec2 models

This commit is contained in:
Wesley Beary 2009-09-25 09:01:51 -07:00
parent 2b7266ede3
commit f7ca218923
3 changed files with 48 additions and 3 deletions

View file

@ -8,9 +8,14 @@ module Fog
class Instances < Fog::Collection
attribute :instance_id
def all(instance_id = [])
data = connection.describe_instances(instance_id)
instances = Fog::AWS::EC2::Instances.new(:connection => connection)
instances = Fog::AWS::EC2::Instances.new(
:connection => connection,
:instance_id => instance_id
)
data['instancesSet'].each do |instance|
instances << Fog::AWS::EC2::Instances.new({
:connection => connection,
@ -26,6 +31,12 @@ module Fog
instance
end
def get(instance_id)
all(instance_id).first
rescue Fog::Errors::BadRequest
nil
end
def new(attributes = {})
Fog::AWS::EC2::Instance.new(
attributes.merge!(
@ -35,6 +46,10 @@ module Fog
)
end
def reload
all(instance_id)
end
end
end

View file

@ -8,9 +8,14 @@ module Fog
class KeyPairs < Fog::Collection
attribute :key_name
def all(key_name = [])
data = connection.describe_key_pairs(key_name).body
key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
key_pairs = Fog::AWS::EC2::KeyPairs.new(
:connection => connection,
:key_name => key_name
)
data['keySet'].each do |key|
key_pairs << Fog::AWS::EC2::KeyPair.new({
:connection => connection,
@ -26,6 +31,12 @@ module Fog
bucket
end
def get(key_name)
all(key_name).first
rescue Fog::Errors::BadRequest
nil
end
def new(attributes = {})
Fog::AWS::EC2::KeyPair.new(
attributes.merge!(
@ -35,6 +46,10 @@ module Fog
)
end
def reload
all(key_name)
end
end
end

View file

@ -8,9 +8,14 @@ module Fog
class SecurityGroups < Fog::Collection
attribute :group_name
def all(group_name = [])
data = connection.describe_security_groups(group_name)
security_groups = Fog::AWS::EC2::SecurityGroups.new(:connection => connection)
security_groups = Fog::AWS::EC2::SecurityGroups.new(
:connection => connection,
:group_name => group_name
)
data['securityGroupInfo'].each do |security_group|
security_groups << Fog::AWS::EC2::SecurityGroup.new({
:connection => connection,
@ -26,6 +31,12 @@ module Fog
security_group
end
def get(group_name)
all(group_name).first
rescue Fog::Errors::BadRequest
nil
end
def new(attributes = {})
Fog::AWS::EC2::SecurityGroup.new(
attributes.merge!(
@ -35,6 +46,10 @@ module Fog
)
end
def reload
all(group_name)
end
end
end