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

Merge pull request #809 from decklin/avoid-constants

[ibm] avoid using constants (Rails loads files multiple times, issue #807)
This commit is contained in:
Decklin Foster 2012-03-22 09:02:42 -07:00
commit 8c40809a39
9 changed files with 22 additions and 21 deletions

View file

@ -10,17 +10,18 @@ module Fog
# Provisioning is very slow. We'll pass this arg explicitly until there's a way
# to set the default timeout on a per-provider basis.
TIMEOUT = 1800
def self.timeout
1800
end
class Connection < Fog::Connection
ENDPOINT = 'https://www-147.ibm.com/computecloud/enterprise/api/rest/20100331'
def initialize(user, password)
require 'multi_json'
@user = user
@password = password
@endpoint = URI.parse(ENDPOINT)
@endpoint = URI.parse('https://www-147.ibm.com/computecloud/enterprise/api/rest/20100331')
@base_path = @endpoint.path
super("#{@endpoint.scheme}://#{@endpoint.host}:#{@endpoint.port}")
end

View file

@ -104,7 +104,7 @@ module Fog
requires :location_id
new_ip = connection.addresses.new(:location => location_id)
new_ip.save
new_ip.wait_for(Fog::IBM::TIMEOUT) { ready? } if wait_for_ready
new_ip.wait_for(Fog::IBM.timeout) { ready? } if wait_for_ready
secondary_ip << new_ip
new_ip
end

View file

@ -32,7 +32,7 @@ Shindo.tests('Fog::Compute[:ibm] | server', ['ibm']) do
tests('Fog::Compute::IBM::Server#wait_for { ready? }') do
@server = Fog::Compute[:ibm].servers.get(@instance_id)
@server.wait_for(Fog::IBM::TIMEOUT) { ready? }
@server.wait_for(Fog::IBM.timeout) { ready? }
end
tests('Fog::Compute::IBM::Server#id') do
@ -66,7 +66,7 @@ Shindo.tests('Fog::Compute[:ibm] | server', ['ibm']) do
body = @server.to_image(:name => @server.name)
returns(@server.name) { body['name'] }
image = Fog::Compute[:ibm].images.get(body['id'])
image.wait_for(Fog::IBM::TIMEOUT) { ready? || state == 'New' }
image.wait_for(Fog::IBM.timeout) { ready? || state == 'New' }
unless image.state == 'Capturing'
returns(true) { Fog::Compute[:ibm].delete_image(image.id).body['success'] }
end
@ -80,7 +80,7 @@ Shindo.tests('Fog::Compute[:ibm] | server', ['ibm']) do
returns(true) { @server.destroy }
end
@key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
@key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
@key.destroy
end

View file

@ -21,12 +21,12 @@ Shindo.tests('Fog::Compute[:ibm] | servers', ['ibm']) do
returns(@instance_id) { @server.id }
end
if @server.wait_for(Fog::IBM::TIMEOUT) { ready? }
if @server.wait_for(Fog::IBM.timeout) { ready? }
@server.destroy
else
pending
end
if @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
if @key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
@key.destroy
else
pending

View file

@ -24,7 +24,7 @@ Shindo.tests('Fog::Storage[:ibm] | volume', ['ibm']) do
tests('Fog::Storage::IBM::Volume#save') do
returns(true) { @volume.save }
returns(String) { @volume.id.class }
@volume.wait_for(Fog::IBM::TIMEOUT) { ready? }
@volume.wait_for(Fog::IBM.timeout) { ready? }
@volume_id = @volume.id
end

View file

@ -35,7 +35,7 @@ Shindo.tests('Fog::Compute[:ibm] | address requests', ['ibm']) do
end
tests("#delete_address('#{@address_id}')") do
Fog::Compute[:ibm].addresses.get(@address_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
Fog::Compute[:ibm].addresses.get(@address_id).wait_for(Fog::IBM.timeout) { ready? }
returns(true) { Fog::Compute[:ibm].delete_address(@address_id).body['success'] }
end

View file

@ -80,7 +80,7 @@ Shindo.tests('Fog::Compute[:ibm] | image requests', ['ibm']) do
:key_name => @key_name
).body
@instance_id = response['instances'][0]['id']
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM.timeout) { ready? }
data = Fog::Compute[:ibm].create_image(@instance_id, @image_name, "").body
@id = data['id']
data
@ -100,9 +100,9 @@ Shindo.tests('Fog::Compute[:ibm] | image requests', ['ibm']) do
end
@server = Fog::Compute[:ibm].servers.get(@instance_id)
@server.wait_for(Fog::IBM::TIMEOUT) { ready? }
@server.wait_for(Fog::IBM.timeout) { ready? }
@server.destroy
@key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
@key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
@key.destroy
end

View file

@ -53,7 +53,7 @@ Shindo.tests('Fog::Compute[:ibm] | instance requests', ['ibm']) do
response = Fog::Compute[:ibm].get_instance(@instance_id).body
end
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM.timeout) { ready? }
tests("#list_instances").formats(@instances_format) do
instances = Fog::Compute[:ibm].list_instances.body
@ -74,14 +74,14 @@ Shindo.tests('Fog::Compute[:ibm] | instance requests', ['ibm']) do
end
tests("#delete_instance('#{@instance_id}')") do
if Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
if Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM.timeout) { ready? }
data = Fog::Compute[:ibm].delete_instance(@instance_id)
else
pending
end
end
if @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
if @key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
@key.destroy
else
pending

View file

@ -82,7 +82,7 @@ Shindo.tests('Fog::Storage[:ibm] | volume requests', ['ibm']) do
Fog::Compute[:ibm].delete_instance(@instance_id)
end
Fog::Storage[:ibm].volumes.get(@volume_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
Fog::Storage[:ibm].volumes.get(@volume_id).wait_for(Fog::IBM.timeout) { ready? }
tests("#delete_volume('#{@volume_id}')") do
returns(true) { Fog::Storage[:ibm].delete_volume(@volume_id).body['success'] }
@ -90,9 +90,9 @@ Shindo.tests('Fog::Storage[:ibm] | volume requests', ['ibm']) do
# See above
# @server = Fog::Compute[:ibm].servers.get(@instance_id)
# @server.wait_for(Fog::IBM::TIMEOUT) { ready? }
# @server.wait_for(Fog::IBM.timeout) { ready? }
# @server.destroy
# @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
# @key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
# @key.destroy
end