lib/vmc/client.rb in af-0.3.16.5 vs lib/vmc/client.rb in af-0.3.18.1

- old
+ new

@@ -4,11 +4,11 @@ # # require 'vmc' # client = VMC::Client.new('api.vcap.me') # client.login(:user, :pass) # client.create('myapplication', manifest) -# client.create_service('redis', 'my_redis_service', opts); +# client.create_service('aws', 'redis', 'my_redis_service', opts); # require 'rubygems' require 'json/pure' require 'open-uri' @@ -25,10 +25,13 @@ attr_accessor :trace # Error codes VMC_HTTP_ERROR_CODES = [ 400, 500 ] + HTTP_TIMEOUT = ENV['TIMEOUT'].to_i if ENV['TIMEOUT'] + HTTP_TIMEOUT ||= 10*60 + # Errors class BadTarget < RuntimeError; end class AuthError < RuntimeError; end class TargetError < RuntimeError; end class NotFound < RuntimeError; end @@ -165,11 +168,11 @@ def services check_login_status json_get(VMC::SERVICES_PATH) end - def create_service(service, name) + def create_service(infra,service, name) check_login_status services = services_info services ||= [] service_hash = nil @@ -182,10 +185,11 @@ if service == service_descr[:vendor] service_hash = { :type => service_descr[:type], :tier => 'free', :vendor => service, :version => version_str } + service_hash[:infra] = { :provider => infra } if infra break end end end end @@ -380,10 +384,10 @@ end req = { :method => method, :url => "#{@target}/#{path}", :payload => payload, :headers => headers, :multipart => true, - :timeout => 120, :open_timeout => 120 + :timeout => HTTP_TIMEOUT, :open_timeout => HTTP_TIMEOUT } status, body, response_headers = perform_http_request(req) if request_failed?(status) # FIXME, old cc returned 400 on not found for file access