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

rebasing with master

This commit is contained in:
Kyle Rames 2013-02-26 07:58:01 -06:00
commit cad881c2b5
13 changed files with 27 additions and 27 deletions

View file

@ -400,7 +400,7 @@ DATA
begin begin
response = @connection.request(params, &block) response = @connection.request(params, &block)
rescue Excon::Errors::TemporaryRedirect => error rescue Excon::Errors::TemporaryRedirect => error
uri = URI.parse(error.response.headers['Location']) uri = URI.parse(error.response.is_a?(Hash) ? error.response[:headers]['Location'] : error.response.headers['Location'])
Fog::Logger.warning("fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant") Fog::Logger.warning("fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant")
response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false, @connection_options).request(original_params, &block) response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false, @connection_options).request(original_params, &block)
end end

View file

@ -32,7 +32,7 @@ module Fog
merge_attributes(connection.create_floating_ip(self.floating_network_id, merge_attributes(connection.create_floating_ip(self.floating_network_id,
self.attributes).body['floating_ip']) self.attributes).body['floatingip'])
self self
end end

View file

@ -17,11 +17,11 @@ module Fog
def all(filters = filters) def all(filters = filters)
self.filters = filters self.filters = filters
load(connection.list_floating_ips(filters).body['floating_ips']) load(connection.list_floating_ips(filters).body['floatingips'])
end end
def get(floating_network_id) def get(floating_network_id)
if floating_ip = connection.get_floating_ip(floating_network_id).body['floating_ip'] if floating_ip = connection.get_floating_ip(floating_network_id).body['floatingip']
new(floating_ip) new(floating_ip)
end end
rescue Fog::Network::OpenStack::NotFound rescue Fog::Network::OpenStack::NotFound

View file

@ -5,14 +5,14 @@ module Fog
class Real class Real
def associate_floating_ip(floating_ip_id, port_id, options = {}) def associate_floating_ip(floating_ip_id, port_id, options = {})
data = { data = {
'floating_ip' => { 'floatingip' => {
'port_id' => port_id, 'port_id' => port_id,
} }
} }
vanilla_options = [:fixed_ip_address] vanilla_options = [:fixed_ip_address]
vanilla_options.reject{ |o| options[o].nil? }.each do |key| vanilla_options.reject{ |o| options[o].nil? }.each do |key|
data['floating_ip'][key] = options[key] data['floatingip'][key] = options[key]
end end
request( request(
@ -39,7 +39,7 @@ module Fog
} }
self.data[:floating_ips][data['floating_ip_id']] = data self.data[:floating_ips][data['floating_ip_id']] = data
response.body = { 'floating_ip' => data } response.body = { 'floatingip' => data }
response response
end end
end end

View file

@ -5,7 +5,7 @@ module Fog
class Real class Real
def create_floating_ip(floating_network_id, options = {}) def create_floating_ip(floating_network_id, options = {})
data = { data = {
'floating_ip' => { 'floatingip' => {
'floating_network_id' => floating_network_id, 'floating_network_id' => floating_network_id,
'port_id' => options[:port_id], 'port_id' => options[:port_id],
'tenant_id' => options[:tenant_id], 'tenant_id' => options[:tenant_id],
@ -15,7 +15,7 @@ module Fog
vanilla_options = [:port_id, :tenant_id, :fixed_ip_address ] vanilla_options = [:port_id, :tenant_id, :fixed_ip_address ]
vanilla_options.reject{ |o| options[o].nil? }.each do |key| vanilla_options.reject{ |o| options[o].nil? }.each do |key|
data['floating_ip'][key] = options[key] data['floatingip'][key] = options[key]
end end
request( request(
@ -40,7 +40,7 @@ module Fog
'router_id' => nil, 'router_id' => nil,
} }
self.data[:floating_ips][data['id']] = data self.data[:floating_ips][data['id']] = data
response.body = { 'floating_ip' => data } response.body = { 'floatingip' => data }
response response
end end
end end

View file

@ -15,7 +15,7 @@ module Fog
class Mock class Mock
def delete_floating_ip(floating_ip_id) def delete_floating_ip(floating_ip_id)
response = Excon::Response.new response = Excon::Response.new
if list_floating_ips.body['floating_ips'].map { |r| r['id'] }.include? floating_ip_id if list_floating_ips.body['floatingips'].map { |r| r['id'] }.include? floating_ip_id
self.data[:floating_ips].delete(floating_ip_id) self.data[:floating_ips].delete(floating_ip_id)
response.status = 204 response.status = 204
response response

View file

@ -5,14 +5,14 @@ module Fog
class Real class Real
def disassociate_floating_ip(floating_ip_id, options = {}) def disassociate_floating_ip(floating_ip_id, options = {})
data = { data = {
'floating_ip' => { 'floatingip' => {
'port_id' => nil, 'port_id' => nil,
} }
} }
vanilla_options = [:fixed_ip_address] vanilla_options = [:fixed_ip_address]
vanilla_options.reject{ |o| options[o].nil? }.each do |key| vanilla_options.reject{ |o| options[o].nil? }.each do |key|
data['floating_ip'][key] = options[key] data['floatingip'][key] = options[key]
end end
request( request(
@ -39,7 +39,7 @@ module Fog
} }
self.data[:floating_ips][data['floating_ip_id']] = data self.data[:floating_ips][data['floating_ip_id']] = data
response.body = { 'floating_ip' => data } response.body = { 'floatingip' => data }
response response
end end
end end

View file

@ -18,7 +18,7 @@ module Fog
if data = self.data[:floating_ips][floating_ip_id] if data = self.data[:floating_ips][floating_ip_id]
response.status = 200 response.status = 200
response.body = { response.body = {
"floating_ip" => { "floatingip" => {
"id" => "00000000-0000-0000-0000-000000000000", "id" => "00000000-0000-0000-0000-000000000000",
# changed # changed
# "floating_ip_id" => floating_ip_id, # "floating_ip_id" => floating_ip_id,

View file

@ -16,7 +16,7 @@ module Fog
class Mock class Mock
def list_floating_ips(filters = {}) def list_floating_ips(filters = {})
Excon::Response.new( Excon::Response.new(
:body => { 'floating_ips' => self.data[:floating_ips].values }, :body => { 'floatingips' => self.data[:floating_ips].values },
:status => 200 :status => 200
) )
end end

View file

@ -45,7 +45,7 @@ module Fog
headers.each_pair do |k, v| headers.each_pair do |k, v|
key = metadata.send(:to_key, k) key = metadata.send(:to_key, k)
next unless key next unless key
metadata.data[key] = Fog::JSON.decode(v) metadata.data[key] = v
end end
metadata metadata
end end

View file

@ -14,7 +14,7 @@ Shindo.tests('Fog::Rackspace::Storage | directories', ['rackspace']) do
tests('#get').succeeds do tests('#get').succeeds do
instance = @service.directories.get @name instance = @service.directories.get @name
returns(false) { instance.nil? } returns(false) { instance.nil? }
returns(true) { instance.metadata[:fog_test] } returns('true') { instance.metadata[:fog_test] }
returns(@name) { instance.key } returns(@name) { instance.key }
returns(1) { instance.count } returns(1) { instance.count }
returns( Fog::Storage.get_body_size(lorem_file)) {instance.bytes } returns( Fog::Storage.get_body_size(lorem_file)) {instance.bytes }

View file

@ -120,7 +120,7 @@ Shindo.tests('Fog::Rackspace::Storage | directory', ['rackspace']) do
@service.put_container(@instance.key, {"X-Container-Meta-List-Test"=>"true"} ) @service.put_container(@instance.key, {"X-Container-Meta-List-Test"=>"true"} )
dir = @service.directories.find {|d| d.key == @instance.key } dir = @service.directories.find {|d| d.key == @instance.key }
returns(nil) { dir.instance_variable_get("@metadata") } returns(nil) { dir.instance_variable_get("@metadata") }
returns(true) { dir.metadata[:list_test] } returns('true') { dir.metadata[:list_test] }
end end
tests("should reload metadata after calling reload").returns(42) do tests("should reload metadata after calling reload").returns(42) do

View file

@ -36,11 +36,11 @@ Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do
metadata.to_headers metadata.to_headers
end end
tests("#from_headers").returns({:my_boolean=>true, :my_integer=>42, :my_string=>"I am a string"}) do tests("#from_headers").returns({:my_boolean=>"true", :my_integer=>"42", :my_string=>"I am a string"}) do
headers = { headers = {
"X-Container-Meta-My-Integer"=> "42", "X-Container-Meta-My-Integer"=> "42",
"X-Container-Meta-My-Boolean"=> "true", "X-Container-Meta-My-Boolean"=> "true",
"X-Container-Meta-My-String"=> "\"I am a string\"" "X-Container-Meta-My-String"=> "I am a string"
} }
metadata = Fog::Storage::Rackspace::Metadata.from_headers @directory, headers metadata = Fog::Storage::Rackspace::Metadata.from_headers @directory, headers
@ -89,11 +89,11 @@ Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do
metadata.to_headers metadata.to_headers
end end
tests("#from_headers").returns({:my_boolean=>true, :my_integer=>42, :my_string=>"I am a string"}) do tests("#from_headers").returns({:my_boolean=>"true", :my_integer=>"42", :my_string=>"I am a string"}) do
headers = { headers = {
"X-Object-Meta-My-Integer"=> "42", "X-Object-Meta-My-Integer"=> "42",
"X-Object-Meta-My-Boolean"=> "true", "X-Object-Meta-My-Boolean"=> "true",
"X-Object-Meta-My-String"=> "\"I am a string\"" "X-Object-Meta-My-String"=> "I am a string"
} }
metadata = Fog::Storage::Rackspace::Metadata.from_headers @file, headers metadata = Fog::Storage::Rackspace::Metadata.from_headers @file, headers