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:
parent
cc8b38ab56
commit
2b7266ede3
3 changed files with 21 additions and 11 deletions
|
@ -28,6 +28,8 @@ module Fog
|
||||||
|
|
||||||
load "fog/aws/models/ec2/address.rb"
|
load "fog/aws/models/ec2/address.rb"
|
||||||
load "fog/aws/models/ec2/addresses.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/volume.rb"
|
||||||
load "fog/aws/models/ec2/volumes.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/disassociate_address.rb"
|
||||||
load "fog/aws/requests/ec2/get_console_output.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_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/monitor_instances.rb"
|
||||||
# TODO: require "fog/aws/requests/ec2/purchase_reserved_instances_offering.rb"
|
# TODO: require "fog/aws/requests/ec2/purchase_reserved_instances_offering.rb"
|
||||||
load "fog/aws/requests/ec2/reboot_instances.rb"
|
load "fog/aws/requests/ec2/reboot_instances.rb"
|
||||||
# TODO: require "fog/aws/requests/ec2/register_image.rb"
|
# TODO: require "fog/aws/requests/ec2/register_image.rb"
|
||||||
load "fog/aws/requests/ec2/release_address.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/revoke_security_group_ingress.rb"
|
||||||
load "fog/aws/requests/ec2/run_instances.rb"
|
load "fog/aws/requests/ec2/run_instances.rb"
|
||||||
load "fog/aws/requests/ec2/terminate_instances.rb"
|
load "fog/aws/requests/ec2/terminate_instances.rb"
|
||||||
|
|
|
@ -16,12 +16,12 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
new_attributes = snapshots.all(@snapshot_id).first.attributes
|
new_attributes = snapshots.get(@snapshot_id).attributes
|
||||||
merge_attributes(new_attributes)
|
merge_attributes(new_attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save
|
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'}
|
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||||
update_attributes(new_attributes)
|
update_attributes(new_attributes)
|
||||||
true
|
true
|
||||||
|
|
|
@ -8,9 +8,14 @@ module Fog
|
||||||
|
|
||||||
class Snapshots < Fog::Collection
|
class Snapshots < Fog::Collection
|
||||||
|
|
||||||
|
attribute :snapshot_id
|
||||||
|
|
||||||
def all(snapshot_id = [])
|
def all(snapshot_id = [])
|
||||||
data = connection.describe_snapshots(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|
|
data['snapshotSet'].each do |snapshot|
|
||||||
snapshots << Fog::AWS::EC2::Snapshot.new({
|
snapshots << Fog::AWS::EC2::Snapshot.new({
|
||||||
:connection => connection,
|
:connection => connection,
|
||||||
|
@ -26,6 +31,12 @@ module Fog
|
||||||
snapshot
|
snapshot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(snapshot_id)
|
||||||
|
all(snapshot_id).first
|
||||||
|
rescue Fog::Errors::BadRequest
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
Fog::AWS::EC2::Snapshot.new(
|
Fog::AWS::EC2::Snapshot.new(
|
||||||
attributes.merge!(
|
attributes.merge!(
|
||||||
|
@ -36,14 +47,8 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def volume
|
def reload
|
||||||
@volume
|
all(snapshot_id)
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def volume=(new_volume)
|
|
||||||
@volume = new_volume
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue