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

Merge pull request #1914 from zertico/xenserver-snapshot

Added support for [xenserver] snapshot
This commit is contained in:
Sergio Rubio 2013-06-28 15:07:48 -07:00
commit b99372c257
5 changed files with 64 additions and 8 deletions

View file

@ -74,6 +74,8 @@ module Fog
request :destroy_network
request :create_vlan
request :destroy_vlan
request :snapshot_server
request :snapshot_revert
class Real

View file

@ -50,6 +50,7 @@ module Fog
attribute :hvm_boot_policy, :aliases => :HVM_boot_policy
attribute :hvm_boot_params, :aliases => :HVM_boot_params
attribute :pci_bus, :aliases => :PCI_bus
attribute :snapshots
def initialize(attributes={})
super
@ -198,14 +199,15 @@ module Fog
service.provision_server reference
end
# def snapshot
# requires :reference, :name_label
# data = service.snapshot_server(@reference, @name_label)
# merge_attributes(data.body)
# true
# end
def snapshot(name)
service.snapshot_server(reference, name)
end
def revert(snapshot_ref)
service.snapshot_revert(snapshot_ref)
end
end
end
end
end
end

View file

@ -0,0 +1,22 @@
module Fog
module Compute
class XenServer
class Real
def snapshot_revert( snapshot_ref, extra_args = {})
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.revert'}, snapshot_ref)
end
end
class Mock
def snapshot_revert()
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,22 @@
module Fog
module Compute
class XenServer
class Real
def snapshot_server( vm_ref , name, extra_args = {})
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.snapshot'}, vm_ref, name)
end
end
class Mock
def snapshot_server()
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -60,7 +60,8 @@ Shindo.tests('Fog::Compute[:xenserver] | server model', ['xenserver']) do
:pv_kernel,
:pv_ramdisk,
:pv_legacy_args,
:pv_bootloader_args
:pv_bootloader_args,
:snapshots
]
tests("The server model should respond to") do
attributes.each do |attribute|
@ -162,6 +163,13 @@ Shindo.tests('Fog::Compute[:xenserver] | server model', ['xenserver']) do
servers.get_by_name('fog-test-server-shindo') == nil
end
tests("Creating a snapshot") do
tests("it should create a snapshot") do
snap_ref = server.snapshot('newsnapshot')
servers.get(snap_ref).reference == snap_ref
end
test("and destroy it afterwards") { s.destroy }
end
end
end