зеркало из https://github.com/microsoft/fog.git
add connection resetting/persistent option to connections
This commit is contained in:
Родитель
7f91db2bd8
Коммит
4b736a3979
2
Gemfile
2
Gemfile
|
@ -1,7 +1,7 @@
|
|||
source 'http://gemcutter.org'
|
||||
|
||||
gem 'rake'
|
||||
gem 'excon', '>= 0.1.0'
|
||||
gem 'excon', '>= 0.1.1'
|
||||
gem 'formatador', ">= 0.0.10"
|
||||
gem 'json', ">= 0"
|
||||
gem 'mime-types', ">= 0"
|
||||
|
|
|
@ -31,7 +31,7 @@ dependencies:
|
|||
excon:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0.1.0"
|
||||
version: ">= 0.1.1"
|
||||
builder:
|
||||
group:
|
||||
- :default
|
||||
|
@ -50,7 +50,7 @@ specs:
|
|||
- builder:
|
||||
version: 2.1.2
|
||||
- excon:
|
||||
version: 0.1.0
|
||||
version: 0.1.1
|
||||
- formatador:
|
||||
version: 0.0.14
|
||||
- gestalt:
|
||||
|
@ -69,7 +69,7 @@ specs:
|
|||
version: 0.4.0
|
||||
- shindo:
|
||||
version: 0.1.6
|
||||
hash: 8e1636212741876b9021efe871e1f6cd8969ab94
|
||||
hash: 566a73651b09dfc6a62475d86d7f75545ce12990
|
||||
sources:
|
||||
- Rubygems:
|
||||
uri: http://gemcutter.org
|
||||
|
|
|
@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
## List your runtime dependencies here. Runtime dependencies are those
|
||||
## that are needed for an end user to actually USE your code.
|
||||
s.add_dependency('excon', '>=0.1.0')
|
||||
s.add_dependency('excon', '>=0.1.1')
|
||||
s.add_dependency('formatador', '>=0.0.10')
|
||||
s.add_dependency('json')
|
||||
s.add_dependency('mime-types')
|
||||
|
|
|
@ -160,13 +160,16 @@ module Fog
|
|||
end
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
|
||||
idempotent = params.delete(:idempotent)
|
||||
parser = params.delete(:parser)
|
||||
|
||||
|
|
|
@ -63,13 +63,16 @@ module Fog
|
|||
end
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
|
||||
idempotent = params.delete(:idempotent)
|
||||
parser = params.delete(:parser)
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@ module Fog
|
|||
end
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
reload
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -68,6 +68,7 @@ module Fog
|
|||
@nil_string = options[:nil_string]|| 'nil'
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -117,8 +118,11 @@ module Fog
|
|||
encoded_attributes
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
idempotent = params.delete(:idempotent)
|
||||
parser = params.delete(:parser)
|
||||
|
||||
|
|
|
@ -53,10 +53,14 @@ module Fog
|
|||
@host = options[:bluebox_host] || "boxpanel.blueboxgrp.com"
|
||||
@port = options[:bluebox_port] || 443
|
||||
@scheme = options[:bluebox_scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
params[:headers] ||= {}
|
||||
params[:headers].merge!({
|
||||
'Authorization' => "Basic #{Base64.encode64([@bluebox_customer_id, @bluebox_api_key].join(':')).delete("\r\n")}"
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
module Fog
|
||||
class Connection
|
||||
|
||||
def initialize(url)
|
||||
def initialize(url, persistent=false)
|
||||
@excon = Excon.new(url)
|
||||
@persistent = persistent
|
||||
end
|
||||
|
||||
def request(params, &block)
|
||||
unless @persistent
|
||||
reset
|
||||
end
|
||||
unless block_given?
|
||||
if (parser = params.delete(:parser))
|
||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||
|
@ -23,5 +27,9 @@ module Fog
|
|||
response
|
||||
end
|
||||
|
||||
def reset
|
||||
@excon.reset
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,20 +78,27 @@ module Fog
|
|||
def initialize(options={})
|
||||
credentials = Fog::Rackspace.authenticate(options)
|
||||
@auth_token = credentials['X-Auth-Token']
|
||||
|
||||
cdn_uri = URI.parse(credentials['X-CDN-Management-Url'])
|
||||
@cdn_host = cdn_uri.host
|
||||
@cdn_path = cdn_uri.path
|
||||
@cdn_port = cdn_uri.port
|
||||
@cdn_scheme = cdn_uri.scheme
|
||||
@cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}", options[:persistent])
|
||||
|
||||
storage_uri = URI.parse(credentials['X-Storage-Url'])
|
||||
@storage_host = storage_uri.host
|
||||
@storage_path = storage_uri.path
|
||||
@storage_port = storage_uri.port
|
||||
@storage_scheme = storage_uri.scheme
|
||||
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def cdn_request(params)
|
||||
@cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}")
|
||||
response = @cdn_connection.request(params.merge!({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
|
@ -107,7 +114,6 @@ module Fog
|
|||
end
|
||||
|
||||
def storage_request(params, parse_json = true, &block)
|
||||
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
||||
response = @storage_connection.request(params.merge!({
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
|
|
|
@ -73,10 +73,14 @@ module Fog
|
|||
@path = uri.path
|
||||
@port = uri.port
|
||||
@scheme = uri.scheme
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
begin
|
||||
response = @connection.request(params.merge!({
|
||||
:headers => {
|
||||
|
|
|
@ -54,10 +54,14 @@ module Fog
|
|||
@host = options[:host] || "api.slicehost.com"
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
params[:headers] ||= {}
|
||||
params[:headers].merge!({
|
||||
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}"
|
||||
|
|
|
@ -42,6 +42,7 @@ module Fog
|
|||
@path = options[:path] || Fog::Terremark::Ecloud::Defaults::PATH
|
||||
@port = options[:port] || Fog::Terremark::Ecloud::Defaults::PORT
|
||||
@scheme = options[:scheme] || Fog::Terremark::Ecloud::Defaults::SCHEME
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -51,8 +51,11 @@ module Fog
|
|||
response.headers['Set-Cookie']
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
unless @cookie
|
||||
@cookie = auth_token
|
||||
end
|
||||
|
|
|
@ -42,6 +42,7 @@ module Fog
|
|||
@path = options[:path] || Fog::Terremark::Vcloud::Defaults::PATH
|
||||
@port = options[:port] || Fog::Terremark::Vcloud::Defaults::PORT
|
||||
@scheme = options[:scheme] || Fog::Terremark::Vcloud::Defaults::SCHEME
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def default_vdc_id
|
||||
|
|
Загрузка…
Ссылка в новой задаче