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

Add attach and detach methods to the volume model using the compute service attribute.

This commit is contained in:
Rupak Ganguly 2012-07-11 19:21:35 -04:00
parent c77d339534
commit fc146770f6

View file

@ -43,9 +43,28 @@ module Fog
self.status == 'available'
end
# volume can be attached to only one server at a time
def attach(new_server_id, device)
requires :id
unless in_use?
data = connection.compute.attach_volume(new_server_id, id, device)
merge_attributes(:attachments => attachments << data.body['volumeAttachment'])
true
else
false
end
end
def detach
requires :id
if has_attachments?
connection.compute.detach_volume(server_id, id)
end
true
end
def destroy
requires :id
connection.delete_volume(id)
true
end