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:
parent
c77d339534
commit
fc146770f6
1 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue