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

fleshing out snapshot models

This commit is contained in:
Wesley Beary 2009-09-24 19:18:41 -07:00
parent cc8b38ab56
commit 2b7266ede3
3 changed files with 21 additions and 11 deletions

View file

@ -28,6 +28,8 @@ module Fog
load "fog/aws/models/ec2/address.rb"
load "fog/aws/models/ec2/addresses.rb"
load "fog/aws/models/ec2/snapshot.rb"
load "fog/aws/models/ec2/snapshots.rb"
load "fog/aws/models/ec2/volume.rb"
load "fog/aws/models/ec2/volumes.rb"
@ -84,11 +86,14 @@ module Fog
load "fog/aws/requests/ec2/disassociate_address.rb"
load "fog/aws/requests/ec2/get_console_output.rb"
# TODO: require "fog/aws/requests/ec2/modify_image_attribute.rb"
# TODO: require "fog/aws/requests/ec2/modify_snapshot_attribute.rb"
# TODO: require "fog/aws/requests/ec2/monitor_instances.rb"
# TODO: require "fog/aws/requests/ec2/purchase_reserved_instances_offering.rb"
load "fog/aws/requests/ec2/reboot_instances.rb"
# TODO: require "fog/aws/requests/ec2/register_image.rb"
load "fog/aws/requests/ec2/release_address.rb"
# TODO: require "fog/aws/requests/ec2/reset_image_attributes.rb"
# TODO: require "fog/aws/requests/ec2/reset_snapshot_attributes.rb"
load "fog/aws/requests/ec2/revoke_security_group_ingress.rb"
load "fog/aws/requests/ec2/run_instances.rb"
load "fog/aws/requests/ec2/terminate_instances.rb"

View file

@ -16,12 +16,12 @@ module Fog
end
def reload
new_attributes = snapshots.all(@snapshot_id).first.attributes
new_attributes = snapshots.get(@snapshot_id).attributes
merge_attributes(new_attributes)
end
def save
data = connection.create_snapshot(@volume.volume_id).body
data = connection.create_snapshot(volume_id).body
new_attributes = data.reject {|key,value| key == 'requestId'}
update_attributes(new_attributes)
true

View file

@ -8,9 +8,14 @@ module Fog
class Snapshots < Fog::Collection
attribute :snapshot_id
def all(snapshot_id = [])
data = connection.describe_snapshots(snapshot_id)
snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
snapshots = Fog::AWS::EC2::Snapshots.new(
:connection => connection,
:snapshot_id => snapshot_id
)
data['snapshotSet'].each do |snapshot|
snapshots << Fog::AWS::EC2::Snapshot.new({
:connection => connection,
@ -26,6 +31,12 @@ module Fog
snapshot
end
def get(snapshot_id)
all(snapshot_id).first
rescue Fog::Errors::BadRequest
nil
end
def new(attributes = {})
Fog::AWS::EC2::Snapshot.new(
attributes.merge!(
@ -36,14 +47,8 @@ module Fog
)
end
def volume
@volume
end
private
def volume=(new_volume)
@volume = new_volume
def reload
all(snapshot_id)
end
end