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:
commit
cad881c2b5
13 changed files with 27 additions and 27 deletions
|
@ -400,7 +400,7 @@ DATA
|
|||
begin
|
||||
response = @connection.request(params, &block)
|
||||
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")
|
||||
response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false, @connection_options).request(original_params, &block)
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module Fog
|
|||
merge_attributes(connection.create_floating_ip(self.floating_network_id,
|
||||
|
||||
|
||||
self.attributes).body['floating_ip'])
|
||||
self.attributes).body['floatingip'])
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
load(connection.list_floating_ips(filters).body['floating_ips'])
|
||||
load(connection.list_floating_ips(filters).body['floatingips'])
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
rescue Fog::Network::OpenStack::NotFound
|
||||
|
|
|
@ -5,14 +5,14 @@ module Fog
|
|||
class Real
|
||||
def associate_floating_ip(floating_ip_id, port_id, options = {})
|
||||
data = {
|
||||
'floating_ip' => {
|
||||
'floatingip' => {
|
||||
'port_id' => port_id,
|
||||
}
|
||||
}
|
||||
|
||||
vanilla_options = [:fixed_ip_address]
|
||||
vanilla_options.reject{ |o| options[o].nil? }.each do |key|
|
||||
data['floating_ip'][key] = options[key]
|
||||
data['floatingip'][key] = options[key]
|
||||
end
|
||||
|
||||
request(
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
}
|
||||
|
||||
self.data[:floating_ips][data['floating_ip_id']] = data
|
||||
response.body = { 'floating_ip' => data }
|
||||
response.body = { 'floatingip' => data }
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
class Real
|
||||
def create_floating_ip(floating_network_id, options = {})
|
||||
data = {
|
||||
'floating_ip' => {
|
||||
'floatingip' => {
|
||||
'floating_network_id' => floating_network_id,
|
||||
'port_id' => options[:port_id],
|
||||
'tenant_id' => options[:tenant_id],
|
||||
|
@ -15,7 +15,7 @@ module Fog
|
|||
|
||||
vanilla_options = [:port_id, :tenant_id, :fixed_ip_address ]
|
||||
vanilla_options.reject{ |o| options[o].nil? }.each do |key|
|
||||
data['floating_ip'][key] = options[key]
|
||||
data['floatingip'][key] = options[key]
|
||||
end
|
||||
|
||||
request(
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
'router_id' => nil,
|
||||
}
|
||||
self.data[:floating_ips][data['id']] = data
|
||||
response.body = { 'floating_ip' => data }
|
||||
response.body = { 'floatingip' => data }
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
class Mock
|
||||
def delete_floating_ip(floating_ip_id)
|
||||
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)
|
||||
response.status = 204
|
||||
response
|
||||
|
|
|
@ -5,14 +5,14 @@ module Fog
|
|||
class Real
|
||||
def disassociate_floating_ip(floating_ip_id, options = {})
|
||||
data = {
|
||||
'floating_ip' => {
|
||||
'floatingip' => {
|
||||
'port_id' => nil,
|
||||
}
|
||||
}
|
||||
|
||||
vanilla_options = [:fixed_ip_address]
|
||||
vanilla_options.reject{ |o| options[o].nil? }.each do |key|
|
||||
data['floating_ip'][key] = options[key]
|
||||
data['floatingip'][key] = options[key]
|
||||
end
|
||||
|
||||
request(
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
}
|
||||
|
||||
self.data[:floating_ips][data['floating_ip_id']] = data
|
||||
response.body = { 'floating_ip' => data }
|
||||
response.body = { 'floatingip' => data }
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
if data = self.data[:floating_ips][floating_ip_id]
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"floating_ip" => {
|
||||
"floatingip" => {
|
||||
"id" => "00000000-0000-0000-0000-000000000000",
|
||||
# changed
|
||||
# "floating_ip_id" => floating_ip_id,
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
class Mock
|
||||
def list_floating_ips(filters = {})
|
||||
Excon::Response.new(
|
||||
:body => { 'floating_ips' => self.data[:floating_ips].values },
|
||||
:body => { 'floatingips' => self.data[:floating_ips].values },
|
||||
:status => 200
|
||||
)
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
headers.each_pair do |k, v|
|
||||
key = metadata.send(:to_key, k)
|
||||
next unless key
|
||||
metadata.data[key] = Fog::JSON.decode(v)
|
||||
metadata.data[key] = v
|
||||
end
|
||||
metadata
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ Shindo.tests('Fog::Rackspace::Storage | directories', ['rackspace']) do
|
|||
tests('#get').succeeds do
|
||||
instance = @service.directories.get @name
|
||||
returns(false) { instance.nil? }
|
||||
returns(true) { instance.metadata[:fog_test] }
|
||||
returns('true') { instance.metadata[:fog_test] }
|
||||
returns(@name) { instance.key }
|
||||
returns(1) { instance.count }
|
||||
returns( Fog::Storage.get_body_size(lorem_file)) {instance.bytes }
|
||||
|
|
|
@ -120,7 +120,7 @@ Shindo.tests('Fog::Rackspace::Storage | directory', ['rackspace']) do
|
|||
@service.put_container(@instance.key, {"X-Container-Meta-List-Test"=>"true"} )
|
||||
dir = @service.directories.find {|d| d.key == @instance.key }
|
||||
returns(nil) { dir.instance_variable_get("@metadata") }
|
||||
returns(true) { dir.metadata[:list_test] }
|
||||
returns('true') { dir.metadata[:list_test] }
|
||||
end
|
||||
|
||||
tests("should reload metadata after calling reload").returns(42) do
|
||||
|
|
|
@ -36,12 +36,12 @@ Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do
|
|||
metadata.to_headers
|
||||
end
|
||||
|
||||
tests("#from_headers").returns({:my_boolean=>true, :my_integer=>42, :my_string=>"I am a string"}) do
|
||||
headers = {
|
||||
"X-Container-Meta-My-Integer"=> "42",
|
||||
"X-Container-Meta-My-Boolean"=> "true",
|
||||
"X-Container-Meta-My-String"=> "\"I am a string\""
|
||||
}
|
||||
tests("#from_headers").returns({:my_boolean=>"true", :my_integer=>"42", :my_string=>"I am a string"}) do
|
||||
headers = {
|
||||
"X-Container-Meta-My-Integer"=> "42",
|
||||
"X-Container-Meta-My-Boolean"=> "true",
|
||||
"X-Container-Meta-My-String"=> "I am a string"
|
||||
}
|
||||
|
||||
metadata = Fog::Storage::Rackspace::Metadata.from_headers @directory, headers
|
||||
metadata.data
|
||||
|
@ -89,11 +89,11 @@ Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do
|
|||
metadata.to_headers
|
||||
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 = {
|
||||
"X-Object-Meta-My-Integer"=> "42",
|
||||
"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
|
||||
|
|
Loading…
Add table
Reference in a new issue