mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fix up collections/reloads
This commit is contained in:
parent
a9797d45a5
commit
2c68ac75af
6 changed files with 40 additions and 24 deletions
|
@ -16,6 +16,11 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def reload
|
||||
new_attributes = addresses.all(@public_ip).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.allocate_address
|
||||
@public_ip = data.body['publicIp']
|
||||
|
|
|
@ -73,13 +73,9 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def volumes
|
||||
connection.volumes.all.select {|volume| volume.instance_id == @instance_id}
|
||||
end
|
||||
|
||||
def volume=(new_volume)
|
||||
new_volume.instance_id = @instance_id
|
||||
connection.attach_volume(@instance_id, new_volume.volume_id, new_volume.device)
|
||||
def reload
|
||||
new_attributes = instances.all(@instance_id).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
|
@ -113,6 +109,15 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def volumes
|
||||
connection.volumes.all.select {|volume| volume.instance_id == @instance_id}
|
||||
end
|
||||
|
||||
def volume=(new_volume)
|
||||
new_volume.instance_id = @instance_id
|
||||
connection.attach_volume(@instance_id, new_volume.volume_id, new_volume.device)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def instance_state=(new_instance_state)
|
||||
|
|
|
@ -17,6 +17,11 @@ module Fog
|
|||
@key_pairs
|
||||
end
|
||||
|
||||
def reload
|
||||
new_attributes = key_pairs.all(@name).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_key_pair(@name).body
|
||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||
|
|
|
@ -14,17 +14,18 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def reload
|
||||
new_attributes = security_groups.all(@public_ip).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_create_security_group(@group_name, @group_description).body
|
||||
true
|
||||
end
|
||||
|
||||
def security_groups
|
||||
@security_groups ||= begin
|
||||
Fog::AWS::S3::SecurityGroups.new(
|
||||
:connection => connection
|
||||
)
|
||||
end
|
||||
@security_groups
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -15,6 +15,11 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def reload
|
||||
new_attributes = snapshots.all(@snapshot_id).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_snapshot(@volume.volume_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
|
@ -23,12 +28,7 @@ module Fog
|
|||
end
|
||||
|
||||
def snapshots
|
||||
@snapshots ||= begin
|
||||
Fog::AWS::S3::Snapshots.new(
|
||||
:connection => connection,
|
||||
:volume => self.volume
|
||||
)
|
||||
end
|
||||
@snapshots
|
||||
end
|
||||
|
||||
def volume
|
||||
|
|
|
@ -26,6 +26,11 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def reload
|
||||
new_attributes = volumes.all(@volume_id).first.attributes
|
||||
merge_attributes(new_attributes)
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
|
@ -34,12 +39,7 @@ module Fog
|
|||
end
|
||||
|
||||
def snapshots
|
||||
@snapshots ||= begin
|
||||
Fog::AWS::S3::Snapshots.new(
|
||||
:connection => connection,
|
||||
:volume => self
|
||||
)
|
||||
end
|
||||
connection.snapshots.all.select {|snapshot| snapshot.volume_id == @volume_id}
|
||||
end
|
||||
|
||||
def volumes
|
||||
|
|
Loading…
Reference in a new issue