bosh_cli 1.3202.0 → 1.3213.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57bf0c54be21cb26fe042e6cb2a3153187a4a9a9
4
- data.tar.gz: b2639e85670849be3a505b9f4d99ca2784a2814d
3
+ metadata.gz: 4d71ef21dc5730f51080af4a6a321428c098779d
4
+ data.tar.gz: 6358116553ae88c116dccf01e748a50c41f20b53
5
5
  SHA512:
6
- metadata.gz: 6593b135fbd3099be5a2f6e68df6fc50ab46ead9583e4d1b13ea216efea37ffa6497f1bf1bdb0f608f7227b302ec41cde2ebe21dbb13280dc4dcb6c91823b07a
7
- data.tar.gz: 33af5651442751fca69b45a64c530ec561085b72cab80a66abe1217e6fb69491b23e5f01ead8a1bc8bebc85b2c8ff2e40f80d3e01b73e49fa1ac7b90b4f97c20
6
+ metadata.gz: d1166bcbe2ef187d5d72836935a281b4220e831187e8e1d5ee816fad44e6857b3faf82c667b61732d5eb6e66677173a0704b8b5ab8de5d9ecd24a8bae4922e9c
7
+ data.tar.gz: e1326d025425c8a866cfbe9b9612e919d8bfe19466be13a9f986b2746b0b2cca6fccf0bf52be0fe3fc2089ee3f684376467bb2d54fc02a82b4e14759f725f8ff
@@ -1,6 +1,7 @@
1
1
  require 'cli/core_ext'
2
2
  require 'cli/errors'
3
3
  require 'cli/cloud_config'
4
+ require 'cli/runtime_config'
4
5
 
5
6
  require 'json'
6
7
  require 'httpclient'
@@ -127,12 +128,20 @@ module Bosh
127
128
  get_json("/deployments/#{deployment_name}/errands")
128
129
  end
129
130
 
130
- def list_running_tasks(verbose = 1)
131
- get_json("/tasks?state=processing,cancelling,queued&verbose=#{verbose}")
131
+ def list_running_tasks(verbose = 1, deployment_name = nil)
132
+ if deployment_name
133
+ get_json("/tasks?state=processing,cancelling,queued&verbose=#{verbose}&deployment=#{deployment_name}")
134
+ else
135
+ get_json("/tasks?state=processing,cancelling,queued&verbose=#{verbose}")
136
+ end
132
137
  end
133
138
 
134
- def list_recent_tasks(count = 30, verbose = 1)
135
- get_json("/tasks?limit=#{count}&verbose=#{verbose}")
139
+ def list_recent_tasks(count = 30, verbose = 1, deployment_name = nil)
140
+ if deployment_name
141
+ get_json("/tasks?limit=#{count}&verbose=#{verbose}&deployment=#{deployment_name}")
142
+ else
143
+ get_json("/tasks?limit=#{count}&verbose=#{verbose}")
144
+ end
136
145
  end
137
146
 
138
147
  def get_release(name)
@@ -266,12 +275,15 @@ module Bosh
266
275
  request_and_track(:post, add_query_string(url, extras), options)
267
276
  end
268
277
 
269
- def diff_deployment(name, manifest_yaml)
270
- status, body = post("/deployments/#{name}/diff", 'text/yaml', manifest_yaml)
278
+ def diff_deployment(name, manifest_yaml, no_redact = false)
279
+ redact_param = no_redact ? '?redact=false' : ''
280
+ uri = "/deployments/#{name}/diff#{redact_param}"
281
+ status, body = post(uri, 'text/yaml', manifest_yaml)
282
+
271
283
  if status == 200
272
284
  JSON.parse(body)
273
285
  else
274
- err(parse_error_message(status, body))
286
+ err(parse_error_message(status, body, uri))
275
287
  end
276
288
  end
277
289
 
@@ -545,12 +557,7 @@ module Bosh
545
557
  body = nil if response_code == 416
546
558
  end
547
559
 
548
- # backward compatible with renaming soap log to cpi log
549
- if response_code == 204 && log_type == 'cpi'
550
- get_task_output(task_id, offset, 'soap')
551
- else
552
- [body, new_offset]
553
- end
560
+ [body, new_offset]
554
561
  end
555
562
 
556
563
  def cancel_task(task_id)
@@ -669,6 +676,22 @@ module Bosh
669
676
  status == 201
670
677
  end
671
678
 
679
+ def get_runtime_config
680
+ _, runtime_configs = get_json_with_status('/runtime_configs?limit=1')
681
+ latest = runtime_configs.first
682
+
683
+ if !latest.nil?
684
+ Bosh::Cli::RuntimeConfig.new(
685
+ properties: latest["properties"],
686
+ created_at: latest["created_at"])
687
+ end
688
+ end
689
+
690
+ def update_runtime_config(runtime_config_yaml)
691
+ status, _ = post('/runtime_configs', 'text/yaml', runtime_config_yaml)
692
+ status == 201
693
+ end
694
+
672
695
  def cleanup(config = {})
673
696
  options = {}
674
697
  options[:payload] = JSON.generate('config' => config)
@@ -82,13 +82,15 @@ module Bosh::Cli::Command
82
82
  desc 'Deploy according to the currently selected deployment manifest'
83
83
  option '--recreate', 'Recreate all VMs in deployment'
84
84
  option '--redact-diff', 'Redact manifest value changes in deployment'
85
+ option '--no-redact', 'do not redact'
85
86
  option '--skip-drain [job1,job2]', String, 'Skip drain script for either specific or all jobs'
86
87
  def perform
87
88
  auth_required
88
89
  recreate = !!options[:recreate]
89
90
  redact_diff = !!options[:redact_diff]
90
-
91
+ no_redact = !options[:no_redact].nil?
91
92
  manifest = build_manifest
93
+
92
94
  if manifest.hash['releases']
93
95
  manifest.hash['releases'].each do |release|
94
96
  if release['url'].blank?
@@ -138,7 +140,7 @@ module Bosh::Cli::Command
138
140
 
139
141
  manifest = prepare_deployment_manifest(resolve_properties: true, show_state: true)
140
142
 
141
- context = DeploymentDiff.new(director, manifest).print({redact_diff: redact_diff})
143
+ context = DeploymentDiff.new(director, manifest).print({redact_diff: redact_diff, no_redact: no_redact})
142
144
  say('Please review all changes carefully'.make_yellow) if interactive?
143
145
 
144
146
  header('Deploying')
@@ -188,69 +190,6 @@ module Bosh::Cli::Command
188
190
  end
189
191
  end
190
192
 
191
- # bosh validate jobs
192
- usage 'validate jobs'
193
- desc 'Validates all jobs in the current release using current ' +
194
- 'deployment manifest as the source of properties'
195
- def validate_jobs
196
- check_if_release_dir
197
- manifest = prepare_deployment_manifest(:resolve_properties => true, show_state: true)
198
-
199
- if manifest.hash['release']
200
- release_name = manifest.hash['release']['name']
201
- elsif manifest.hash['releases'].count > 1
202
- err('Cannot validate a deployment manifest with more than 1 release')
203
- else
204
- release_name = manifest.hash['releases'].first['name']
205
- end
206
- if release_name == release.dev_name || release_name == release.final_name
207
- nl
208
- say('Analyzing release directory...'.make_yellow)
209
- else
210
- err('This release was not found in deployment manifest')
211
- end
212
-
213
- say(' - discovering packages')
214
- packages = Bosh::Cli::Resources::Package.discover(work_dir)
215
-
216
- say(' - discovering jobs')
217
- jobs = Bosh::Cli::Resources::Job.discover(
218
- work_dir,
219
- # TODO: be sure this is covered in integration
220
- packages.map {|package| package['name']}
221
- )
222
-
223
- say(' - validating properties')
224
- validator = Bosh::Cli::JobPropertyValidator.new(jobs, manifest.hash)
225
- validator.validate
226
-
227
- unless validator.jobs_without_properties.empty?
228
- nl
229
- say('Legacy jobs (no properties defined): '.make_yellow)
230
- validator.jobs_without_properties.sort { |a, b|
231
- a.name <=> b.name
232
- }.each do |job|
233
- say(" - #{job.name}")
234
- end
235
- end
236
-
237
- if validator.template_errors.empty?
238
- nl
239
- say('No template errors found'.make_green)
240
- else
241
- nl
242
- say('Template errors: '.make_yellow)
243
- validator.template_errors.each do |error|
244
- nl
245
- path = Pathname.new(error.template_path)
246
- rel_path = path.relative_path_from(Pathname.new(release.dir))
247
-
248
- say(" - #{rel_path}:")
249
- say(" line #{error.line}:".make_yellow + " #{error.exception.to_s}")
250
- end
251
- end
252
- end
253
-
254
193
  # bosh deployments
255
194
  usage 'deployments'
256
195
  desc 'Show the list of available deployments'
@@ -7,7 +7,8 @@ module Bosh::Cli::Command
7
7
 
8
8
  def print(options)
9
9
  begin
10
- changes = @director.diff_deployment(@manifest.name, @manifest.yaml)
10
+ no_redact = options[:no_redact]
11
+ changes = @director.diff_deployment(@manifest.name, @manifest.yaml, no_redact)
11
12
  diff = changes['diff']
12
13
 
13
14
  header('Detecting deployment changes')
@@ -24,17 +24,29 @@ module Bosh::Cli::Command
24
24
  say(packages_table.render)
25
25
  end
26
26
 
27
+ private
28
+
27
29
  def build_jobs_table(release)
28
30
  table do |t|
29
- t.headings = 'Job', 'Fingerprint', 'Blobstore ID', 'SHA1'
30
- release['jobs'].each do |job|
31
+ t.headings = 'Job', 'Fingerprint', 'Blobstore ID', 'SHA1', 'Links Consumed', 'Links Provided'
32
+
33
+ release['jobs'].each_with_index do |job, index|
34
+
35
+ consumed_links = (job['consumes'].nil? ? '' : YAML.dump(job['consumes']).sub("---\n", ''))
36
+ provided_links = (job['provides'].nil? ? '' : YAML.dump(job['provides']).sub("---\n", ''))
37
+
38
+ color = (index.even? ? :yellow : :green)
39
+
31
40
  row = [
32
- job['name'].make_yellow,
33
- job['fingerprint'].make_yellow,
34
- job['blobstore_id'].make_yellow,
35
- job['sha1'].make_yellow]
41
+ job['name'].make_color(color),
42
+ job['fingerprint'].make_color(color),
43
+ job['blobstore_id'].make_color(color),
44
+ job['sha1'].make_color(color),
45
+ consumed_links.make_color(color),
46
+ provided_links.make_color(color)]
36
47
  t << row
37
48
  end
49
+
38
50
  end
39
51
  end
40
52
 
@@ -0,0 +1,34 @@
1
+ require 'cli/core_ext'
2
+
3
+ module Bosh::Cli::Command
4
+ class RuntimeConfig < Base
5
+ usage 'runtime-config'
6
+ desc 'Download the current runtime config for the director'
7
+
8
+ def show
9
+ auth_required
10
+ show_current_state
11
+
12
+ config = director.get_runtime_config
13
+ if !config.nil?
14
+ say(config.properties)
15
+ end
16
+ end
17
+
18
+ usage 'update runtime-config'
19
+ desc 'Update the current runtime config for the director'
20
+
21
+ def update(runtime_config_path)
22
+ auth_required
23
+ show_current_state
24
+
25
+ runtime_config_yaml = read_yaml_file(runtime_config_path)
26
+
27
+ if director.update_runtime_config(runtime_config_yaml)
28
+ say("Successfully updated runtime config")
29
+ else
30
+ err("Failed to update runtime config")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -66,11 +66,12 @@ module Bosh::Cli::Command
66
66
  usage "tasks"
67
67
  desc "Show running tasks"
68
68
  option "--no-filter", INCLUDE_ALL
69
+ option "--deployment DEPLOYMENT_NAME", "Show tasks for given deployment"
69
70
  def list_running
70
71
  auth_required
71
72
  show_current_state
72
73
  use_filter = !options.key?(:no_filter)
73
- tasks = director.list_running_tasks(get_verbose_level(use_filter))
74
+ tasks = director.list_running_tasks(get_verbose_level(use_filter), options[:deployment])
74
75
  err("No running tasks") if tasks.empty?
75
76
  show_tasks_table(tasks.sort_by { |t| t["id"].to_i * -1 })
76
77
  say("Total tasks running now: %d" % [tasks.size])
@@ -80,11 +81,12 @@ module Bosh::Cli::Command
80
81
  usage "tasks recent"
81
82
  desc "Show <number> recent tasks"
82
83
  option "--no-filter", INCLUDE_ALL
84
+ option "--deployment DEPLOYMENT_NAME", "Show tasks for given deployment"
83
85
  def list_recent(count = 30)
84
86
  auth_required
85
87
  show_current_state
86
88
  use_filter = !options.key?(:no_filter)
87
- tasks = director.list_recent_tasks(count, get_verbose_level(use_filter))
89
+ tasks = director.list_recent_tasks(count, get_verbose_level(use_filter), options[:deployment])
88
90
  err("No recent tasks") if tasks.empty?
89
91
  show_tasks_table(tasks)
90
92
  say("Showing #{tasks.size} recent #{tasks.size == 1 ? "task" : "tasks"}")
@@ -117,9 +119,9 @@ module Bosh::Cli::Command
117
119
  def show_tasks_table(tasks)
118
120
  return if tasks.empty?
119
121
  tasks_table = table do |t|
120
- t.headings = "#", "State", "Timestamp", "User", "Description", "Result"
122
+ t.headings = "#", "State", "Timestamp", "User", "Deployment", "Description", "Result"
121
123
  tasks.map do |task|
122
- t << [task["id"], task["state"], Time.at(task["timestamp"]).utc, task["user"],
124
+ t << [task["id"], task["state"], Time.at(task["timestamp"]).utc, task["user"], task["deployment"],
123
125
  task["description"].to_s, task["result"].to_s.truncate(80)]
124
126
  end
125
127
  end
data/lib/cli/errors.rb CHANGED
@@ -49,6 +49,7 @@ module Bosh
49
49
  class InvalidManifest < CliError; error_code(514); end
50
50
  class PropertyMismatch < CliError; error_code(515); end
51
51
  class InvalidPropertyMapping < CliError; error_code(516); end
52
+ class InvalidLinks < CliError; error_code(517); end
52
53
 
53
54
  class ReleaseVersionError < CliError; error_code(600); end
54
55
  end
@@ -28,23 +28,23 @@ module Bosh::Cli
28
28
  end
29
29
 
30
30
  unless @manifest["jobs"].is_a?(Array)
31
- bad_manifest("Invalid jobs format in deployment " +
31
+ bad_manifest("Invalid instance groups format in deployment " +
32
32
  "manifest, Array expected, #{@manifest["jobs"].class} given")
33
33
  end
34
34
 
35
35
  @manifest["jobs"].each do |job|
36
36
  unless job.is_a?(Hash)
37
- bad_manifest("Invalid job spec in the manifest " +
37
+ bad_manifest("Invalid instance group spec in the manifest " +
38
38
  "Hash expected, #{job.class} given")
39
39
  end
40
40
 
41
41
  job_name = job["name"]
42
42
  if job_name.nil?
43
- bad_manifest("Manifest contains at least one job without name")
43
+ bad_manifest("Manifest contains at least one instance group without name")
44
44
  end
45
45
 
46
46
  if job["template"].nil?
47
- bad_manifest("Job '#{job_name}' doesn't have a template")
47
+ bad_manifest("Instance group '#{job_name}' doesn't have a job")
48
48
  end
49
49
  end
50
50
 
@@ -68,7 +68,7 @@ module Bosh::Cli
68
68
  built_job = @built_jobs[job_spec["template"]]
69
69
 
70
70
  if built_job.nil?
71
- raise CliError, "Job '#{job_spec["template"]}' has not been built"
71
+ raise CliError, "Instance group '#{job_spec["template"]}' has not been built"
72
72
  end
73
73
 
74
74
  collection = JobPropertyCollection.new(
@@ -0,0 +1,10 @@
1
+ module Bosh
2
+ module Cli
3
+ class RuntimeConfig < Struct.new(:properties, :created_at)
4
+ def initialize(attrs)
5
+ self.properties = attrs.fetch(:properties)
6
+ self.created_at = attrs.fetch(:created_at)
7
+ end
8
+ end
9
+ end
10
+ end
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.3202.0'
3
+ VERSION = '1.3213.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.3202.0
4
+ version: 1.3213.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2016-03-13 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.3202.0
19
+ version: 1.3213.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.3202.0
26
+ version: 1.3213.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.3202.0
33
+ version: 1.3213.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.3202.0
40
+ version: 1.3213.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.3202.0
131
+ version: 1.3213.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.3202.0
138
+ version: 1.3213.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -384,6 +384,7 @@ files:
384
384
  - lib/cli/commands/release/upload_release.rb
385
385
  - lib/cli/commands/release/verify_release.rb
386
386
  - lib/cli/commands/restore.rb
387
+ - lib/cli/commands/runtime_config.rb
387
388
  - lib/cli/commands/snapshot.rb
388
389
  - lib/cli/commands/ssh.rb
389
390
  - lib/cli/commands/stemcell.rb
@@ -427,6 +428,7 @@ files:
427
428
  - lib/cli/resources/package.rb
428
429
  - lib/cli/resurrection.rb
429
430
  - lib/cli/runner.rb
431
+ - lib/cli/runtime_config.rb
430
432
  - lib/cli/sorted_release_archiver.rb
431
433
  - lib/cli/source_control/git_ignore.rb
432
434
  - lib/cli/ssh_session.rb