mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add collection references to ec2 models
This commit is contained in:
parent
528fdb4ed3
commit
a9797d45a5
10 changed files with 49 additions and 5 deletions
|
@ -7,6 +7,10 @@ module Fog
|
|||
attribute :instance_id, 'instanceId'
|
||||
attribute :public_ip, 'publicIp'
|
||||
|
||||
def addresses
|
||||
@addresses
|
||||
end
|
||||
|
||||
def delete
|
||||
connection.release_address(@public_ip)
|
||||
true
|
||||
|
@ -18,6 +22,12 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def addresses=(new_addresses)
|
||||
@addresses = new_addresses
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,6 +13,7 @@ module Fog
|
|||
addresses = Fog::AWS::EC2::Addresses.new(:connection => connection)
|
||||
data['addressesSet'].each do |address|
|
||||
addresses << Fog::AWS::EC2::Address.new({
|
||||
:addresses => self,
|
||||
:connection => connection
|
||||
}.merge!(address))
|
||||
end
|
||||
|
|
|
@ -53,6 +53,10 @@ module Fog
|
|||
@key_name = new_keypair.name
|
||||
end
|
||||
|
||||
def instances
|
||||
@instances
|
||||
end
|
||||
|
||||
def monitoring=(new_monitoring)
|
||||
if new_monitoring.is_a?(Hash)
|
||||
@monitoring = new_monitoring['state']
|
||||
|
@ -115,6 +119,10 @@ module Fog
|
|||
@instance_state = new_instance_state['name']
|
||||
end
|
||||
|
||||
def instances=(new_instances)
|
||||
@instances = new_instances
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
instances = Fog::AWS::EC2::Instances.new(:connection => connection)
|
||||
data['instancesSet'].each do |instance|
|
||||
instances << Fog::AWS::EC2::Instances.new({
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:instances => self
|
||||
}.merge!(instance))
|
||||
end
|
||||
instances
|
||||
|
|
|
@ -13,6 +13,10 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def key_pairs
|
||||
@key_pairs
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_key_pair(@name).body
|
||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||
|
@ -20,6 +24,12 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def key_pairs=(new_key_pairs)
|
||||
@key_pairs = new_key_pairs
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
|
||||
data['keySet'].each do |key|
|
||||
key_pairs << Fog::AWS::EC2::KeyPair.new({
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:key_pairs => self
|
||||
}.merge!(key))
|
||||
end
|
||||
key_pairs
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
security_groups = Fog::AWS::EC2::SecurityGroups.new(:connection => connection)
|
||||
data['securityGroupInfo'].each do |security_group|
|
||||
security_groups << Fog::AWS::EC2::SecurityGroup.new({
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:security_groups => self
|
||||
}.merge!(security_group))
|
||||
end
|
||||
security_groups
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
|
||||
data['snapshotSet'].each do |snapshot|
|
||||
snapshots << Fog::AWS::EC2::Snapshot.new({
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:snapshots => self
|
||||
}.merge!(snapshot))
|
||||
end
|
||||
snapshots
|
||||
|
|
|
@ -42,6 +42,16 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def volumes
|
||||
@volumes
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def volumes=(new_volumes)
|
||||
@volumes = new_volumes
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
volumes = Fog::AWS::EC2::Volumes.new(:connection => connection)
|
||||
data['volumeSet'].each do |volume|
|
||||
volumes << Fog::AWS::EC2::Volume.new({
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:volumes => self
|
||||
}.merge!(volume))
|
||||
end
|
||||
volumes
|
||||
|
|
Loading…
Add table
Reference in a new issue