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 :instance_id, 'instanceId'
|
||||||
attribute :public_ip, 'publicIp'
|
attribute :public_ip, 'publicIp'
|
||||||
|
|
||||||
|
def addresses
|
||||||
|
@addresses
|
||||||
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
connection.release_address(@public_ip)
|
connection.release_address(@public_ip)
|
||||||
true
|
true
|
||||||
|
@ -18,6 +22,12 @@ module Fog
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def addresses=(new_addresses)
|
||||||
|
@addresses = new_addresses
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,7 @@ module Fog
|
||||||
addresses = Fog::AWS::EC2::Addresses.new(:connection => connection)
|
addresses = Fog::AWS::EC2::Addresses.new(:connection => connection)
|
||||||
data['addressesSet'].each do |address|
|
data['addressesSet'].each do |address|
|
||||||
addresses << Fog::AWS::EC2::Address.new({
|
addresses << Fog::AWS::EC2::Address.new({
|
||||||
|
:addresses => self,
|
||||||
:connection => connection
|
:connection => connection
|
||||||
}.merge!(address))
|
}.merge!(address))
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,6 +53,10 @@ module Fog
|
||||||
@key_name = new_keypair.name
|
@key_name = new_keypair.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def instances
|
||||||
|
@instances
|
||||||
|
end
|
||||||
|
|
||||||
def monitoring=(new_monitoring)
|
def monitoring=(new_monitoring)
|
||||||
if new_monitoring.is_a?(Hash)
|
if new_monitoring.is_a?(Hash)
|
||||||
@monitoring = new_monitoring['state']
|
@monitoring = new_monitoring['state']
|
||||||
|
@ -115,6 +119,10 @@ module Fog
|
||||||
@instance_state = new_instance_state['name']
|
@instance_state = new_instance_state['name']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def instances=(new_instances)
|
||||||
|
@instances = new_instances
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
||||||
instances = Fog::AWS::EC2::Instances.new(:connection => connection)
|
instances = Fog::AWS::EC2::Instances.new(:connection => connection)
|
||||||
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,
|
||||||
|
:instances => self
|
||||||
}.merge!(instance))
|
}.merge!(instance))
|
||||||
end
|
end
|
||||||
instances
|
instances
|
||||||
|
|
|
@ -13,6 +13,10 @@ module Fog
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def key_pairs
|
||||||
|
@key_pairs
|
||||||
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
data = connection.create_key_pair(@name).body
|
data = connection.create_key_pair(@name).body
|
||||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||||
|
@ -20,6 +24,12 @@ module Fog
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def key_pairs=(new_key_pairs)
|
||||||
|
@key_pairs = new_key_pairs
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
||||||
key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
|
key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
|
||||||
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,
|
||||||
|
:key_pairs => self
|
||||||
}.merge!(key))
|
}.merge!(key))
|
||||||
end
|
end
|
||||||
key_pairs
|
key_pairs
|
||||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
||||||
security_groups = Fog::AWS::EC2::SecurityGroups.new(:connection => connection)
|
security_groups = Fog::AWS::EC2::SecurityGroups.new(:connection => connection)
|
||||||
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,
|
||||||
|
:security_groups => self
|
||||||
}.merge!(security_group))
|
}.merge!(security_group))
|
||||||
end
|
end
|
||||||
security_groups
|
security_groups
|
||||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
||||||
snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
|
snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
|
||||||
data['snapshotSet'].each do |snapshot|
|
data['snapshotSet'].each do |snapshot|
|
||||||
snapshots << Fog::AWS::EC2::Snapshot.new({
|
snapshots << Fog::AWS::EC2::Snapshot.new({
|
||||||
:connection => connection
|
:connection => connection,
|
||||||
|
:snapshots => self
|
||||||
}.merge!(snapshot))
|
}.merge!(snapshot))
|
||||||
end
|
end
|
||||||
snapshots
|
snapshots
|
||||||
|
|
|
@ -42,6 +42,16 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def volumes
|
||||||
|
@volumes
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def volumes=(new_volumes)
|
||||||
|
@volumes = new_volumes
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
||||||
volumes = Fog::AWS::EC2::Volumes.new(:connection => connection)
|
volumes = Fog::AWS::EC2::Volumes.new(:connection => connection)
|
||||||
data['volumeSet'].each do |volume|
|
data['volumeSet'].each do |volume|
|
||||||
volumes << Fog::AWS::EC2::Volume.new({
|
volumes << Fog::AWS::EC2::Volume.new({
|
||||||
:connection => connection
|
:connection => connection,
|
||||||
|
:volumes => self
|
||||||
}.merge!(volume))
|
}.merge!(volume))
|
||||||
end
|
end
|
||||||
volumes
|
volumes
|
||||||
|
|
Loading…
Add table
Reference in a new issue