bosh_cli 1.3091.0 → 1.3093.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3da859f230af3dcde0e0ce0a18b6c5419047a0e2
4
- data.tar.gz: d5fc1e4eeb9ab84372545f94bba14c02656fd0fc
3
+ metadata.gz: a6f0f6a01a728568c829a7dd5eb560be35876086
4
+ data.tar.gz: 75191afff90c2644f931c5c587b292e1fd85ade6
5
5
  SHA512:
6
- metadata.gz: 71d6c0c0d6b8a8fd4d7062a5c1b78e98aafec9bf6c74d5447868adb37b6a9968c341dc0dce9caf8e44f9645ddd77c21aed6b1991196e1d6922e9e8dcb7f02418
7
- data.tar.gz: 59a163acbf7983284b2dbc2aa41d287e4d6b1090ec3cb476c80d27104d5aa9d1b57a780dd81c17679ec27f85b6e4209a9636b7c51d791c4dd19519577c660772
6
+ metadata.gz: 860039081d2a22918caf7098525a80dfd1a5242a672fff3cd6afb171e64b53b9c7f1eabc37c982b6fdcaa99fdaa0b463640af3d79cd820e22bb262d365d646a3
7
+ data.tar.gz: b45e66e483540247760aea8256016d0ed47f1a1e339741353ffb68e9d11046b88dbce565ecd28da1dffcac7cb0965d52834856e372cb15247a0b151999721224
@@ -90,7 +90,7 @@ module Bosh
90
90
  options = options.dup
91
91
  options[:content_type] = 'application/x-compressed'
92
92
 
93
- upload_and_track(:post, '/stemcells', filename, options)
93
+ upload_and_track(:post, stemcells_path(options), filename, options)
94
94
  end
95
95
 
96
96
  def upload_remote_stemcell(stemcell_location, options = {})
@@ -99,7 +99,7 @@ module Bosh
99
99
  options[:payload] = JSON.generate(payload)
100
100
  options[:content_type] = 'application/json'
101
101
 
102
- request_and_track(:post, '/stemcells', options)
102
+ request_and_track(:post, stemcells_path(options), options)
103
103
  end
104
104
 
105
105
  def get_version
@@ -645,6 +645,12 @@ module Bosh
645
645
  path
646
646
  end
647
647
 
648
+ def stemcells_path(options = {})
649
+ path = '/stemcells'
650
+ path << "?fix=true" if options[:fix]
651
+ path
652
+ end
653
+
648
654
  def request(method, uri, content_type = nil, payload = nil, headers = {}, options = {})
649
655
  headers = headers.dup
650
656
  headers['Content-Type'] = content_type if content_type
@@ -723,12 +729,16 @@ module Bosh
723
729
  end
724
730
  end
725
731
 
726
- def perform_http_request(method, uri, payload = nil, headers = {}, &block)
727
- http_client = HTTPClient.new
732
+ def generate_http_client
733
+ @http_client ||= HTTPClient.new.tap do |http_client|
734
+ http_client.send_timeout = API_TIMEOUT
735
+ http_client.receive_timeout = API_TIMEOUT
736
+ http_client.connect_timeout = CONNECT_TIMEOUT
737
+ end
738
+ end
728
739
 
729
- http_client.send_timeout = API_TIMEOUT
730
- http_client.receive_timeout = API_TIMEOUT
731
- http_client.connect_timeout = CONNECT_TIMEOUT
740
+ def perform_http_request(method, uri, payload = nil, headers = {}, &block)
741
+ http_client = generate_http_client
732
742
 
733
743
  if @ca_cert.nil?
734
744
  http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -753,8 +763,8 @@ module Bosh
753
763
  begin
754
764
  cert_store = OpenSSL::X509::Store.new
755
765
  cert_store.add_file(@ca_cert)
756
- rescue OpenSSL::X509::StoreError
757
- err('Invalid SSL Cert')
766
+ rescue OpenSSL::X509::StoreError => e
767
+ err("Invalid SSL Cert for '#{uri}': #{e.message}")
758
768
  end
759
769
  http_client.ssl_config.cert_store = cert_store
760
770
  end
@@ -780,7 +790,7 @@ module Bosh
780
790
  OpenSSL::X509::StoreError => e
781
791
 
782
792
  if e.is_a?(OpenSSL::SSL::SSLError) && e.message.include?('certificate verify failed')
783
- err('Invalid SSL Cert')
793
+ err("Invalid SSL Cert for '#{uri}': #{e.message}")
784
794
  end
785
795
  raise DirectorInaccessible, "cannot access director (#{e.message})"
786
796
 
@@ -7,6 +7,7 @@ module Bosh::Cli::Command
7
7
  option '--details', 'Return detailed instance information'
8
8
  option '--dns', 'Return instance DNS A records'
9
9
  option '--vitals', 'Return instance vitals information'
10
+ option '--ps', "Return instance process information"
10
11
  def list()
11
12
  auth_required
12
13
  deployment_required
@@ -65,6 +66,7 @@ module Bosh::Cli::Command
65
66
  end
66
67
  t.headings = headings
67
68
 
69
+ s = instances.size
68
70
  sorted.each do |instance|
69
71
  job = "#{instance['job_name'] || 'unknown'}/#{instance['index'] || 'unknown'}"
70
72
  ips = Array(instance['ips']).join("\n")
@@ -115,6 +117,17 @@ module Bosh::Cli::Command
115
117
  end
116
118
 
117
119
  t << row
120
+ s -= 1
121
+ if options[:ps] && instance['processes']
122
+ instance['processes'].each do |process|
123
+ name = process['name']
124
+ state = process['state']
125
+ process_row = [" #{name}", "#{state}"]
126
+ (headings.size - 2).times { process_row << '' }
127
+ t << process_row
128
+ end
129
+ t << :separator if s > 0
130
+ end
118
131
  end
119
132
  end
120
133
 
@@ -27,13 +27,20 @@ module Bosh::Cli
27
27
  end
28
28
 
29
29
  usage 'upload stemcell'
30
- desc 'Upload stemcell (stemcell_location can be a local file or a remote URI)'
30
+ desc "Upload stemcell (stemcell_location can be a local file or a remote URI). \
31
+ Note that --skip-if-exists and --fix can not be used together."
31
32
  option '--skip-if-exists', 'skips upload if stemcell already exists'
33
+ option '--fix', 'replaces the stemcell if already exists'
32
34
  def upload(stemcell_location)
33
35
  auth_required
34
36
  show_current_state
35
37
 
38
+ if options[:skip_if_exists] && options[:fix]
39
+ err("Option '--skip-if-exists' and option '--fix' should not be used together")
40
+ end
41
+
36
42
  stemcell_type = stemcell_location =~ /^#{URI::regexp}$/ ? 'remote' : 'local'
43
+
37
44
  if stemcell_type == 'local'
38
45
  stemcell = Bosh::Cli::Stemcell.new(stemcell_location)
39
46
 
@@ -46,19 +53,16 @@ module Bosh::Cli
46
53
  err('Stemcell is invalid, please fix, verify and upload again')
47
54
  end
48
55
 
49
- say('Checking if stemcell already exists...')
50
56
  name = stemcell.manifest['name']
51
57
  version = stemcell.manifest['version']
52
58
 
53
- if exists?(name, version)
59
+ if !options[:fix] && exists?(name, version)
54
60
  if options[:skip_if_exists]
55
61
  say("Stemcell `#{name}/#{version}' already exists. Skipping upload.")
56
62
  return
57
63
  else
58
64
  err("Stemcell `#{name}/#{version}' already exists. Increment the version if it has changed.")
59
65
  end
60
- else
61
- say('No')
62
66
  end
63
67
 
64
68
  stemcell_location = stemcell.stemcell_file
@@ -71,7 +75,7 @@ module Bosh::Cli
71
75
  say("Using remote stemcell `#{stemcell_location}'")
72
76
  end
73
77
 
74
- status, task_id = apply_upload_stemcell_strategy(stemcell_type, stemcell_location)
78
+ status, task_id = apply_upload_stemcell_strategy(stemcell_type, stemcell_location, options[:fix]?{fix: true}:{})
75
79
  success_message = 'Stemcell uploaded and created.'
76
80
 
77
81
  if status == :error && options[:skip_if_exists] && last_event(task_id)['error']['code'] == STEMCELL_EXISTS_ERROR_CODE
@@ -140,11 +144,7 @@ module Bosh::Cli
140
144
 
141
145
  force = !!options[:force]
142
146
 
143
- say('Checking if stemcell exists...')
144
-
145
- unless exists?(name, version)
146
- err("Stemcell `#{name}/#{version}' does not exist")
147
- end
147
+ err("Stemcell `#{name}/#{version}' does not exist") unless exists?(name, version)
148
148
 
149
149
  say("You are going to delete stemcell `#{name}/#{version}'".make_red)
150
150
 
@@ -168,11 +168,11 @@ module Bosh::Cli
168
168
  end
169
169
  end
170
170
 
171
- def apply_upload_stemcell_strategy(stemcell_type, stemcell_location)
171
+ def apply_upload_stemcell_strategy(stemcell_type, stemcell_location, options={})
172
172
  if stemcell_type == 'local'
173
- director.upload_stemcell(stemcell_location)
173
+ director.upload_stemcell(stemcell_location, options)
174
174
  else
175
- director.upload_remote_stemcell(stemcell_location)
175
+ director.upload_remote_stemcell(stemcell_location, options)
176
176
  end
177
177
  end
178
178
 
@@ -182,10 +182,11 @@ module Bosh::Cli
182
182
  end
183
183
 
184
184
  def exists?(name, version)
185
+ say('Checking if stemcell already exists...')
185
186
  existing = director.list_stemcells.select do |sc|
186
187
  sc['name'] == name && sc['version'] == version
187
188
  end
188
-
189
+ existing.empty? ? say('No'):say('Yes')
189
190
  !existing.empty?
190
191
  end
191
192
 
@@ -13,7 +13,10 @@ module Bosh::Cli::TaskTracking
13
13
  def initialize(director, task_id, options = {})
14
14
  @director = director
15
15
  @task_id = task_id
16
- @task_success_state = options[:task_success_state] || :done
16
+ @task_finished_states = 'done error cancelled'
17
+ if(options[:task_success_state])
18
+ @task_finished_states << options[:task_success_state].to_s
19
+ end
17
20
  @options = options
18
21
 
19
22
  @quiet = !!options[:quiet]
@@ -140,7 +143,7 @@ module Bosh::Cli::TaskTracking
140
143
  end
141
144
 
142
145
  def finished?(state)
143
- "#{@task_success_state} error cancelled".include?(state)
146
+ @task_finished_states.include?(state)
144
147
  end
145
148
 
146
149
  def interactive?
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.3091.0'
3
+ VERSION = '1.3093.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3091.0
4
+ version: 1.3093.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3091.0
19
+ version: 1.3093.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3091.0
26
+ version: 1.3093.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh-template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3091.0
33
+ version: 1.3093.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3091.0
40
+ version: 1.3093.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cf-uaa-lib
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3091.0
131
+ version: 1.3093.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.3091.0
138
+ version: 1.3093.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement