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

cleanup instance/snapshot models

This commit is contained in:
Wesley Beary 2009-09-18 08:56:27 -07:00
parent 8788fdcf28
commit eea51b719f
3 changed files with 14 additions and 12 deletions

View file

@ -28,6 +28,7 @@ module Fog
end
def address=(new_address)
new_address.instance_id = @instance_id
connection.associate_address(@instance_id, new_address.public_ip)
end
@ -36,12 +37,12 @@ module Fog
true
end
# def group
# connection.groups.all(@group_id)
# def security_group
# connection.security_groups.all(@group_id)
# end
#
# def group=(new_group)
# @group_id = new_group.name
# def security_group=(new_security_group)
# @group_id = new_security_group.name
# end
def key_pair
@ -73,6 +74,7 @@ module Fog
end
def volume=(new_volume)
new_volume.instance_id = @instance_id
connection.attach_volume(@instance_id, new_volume.volume_id, new_volume.device)
end

View file

@ -8,7 +8,7 @@ module Fog
attribute :snapshot_id, 'snapshotId'
attribute :start_time, 'startTime'
attribute :status
attribute :volumeId, 'volumeId'
attribute :volume_id, 'volumeId'
def delete
connection.delete_snapshot(@snapshot_id)
@ -26,13 +26,13 @@ module Fog
@snapshots ||= begin
Fog::AWS::S3::Snapshots.new(
:connection => connection,
:volume => self
:volume => self.volume
)
end
end
def volume
@volume
connection.describe_volumes(@volume_id)
end
private
@ -42,7 +42,7 @@ module Fog
end
def volume=(new_volume)
@volume = new_volume
@volume_id = new_volume.volume_id
end
end

View file

@ -11,7 +11,7 @@ module Fog
def all(snapshot_id = [])
data = connection.describe_snapshots(snapshot_id)
snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
data['snapshotSet'].each do |volume|
data['snapshotSet'].each do |snapshot|
snapshots << Fog::AWS::EC2::Snapshot.new({
:connection => connection
}.merge!(snapshot))
@ -20,9 +20,9 @@ module Fog
end
def create(attributes = {})
volume = new(attributes)
volume.save
volume
snapshot = new(attributes)
snapshot.save
snapshot
end
def new(attributes = {})