Rescue `opennebula` loading issues
`require "opennebula"` fails when downstream tries to require `xmlrpc` which is not included within the main `fog` dependencies. The problem is that the `LoadError` was being trapped by `Fog::SevicesMixin#new` so it was reporting that the OpenNebula provider did not offer the service. This then handles the `Fog::Errors::LoadError` in all the shindo tests that halted the run. These tests will be pending unless `opennebula` is installed.
This commit is contained in:
parent
4fb6da70e1
commit
a759f97388
|
@ -98,7 +98,12 @@ module Fog
|
||||||
@opennebula_endpoint = options[:opennebula_endpoint]
|
@opennebula_endpoint = options[:opennebula_endpoint]
|
||||||
@opennebula_username = options[:opennebula_username]
|
@opennebula_username = options[:opennebula_username]
|
||||||
@opennebula_password = options[:opennebula_password]
|
@opennebula_password = options[:opennebula_password]
|
||||||
require 'opennebula'
|
|
||||||
|
begin
|
||||||
|
require "opennebula"
|
||||||
|
rescue LoadError
|
||||||
|
raise Fog::Errors::LoadError, "To use OpenNebula provider, you must load 'opennebula' gem"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def client
|
def client
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'opennebula'
|
begin
|
||||||
|
require "opennebula"
|
||||||
|
rescue LoadError
|
||||||
|
raise Fog::Errors::LoadError, "To use OpenNebula provider, you must load 'opennebula' gem"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#if !ONE_LOCATION
|
#if !ONE_LOCATION
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula]', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula]', ['opennebula']) do
|
||||||
|
begin
|
||||||
compute = Fog::Compute[:opennebula]
|
compute = Fog::Compute[:opennebula]
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
tests("Compute collections") do
|
tests("Compute collections") do
|
||||||
%w{networks groups}.each do |collection|
|
%w{networks groups}.each do |collection|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do
|
||||||
|
begin
|
||||||
flavors = Fog::Compute[:opennebula].flavors
|
flavors = Fog::Compute[:opennebula].flavors
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
flavor = flavors.get_by_name('fogtest').last
|
flavor = flavors.get_by_name('fogtest').last
|
||||||
|
|
||||||
tests('The flavor model should') do
|
tests('The flavor model should') do
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | flavors collection', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | flavors collection', ['opennebula']) do
|
||||||
|
begin
|
||||||
flavors = Fog::Compute[:opennebula].flavors
|
flavors = Fog::Compute[:opennebula].flavors
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
tests('The flavors collection should') do
|
tests('The flavors collection should') do
|
||||||
test('should be a kind of Fog::Compute::OpenNebula::Flavors') { flavors.kind_of? Fog::Compute::OpenNebula::Flavors }
|
test('should be a kind of Fog::Compute::OpenNebula::Flavors') { flavors.kind_of? Fog::Compute::OpenNebula::Flavors }
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | group model', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | group model', ['opennebula']) do
|
||||||
|
begin
|
||||||
groups = Fog::Compute[:opennebula].groups
|
groups = Fog::Compute[:opennebula].groups
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
group = groups.last
|
group = groups.last
|
||||||
|
|
||||||
tests('The group model should') do
|
tests('The group model should') do
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | groups collection', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | groups collection', ['opennebula']) do
|
||||||
|
begin
|
||||||
groups = Fog::Compute[:opennebula].groups
|
groups = Fog::Compute[:opennebula].groups
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
tests('The groups collection') do
|
tests('The groups collection') do
|
||||||
test('should be a kind of Fog::Compute::OpenNebula::Groups') { groups.kind_of? Fog::Compute::OpenNebula::Groups }
|
test('should be a kind of Fog::Compute::OpenNebula::Groups') { groups.kind_of? Fog::Compute::OpenNebula::Groups }
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | network model', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | network model', ['opennebula']) do
|
||||||
|
begin
|
||||||
networks = Fog::Compute[:opennebula].networks
|
networks = Fog::Compute[:opennebula].networks
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
network = networks.get_by_name('fogtest')
|
network = networks.get_by_name('fogtest')
|
||||||
|
|
||||||
tests('The network model should') do
|
tests('The network model should') do
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests('Fog::Compute[:opennebula] | networks collection', ['opennebula']) do
|
Shindo.tests('Fog::Compute[:opennebula] | networks collection', ['opennebula']) do
|
||||||
|
begin
|
||||||
networks = Fog::Compute[:opennebula].networks
|
networks = Fog::Compute[:opennebula].networks
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
tests('The networks collection') do
|
tests('The networks collection') do
|
||||||
test('should be a kind of Fog::Compute::OpenNebula::Networks') { networks.kind_of? Fog::Compute::OpenNebula::Networks }
|
test('should be a kind of Fog::Compute::OpenNebula::Networks') { networks.kind_of? Fog::Compute::OpenNebula::Networks }
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
Shindo.tests("Fog::Compute[:opennebula] | vm_create and vm_destroy request", 'opennebula') do
|
Shindo.tests("Fog::Compute[:opennebula] | vm_create and vm_destroy request", 'opennebula') do
|
||||||
|
begin
|
||||||
compute = Fog::Compute[:opennebula]
|
compute = Fog::Compute[:opennebula]
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
name_base = Time.now.to_i
|
name_base = Time.now.to_i
|
||||||
f = compute.flavors.get_by_name("fogtest")
|
f = compute.flavors.get_by_name("fogtest")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
Shindo.tests("Fog::Compute[:opennebula] | vm_suspend and vm_resume request", 'opennebula') do
|
Shindo.tests("Fog::Compute[:opennebula] | vm_suspend and vm_resume request", 'opennebula') do
|
||||||
|
begin
|
||||||
compute = Fog::Compute[:opennebula]
|
compute = Fog::Compute[:opennebula]
|
||||||
|
rescue Fog::Errors::LoadError
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
name_base = Time.now.to_i
|
name_base = Time.now.to_i
|
||||||
f = compute.flavors.get_by_name("fogtest")
|
f = compute.flavors.get_by_name("fogtest")
|
||||||
|
|
Loading…
Reference in New Issue