Skip to content

Commit 14ac85e

Browse files
committed
Filter out UNDEFINE_NVRAM for test:///default
The test driver doesn't support UNDEFINE_NVRAM and I couldn't find a way to probe for the capability. This hacks around it by looking at the service uri and filters out the flag. It also adds an explicit test since previously the exception was swallowed. A new server is created to avoid interference with other tests.
1 parent 21fa469 commit 14ac85e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/fog/libvirt/models/compute/server.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def destroy(options={ :destroy_volumes => false, :flags => ::Libvirt::Domain::UN
9797
if flags.zero?
9898
service.vm_action(uuid, :undefine)
9999
else
100+
# the test driver doesn't support UNDEFINE_NVRAM
101+
if service.uri.driver == 'test'
102+
flags ^= ::Libvirt::Domain::UNDEFINE_NVRAM
103+
end
100104
service.vm_action(uuid, :undefine, flags)
101105
end
102106
volumes.each { |vol| vol.destroy } if options[:destroy_volumes]

tests/libvirt/models/compute/server_tests.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
%w{ start stop destroy reboot suspend }.each do |action|
1414
test(action) { server.respond_to? action }
1515
end
16-
%w{ start reboot suspend stop destroy}.each do |action|
16+
%w{ start reboot suspend stop }.each do |action|
1717
test("#{action} returns successfully") {
1818
begin
1919
server.send(action.to_sym)
@@ -60,6 +60,11 @@
6060
end
6161
end
6262
end
63+
64+
test('can destroy') do
65+
servers.create(:name => Fog::Mock.random_letters(8)).destroy
66+
end
67+
6368
test('be a kind of Fog::Libvirt::Compute::Server') { server.kind_of? Fog::Libvirt::Compute::Server }
6469
tests("serializes to xml") do
6570
test("with memory") { server.to_xml.match?(%r{<memory>\d+</memory>}) }

0 commit comments

Comments
 (0)