mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Introduce disk-snapshot and VM shutdown functionality.
This commit is contained in:
parent
dc4929dfb8
commit
754c663cb5
4 changed files with 54 additions and 0 deletions
|
@ -28,6 +28,8 @@ module Fog
|
|||
request :vm_resume
|
||||
request :vm_stop
|
||||
request :template_pool
|
||||
request :vm_disk_snapshot
|
||||
request :vm_shutdown
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
|
|
@ -19,6 +19,10 @@ module Fog
|
|||
new data.first unless data.empty?
|
||||
end
|
||||
|
||||
def shutdown(id)
|
||||
service.vm_shutdown(id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
25
lib/fog/opennebula/requests/compute/vm_disk_snapshot.rb
Normal file
25
lib/fog/opennebula/requests/compute/vm_disk_snapshot.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class OpenNebula
|
||||
class Real
|
||||
|
||||
def vm_disk_snapshot(id, disk_id, image_name)
|
||||
vmpool = ::OpenNebula::VirtualMachinePool.new(client)
|
||||
vmpool.info!(-2,id,id,-1)
|
||||
|
||||
rc = 0
|
||||
vmpool.each do |vm|
|
||||
rc = vm.disk_snapshot(disk_id, image_name)
|
||||
if(rc.is_a? ::OpenNebula::Error)
|
||||
raise(rc)
|
||||
end
|
||||
end
|
||||
rc
|
||||
end #def vm_disk_snapshot
|
||||
|
||||
class Mock
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/opennebula/requests/compute/vm_shutdown.rb
Normal file
23
lib/fog/opennebula/requests/compute/vm_shutdown.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class OpenNebula
|
||||
class Real
|
||||
|
||||
def vm_shutdown(id)
|
||||
vmpool = ::OpenNebula::VirtualMachinePool.new(client)
|
||||
vmpool.info!(-2,id,id,-1)
|
||||
|
||||
vmpool.each do |vm|
|
||||
vm.shutdown()
|
||||
end
|
||||
end #def vm_disk_snapshot
|
||||
|
||||
end
|
||||
class Mock
|
||||
def vm_shutdown(id)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue