bosh_cli 1.2311.0 → 1.2334.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -598,22 +598,26 @@ module Bosh
598
598
  @director_name ||= get_status['name']
599
599
  end
600
600
 
601
- def request(method, uri, content_type = nil, payload = nil,
602
- headers = {}, options = {})
603
- headers = headers.dup
604
- tmp_file = nil
605
-
601
+ def request(method, uri, content_type = nil, payload = nil, headers = {}, options = {})
602
+ headers = headers.dup
606
603
  headers['Content-Type'] = content_type if content_type
607
604
 
605
+ tmp_file = nil
606
+ response_reader = nil
608
607
  if options[:file]
609
608
  tmp_file = File.open(File.join(Dir.mktmpdir, 'streamed-response'), 'w')
610
-
611
609
  response_reader = lambda { |part| tmp_file.write(part) }
612
- else
613
- response_reader = nil
614
610
  end
615
611
 
616
- response = try_to_perform_http_request(method, "#{@scheme}://#{@director_ip}:#{@port}#{uri}", payload, headers, num_retries, retry_wait_interval, &response_reader)
612
+ response = try_to_perform_http_request(
613
+ method,
614
+ "#{@scheme}://#{@director_ip}:#{@port}#{uri}",
615
+ payload,
616
+ headers,
617
+ num_retries,
618
+ retry_wait_interval,
619
+ &response_reader
620
+ )
617
621
 
618
622
  if options[:file]
619
623
  tmp_file.close
@@ -640,7 +644,6 @@ module Bosh
640
644
 
641
645
  [response.code, body, headers]
642
646
 
643
-
644
647
  rescue SystemCallError => e
645
648
  raise DirectorError, "System call error while talking to director: #{e}"
646
649
  end
@@ -659,6 +662,19 @@ module Bosh
659
662
  end
660
663
  end
661
664
 
665
+ def try_to_perform_http_request(method, uri, payload, headers, num_retries, retry_wait_interval, &response_reader)
666
+ num_retries.downto(1) do |n|
667
+ begin
668
+ return perform_http_request(method, uri, payload, headers, &response_reader)
669
+
670
+ rescue DirectorInaccessible
671
+ warning("cannot access director, trying #{n-1} more times...") if n != 1
672
+ raise if n == 1
673
+ sleep(retry_wait_interval)
674
+ end
675
+ end
676
+ end
677
+
662
678
  def perform_http_request(method, uri, payload = nil, headers = {}, &block)
663
679
  http_client = HTTPClient.new
664
680
 
@@ -676,31 +692,23 @@ module Bosh
676
692
  Base64.encode64("#{@user}:#{@password}").strip
677
693
  end
678
694
 
679
- http_client.request(method, uri, :body => payload,
680
- :header => headers, &block)
695
+ http_client.request(method, uri, {
696
+ :body => payload,
697
+ :header => headers,
698
+ }, &block)
699
+
700
+ rescue URI::Error, SocketError, Errno::ECONNREFUSED, Timeout::Error, HTTPClient::TimeoutError => e
701
+ raise DirectorInaccessible, "cannot access director (#{e.message})"
681
702
 
682
703
  rescue HTTPClient::BadResponseError => e
683
704
  err("Received bad HTTP response from director: #{e}")
684
- rescue URI::Error, SocketError, SystemCallError
685
- raise # We handle these upstream
686
- rescue => e
687
- # httpclient (sadly) doesn't have a generic exception
705
+
706
+ # HTTPClient doesn't have a root exception but instead subclasses RuntimeError
707
+ rescue RuntimeError => e
688
708
  puts "Perform request #{method}, #{uri}, #{headers.inspect}, #{payload.inspect}"
689
709
  err("REST API call exception: #{e}")
690
710
  end
691
711
 
692
- def try_to_perform_http_request(method, uri, payload, headers, num_retries, retry_wait_interval, &response_reader)
693
- num_retries.downto(1) do |n|
694
- begin
695
- return perform_http_request(method, uri, payload, headers, &response_reader)
696
- rescue URI::Error, SocketError, Errno::ECONNREFUSED => e
697
- warning("cannot access director, trying #{n-1} more times...") if n != 1
698
- raise DirectorInaccessible, "cannot access director (#{e.message})" if n == 1
699
- sleep retry_wait_interval
700
- end
701
- end
702
- end
703
-
704
712
  def get_json(url)
705
713
  status, body = get_json_with_status(url)
706
714
  raise AuthError if status == 401
@@ -64,8 +64,10 @@ module Bosh::Cli::TaskTracking
64
64
  end
65
65
 
66
66
  def add_event(event)
67
- @total_duration.started_at = event['time']
68
- @total_duration.finished_at = event['time']
67
+ unless event['time'] == 0
68
+ @total_duration.started_at = event['time']
69
+ @total_duration.finished_at = event['time']
70
+ end
69
71
 
70
72
  if event['type'] == 'deprecation'
71
73
  show_deprecation(event)
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.2311.0'
3
+ VERSION = '1.2334.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2311.0
4
+ version: 1.2334.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-28 00:00:00.000000000 Z
12
+ date: 2014-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_common
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2311.0
21
+ version: 1.2334.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2311.0
29
+ version: 1.2334.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json_pure
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2311.0
117
+ version: 1.2334.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.2311.0
125
+ version: 1.2334.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: net-ssh
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,7 @@ dependencies:
269
269
  version: '0'
270
270
  description: ! 'BOSH CLI
271
271
 
272
- 7df356'
272
+ 839055'
273
273
  email: support@cloudfoundry.com
274
274
  executables:
275
275
  - bosh
@@ -380,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
380
  version: '0'
381
381
  segments:
382
382
  - 0
383
- hash: -598426764694286403
383
+ hash: 4124968515230087242
384
384
  requirements: []
385
385
  rubyforge_project:
386
386
  rubygems_version: 1.8.23