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:
parent
2b7266ede3
commit
f7ca218923
3 changed files with 48 additions and 3 deletions
|
@ -8,9 +8,14 @@ module Fog
|
||||||
|
|
||||||
class Instances < Fog::Collection
|
class Instances < Fog::Collection
|
||||||
|
|
||||||
|
attribute :instance_id
|
||||||
|
|
||||||
def all(instance_id = [])
|
def all(instance_id = [])
|
||||||
data = connection.describe_instances(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|
|
data['instancesSet'].each do |instance|
|
||||||
instances << Fog::AWS::EC2::Instances.new({
|
instances << Fog::AWS::EC2::Instances.new({
|
||||||
:connection => connection,
|
:connection => connection,
|
||||||
|
@ -26,6 +31,12 @@ module Fog
|
||||||
instance
|
instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(instance_id)
|
||||||
|
all(instance_id).first
|
||||||
|
rescue Fog::Errors::BadRequest
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
Fog::AWS::EC2::Instance.new(
|
Fog::AWS::EC2::Instance.new(
|
||||||
attributes.merge!(
|
attributes.merge!(
|
||||||
|
@ -35,6 +46,10 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload
|
||||||
|
all(instance_id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,9 +8,14 @@ module Fog
|
||||||
|
|
||||||
class KeyPairs < Fog::Collection
|
class KeyPairs < Fog::Collection
|
||||||
|
|
||||||
|
attribute :key_name
|
||||||
|
|
||||||
def all(key_name = [])
|
def all(key_name = [])
|
||||||
data = connection.describe_key_pairs(key_name).body
|
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|
|
data['keySet'].each do |key|
|
||||||
key_pairs << Fog::AWS::EC2::KeyPair.new({
|
key_pairs << Fog::AWS::EC2::KeyPair.new({
|
||||||
:connection => connection,
|
:connection => connection,
|
||||||
|
@ -26,6 +31,12 @@ module Fog
|
||||||
bucket
|
bucket
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(key_name)
|
||||||
|
all(key_name).first
|
||||||
|
rescue Fog::Errors::BadRequest
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
Fog::AWS::EC2::KeyPair.new(
|
Fog::AWS::EC2::KeyPair.new(
|
||||||
attributes.merge!(
|
attributes.merge!(
|
||||||
|
@ -35,6 +46,10 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload
|
||||||
|
all(key_name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,9 +8,14 @@ module Fog
|
||||||
|
|
||||||
class SecurityGroups < Fog::Collection
|
class SecurityGroups < Fog::Collection
|
||||||
|
|
||||||
|
attribute :group_name
|
||||||
|
|
||||||
def all(group_name = [])
|
def all(group_name = [])
|
||||||
data = connection.describe_security_groups(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|
|
data['securityGroupInfo'].each do |security_group|
|
||||||
security_groups << Fog::AWS::EC2::SecurityGroup.new({
|
security_groups << Fog::AWS::EC2::SecurityGroup.new({
|
||||||
:connection => connection,
|
:connection => connection,
|
||||||
|
@ -26,6 +31,12 @@ module Fog
|
||||||
security_group
|
security_group
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(group_name)
|
||||||
|
all(group_name).first
|
||||||
|
rescue Fog::Errors::BadRequest
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
Fog::AWS::EC2::SecurityGroup.new(
|
Fog::AWS::EC2::SecurityGroup.new(
|
||||||
attributes.merge!(
|
attributes.merge!(
|
||||||
|
@ -35,6 +46,10 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload
|
||||||
|
all(group_name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue