bosh_cli 1.3215.4.0 → 1.3232.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli.rb +1 -0
  3. data/lib/cli/base_command.rb +1 -1
  4. data/lib/cli/basic_login_strategy.rb +3 -3
  5. data/lib/cli/blob_manager.rb +14 -14
  6. data/lib/cli/client/director.rb +16 -5
  7. data/lib/cli/commands/backup.rb +2 -2
  8. data/lib/cli/commands/cloudcheck.rb +2 -2
  9. data/lib/cli/commands/deployment.rb +22 -22
  10. data/lib/cli/commands/deployment_diff.rb +7 -3
  11. data/lib/cli/commands/disks.rb +1 -1
  12. data/lib/cli/commands/errand.rb +2 -2
  13. data/lib/cli/commands/events.rb +55 -0
  14. data/lib/cli/commands/help.rb +1 -1
  15. data/lib/cli/commands/job.rb +3 -3
  16. data/lib/cli/commands/job_management.rb +1 -1
  17. data/lib/cli/commands/locks.rb +6 -4
  18. data/lib/cli/commands/login.rb +1 -1
  19. data/lib/cli/commands/misc.rb +4 -4
  20. data/lib/cli/commands/package.rb +3 -3
  21. data/lib/cli/commands/property_management.rb +8 -8
  22. data/lib/cli/commands/release/delete_release.rb +3 -3
  23. data/lib/cli/commands/release/export_release.rb +2 -2
  24. data/lib/cli/commands/release/finalize_release.rb +26 -12
  25. data/lib/cli/commands/release/upload_release.rb +2 -2
  26. data/lib/cli/commands/release/verify_release.rb +2 -2
  27. data/lib/cli/commands/restore.rb +3 -3
  28. data/lib/cli/commands/snapshot.rb +5 -5
  29. data/lib/cli/commands/ssh.rb +2 -2
  30. data/lib/cli/commands/stemcell.rb +8 -8
  31. data/lib/cli/commands/task.rb +4 -4
  32. data/lib/cli/commands/user.rb +3 -3
  33. data/lib/cli/commands/vms.rb +1 -1
  34. data/lib/cli/config.rb +1 -1
  35. data/lib/cli/core_ext.rb +4 -4
  36. data/lib/cli/deployment_manifest_compiler.rb +1 -1
  37. data/lib/cli/file_with_progress_bar.rb +2 -0
  38. data/lib/cli/job_property_collection.rb +2 -2
  39. data/lib/cli/job_state.rb +2 -2
  40. data/lib/cli/logs_downloader.rb +1 -1
  41. data/lib/cli/manifest.rb +3 -3
  42. data/lib/cli/public_stemcell_presenter.rb +3 -3
  43. data/lib/cli/release.rb +3 -3
  44. data/lib/cli/release_compiler.rb +2 -2
  45. data/lib/cli/release_tarball.rb +2 -1
  46. data/lib/cli/runner.rb +1 -1
  47. data/lib/cli/sorted_release_archiver.rb +1 -12
  48. data/lib/cli/uaa_login_strategy.rb +1 -1
  49. data/lib/cli/version.rb +1 -1
  50. data/lib/cli/versions/local_artifact_storage.rb +2 -2
  51. data/lib/cli/versions/releases_dir_migrator.rb +3 -3
  52. data/lib/cli/versions/version_file_resolver.rb +1 -1
  53. data/lib/cli/versions/versions_index.rb +10 -11
  54. metadata +9 -8
@@ -0,0 +1,55 @@
1
+ module Bosh::Cli::Command
2
+ class Events < Base
3
+ usage 'events'
4
+ desc 'Show all deployment events'
5
+ option '--before-id id', Integer, 'Show all events with id less or equal to given id'
6
+ option '--deployment name', String, 'filter all events by the Deployment Name'
7
+ option '--task id', String, 'filter all events by the task id'
8
+ option '--instance job_name/id', String, 'filter all events by the instance job_name/id'
9
+
10
+
11
+ def list
12
+ auth_required
13
+ show_events
14
+ end
15
+
16
+ private
17
+ def show_events
18
+ events = director.list_events(options)
19
+ if events.empty?
20
+ nl
21
+ say('No events')
22
+ nl
23
+ return
24
+ end
25
+
26
+ events_table = table do |t|
27
+ headings = ['ID', 'Time', 'User', 'Action', 'Object type', 'Object ID', 'Task', 'Dep', 'Inst', 'Context']
28
+ t.headings = headings
29
+
30
+ events.each do |event|
31
+ row = []
32
+ id = event['id']
33
+ id = "#{id} <- #{event['parent_id']}" if event['parent_id']
34
+ row << id
35
+ row << Time.at(event['timestamp']).utc.strftime('%a %b %d %H:%M:%S %Z %Y')
36
+ row << event['user']
37
+ row << event['action']
38
+ row << event['object_type']
39
+ row << event.fetch('object_name', '-')
40
+ row << event.fetch('task', '-')
41
+ row << event.fetch('deployment', '-')
42
+ row << event.fetch('instance', '-')
43
+ context = event['error'] ? {'error' => event['error'].to_s.truncate(80)}.merge(event['context']) : event['context']
44
+ context = context.empty? ? '-' : context.map { |k, v| "#{k}: #{v}" }.join(",\n")
45
+ row << context
46
+ t << row
47
+ end
48
+ end
49
+
50
+ nl
51
+ say(events_table)
52
+ nl
53
+ end
54
+ end
55
+ end
@@ -54,7 +54,7 @@ module Bosh::Cli::Command
54
54
  end
55
55
  end
56
56
 
57
- err("No help found for command `#{keywords.join(' ')}'. Run 'bosh help --all' to see all available BOSH commands.") if good_matches.empty?
57
+ err("No help found for command '#{keywords.join(' ')}'. Run `bosh help --all` to see all available BOSH commands.") if good_matches.empty?
58
58
 
59
59
  self.class.list_commands(good_matches)
60
60
  end
@@ -10,13 +10,13 @@ module Bosh::Cli::Command
10
10
  check_if_release_dir
11
11
 
12
12
  unless name.bosh_valid_id?
13
- err("`#{name}' is not a valid BOSH id")
13
+ err("'#{name}' is not a valid BOSH id")
14
14
  end
15
15
 
16
16
  job_dir = File.join("jobs", name)
17
17
 
18
18
  if File.exists?(job_dir)
19
- err("Job `#{name}' already exists, please pick another name")
19
+ err("Job '#{name}' already exists, please pick another name")
20
20
  end
21
21
 
22
22
  say("create\t#{job_dir}")
@@ -38,7 +38,7 @@ module Bosh::Cli::Command
38
38
  f.write("---\nname: #{name}\ntemplates:\n\npackages:\n")
39
39
  end
40
40
 
41
- say("\nGenerated skeleton for `#{name}' job in `#{job_dir}'")
41
+ say("\nGenerated skeleton for '#{name}' job in '#{job_dir}'")
42
42
  end
43
43
 
44
44
  end
@@ -82,7 +82,7 @@ module Bosh::Cli
82
82
  end
83
83
 
84
84
  if !hard_and_soft_options_allowed?(operation) && (hard? || soft?)
85
- err("--hard and --soft options only make sense for `stop' operation")
85
+ err("--hard and --soft options only make sense for 'stop' operation")
86
86
  end
87
87
 
88
88
  manifest
@@ -1,6 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
- # Copyright (c) 2013 GoPivotal, Inc.
3
-
4
1
  module Bosh::Cli::Command
5
2
  class Locks < Base
6
3
 
@@ -11,7 +8,12 @@ module Bosh::Cli::Command
11
8
  show_current_state
12
9
 
13
10
  locks = director.list_locks
14
- err('No locks') if locks.empty?
11
+ if locks.empty?
12
+ nl
13
+ say('No locks')
14
+ nl
15
+ return
16
+ end
15
17
 
16
18
  show_locks_table(locks)
17
19
  say("Locks total: %d" % locks.size)
@@ -24,7 +24,7 @@ module Bosh::Cli::Command
24
24
  target_required
25
25
  config.set_credentials(target, nil)
26
26
  config.save
27
- say("You are no longer logged in to `#{target}'".make_yellow)
27
+ say("You are no longer logged in to '#{target}'".make_yellow)
28
28
  end
29
29
 
30
30
  private
@@ -89,7 +89,7 @@ module Bosh::Cli::Command
89
89
  rescue Bosh::Cli::AuthError
90
90
  status = {}
91
91
  rescue Bosh::Cli::DirectorError
92
- err("Cannot talk to director at `#{director_url}', " +
92
+ err("Cannot talk to director at '#{director_url}', " +
93
93
  "please set correct target")
94
94
  end
95
95
 
@@ -101,7 +101,7 @@ module Bosh::Cli::Command
101
101
  old_ca_cert_path = config.ca_cert
102
102
  expanded_ca_cert_path = config.save_ca_cert_path(options[:ca_cert])
103
103
  if old_ca_cert_path != expanded_ca_cert_path
104
- say("Updating certificate file path to `#{expanded_ca_cert_path.to_s.make_green}'")
104
+ say("Updating certificate file path to '#{expanded_ca_cert_path.to_s.make_green}'")
105
105
  nl
106
106
  end
107
107
 
@@ -114,7 +114,7 @@ module Bosh::Cli::Command
114
114
  end
115
115
 
116
116
  config.save
117
- say("Target set to `#{target_name.make_green}'")
117
+ say("Target set to '#{target_name.make_green}'")
118
118
 
119
119
  if interactive? && !logged_in?
120
120
  redirect("login")
@@ -146,7 +146,7 @@ module Bosh::Cli::Command
146
146
  def set_alias(name, command)
147
147
  config.set_alias(:cli, name, command.to_s.strip)
148
148
  config.save
149
- say("Alias `#{name.make_green}' created for command `#{command.make_green}'")
149
+ say("Alias '#{name.make_green}' created for command '#{command.make_green}'")
150
150
  end
151
151
 
152
152
  # bosh aliases
@@ -9,13 +9,13 @@ module Bosh::Cli::Command
9
9
  check_if_release_dir
10
10
 
11
11
  unless name.bosh_valid_id?
12
- err("`#{name}' is not a vaild BOSH id")
12
+ err("'#{name}' is not a vaild BOSH id")
13
13
  end
14
14
 
15
15
  package_dir = File.join("packages", name)
16
16
 
17
17
  if File.exists?(package_dir)
18
- err("Package `#{name}' already exists, please pick another name")
18
+ err("Package '#{name}' already exists, please pick another name")
19
19
  end
20
20
 
21
21
  say("create\t#{package_dir}")
@@ -35,7 +35,7 @@ module Bosh::Cli::Command
35
35
  "---\nname: #{name}\n\ndependencies:\n\nfiles:\n"
36
36
  end
37
37
 
38
- say("\nGenerated skeleton for `#{name}' package in `#{package_dir}'")
38
+ say("\nGenerated skeleton for '#{name}' package in '#{package_dir}'")
39
39
  end
40
40
 
41
41
  private
@@ -17,14 +17,14 @@ module Bosh::Cli::Command
17
17
  end
18
18
 
19
19
  if existing_property
20
- say("Current `#{name.make_green}' value is " +
21
- "`#{format_property(body["value"]).make_green}'")
20
+ say("Current '#{name.make_green}' value is " +
21
+ "'#{format_property(body["value"]).make_green}'")
22
22
  else
23
23
  say("This will be a new property")
24
24
  end
25
25
 
26
26
  prompt = "Are you sure you want to set property" +
27
- " `#{name.make_green}' to `#{format_property(value).make_green}'?"
27
+ " '#{name.make_green}' to '#{format_property(value).make_green}'?"
28
28
 
29
29
  unless confirmed?(prompt)
30
30
  err("Canceled")
@@ -37,7 +37,7 @@ module Bosh::Cli::Command
37
37
  end
38
38
 
39
39
  if status == 204
40
- say("Property `#{name.make_green}' set to `#{value.make_green}'")
40
+ say("Property '#{name.make_green}' set to '#{value.make_green}'")
41
41
  else
42
42
  err(director.parse_error_message(status, body))
43
43
  end
@@ -51,7 +51,7 @@ module Bosh::Cli::Command
51
51
  show_header
52
52
 
53
53
  prompt = "Are you sure you want to unset property " +
54
- "`#{name.make_green}'?"
54
+ "'#{name.make_green}'?"
55
55
 
56
56
  unless confirmed?(prompt)
57
57
  err("Canceled")
@@ -60,7 +60,7 @@ module Bosh::Cli::Command
60
60
  status, body = director.delete_property(@deployment_name, name)
61
61
 
62
62
  if status == 204
63
- say("Property `#{name.make_green}' has been unset")
63
+ say("Property '#{name.make_green}' has been unset")
64
64
  else
65
65
  err(director.parse_error_message(status, body))
66
66
  end
@@ -75,8 +75,8 @@ module Bosh::Cli::Command
75
75
 
76
76
  status, body = director.get_property(@deployment_name, name)
77
77
  if status == 200
78
- say("Property `#{name.make_green}' value is " +
79
- "`#{format_property(body["value"]).make_green}'")
78
+ say("Property '#{name.make_green}' value is " +
79
+ "'#{format_property(body["value"]).make_green}'")
80
80
  else
81
81
  err(director.parse_error_message(status, body))
82
82
  end
@@ -14,14 +14,14 @@ module Bosh::Cli::Command
14
14
  desc << "/#{version}" if version
15
15
 
16
16
  if force
17
- say("Deleting `#{desc}' (FORCED DELETE, WILL IGNORE ERRORS)".make_red)
17
+ say("Deleting '#{desc}' (FORCED DELETE, WILL IGNORE ERRORS)".make_red)
18
18
  else
19
- say("Deleting `#{desc}'".make_red)
19
+ say("Deleting '#{desc}'".make_red)
20
20
  end
21
21
 
22
22
  if confirmed?
23
23
  status, task_id = director.delete_release(name, force: force, version: version)
24
- task_report(status, task_id, "Deleted `#{desc}'")
24
+ task_report(status, task_id, "Deleted '#{desc}'")
25
25
  else
26
26
  say('Canceled deleting release'.make_green)
27
27
  end
@@ -43,10 +43,10 @@ module Bosh::Cli::Command
43
43
  progress_renderer.finish(tarball_file_name, "downloaded")
44
44
 
45
45
  if file_checksum(tarball_file_path) != tarball_sha1
46
- err("Checksum mismatch for downloaded blob `#{tarball_file_path}'")
46
+ err("Checksum mismatch for downloaded blob '#{tarball_file_path}'")
47
47
  end
48
48
 
49
- task_report(status, task_id, "Exported release `#{release.name.make_green}/#{release.version.make_green}` for `#{stemcell_os.make_green}/#{stemcell.version.make_green}`")
49
+ task_report(status, task_id, "Exported release '#{release.name.make_green}/#{release.version.make_green}' for '#{stemcell_os.make_green}/#{stemcell.version.make_green}'")
50
50
  end
51
51
 
52
52
  # Returns file SHA1 checksum
@@ -42,7 +42,9 @@ module Bosh::Cli::Command
42
42
  manifest["version"] = final_release_ver
43
43
  manifest["name"] = final_release_name
44
44
 
45
- tarball.replace_manifest(manifest)
45
+ updated_manifest = upload_package_and_job_blobs(manifest, tarball)
46
+
47
+ tarball.replace_manifest(updated_manifest)
46
48
 
47
49
  FileUtils.mkdir_p(final_release_dir)
48
50
  final_release_manifest_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.yml"))
@@ -55,8 +57,6 @@ module Bosh::Cli::Command
55
57
  final_release_tarball_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.tgz"))
56
58
  tarball.create_from_unpacked(final_release_tarball_path)
57
59
 
58
- upload_package_and_job_blobs(manifest, tarball)
59
-
60
60
  nl
61
61
  say("Creating final release #{final_release_name}/#{final_release_ver} from dev release #{dev_release_name}/#{dev_release_ver}")
62
62
 
@@ -77,19 +77,25 @@ module Bosh::Cli::Command
77
77
  private
78
78
 
79
79
  def upload_package_and_job_blobs(manifest, tarball)
80
- manifest['packages'].each do |package|
81
- upload_to_blobstore(package, 'packages', tarball.package_tarball_path(package['name']))
80
+ manifest['packages'].map! do |package|
81
+ upload_to_blobstore(package.dup, 'packages', tarball.package_tarball_path(package['name']))
82
82
  end
83
83
 
84
- manifest['jobs'].each do |job|
85
- upload_to_blobstore(job, 'jobs', tarball.job_tarball_path(job['name']))
84
+ manifest['jobs'].map! do |job|
85
+ upload_to_blobstore(job.dup, 'jobs', tarball.job_tarball_path(job['name']))
86
86
  end
87
87
 
88
88
  if manifest['license']
89
89
  # the licence is different from packages and jobs: it has to be rebuilt from the
90
90
  # raw LICENSE and/or NOTICE files in the dev release tarball
91
- archive_builder.build(tarball.license_resource)
91
+ updated_artifact = archive_builder.build(tarball.license_resource)
92
+ manifest['license'] = {
93
+ 'version' => updated_artifact.version,
94
+ 'fingerprint' => updated_artifact.fingerprint,
95
+ 'sha1' => updated_artifact.sha1,
96
+ }
92
97
  end
98
+ manifest
93
99
  end
94
100
 
95
101
  def extract_and_validate_tarball(tarball_path)
@@ -108,11 +114,12 @@ module Bosh::Cli::Command
108
114
  def upload_to_blobstore(artifact, plural_type, artifact_path)
109
115
  err("Cannot find artifact complete information, please upgrade tarball to newer version") if !artifact['fingerprint']
110
116
 
111
- final_builds_dir = File.join('.final_builds', plural_type, artifact['name']).to_s
112
- FileUtils.mkdir_p(final_builds_dir)
113
- final_builds_index = Bosh::Cli::Versions::VersionsIndex.new(final_builds_dir)
117
+ final_builds_index = final_builds_for_artifact(plural_type, artifact)
114
118
 
115
- return artifact if final_builds_index[artifact['fingerprint']]
119
+ if final_builds_index[artifact['fingerprint']]
120
+ artifact['sha1'] = final_builds_index[artifact['fingerprint']]['sha1']
121
+ return artifact
122
+ end
116
123
 
117
124
  @progress_renderer.start(artifact['name'], "uploading...")
118
125
  blobstore_id = nil
@@ -126,6 +133,7 @@ module Bosh::Cli::Command
126
133
  'blobstore_id' => blobstore_id
127
134
  })
128
135
  @progress_renderer.finish(artifact['name'], "uploaded")
136
+ artifact
129
137
  end
130
138
 
131
139
  def archive_builder
@@ -136,6 +144,12 @@ module Bosh::Cli::Command
136
144
  def archive_repository_provider
137
145
  @archive_repository_provider ||= Bosh::Cli::ArchiveRepositoryProvider.new(work_dir, cache_dir, release.blobstore)
138
146
  end
147
+
148
+ def final_builds_for_artifact(plural_type, artifact)
149
+ final_builds_dir = File.join('.final_builds', plural_type, artifact['name']).to_s
150
+ FileUtils.mkdir_p(final_builds_dir)
151
+ Bosh::Cli::Versions::VersionsIndex.new(final_builds_dir)
152
+ end
139
153
  end
140
154
  end
141
155
  end
@@ -170,10 +170,10 @@ If --name & --version are provided, they will be used for checking if release ex
170
170
 
171
171
  def upload_remote_release(release_location, upload_options = {})
172
172
  if upload_options[:rebase]
173
- say("Using remote release `#{release_location}' (#{'will be rebased'.make_yellow})")
173
+ say("Using remote release '#{release_location}' (#{'will be rebased'.make_yellow})")
174
174
  report = 'Release rebased'
175
175
  else
176
- say("Using remote release `#{release_location}'")
176
+ say("Using remote release '#{release_location}'")
177
177
  report = 'Release uploaded'
178
178
  end
179
179
 
@@ -14,13 +14,13 @@ module Bosh::Cli::Command
14
14
  nl
15
15
 
16
16
  if tarball.valid?
17
- say("`#{tarball_path}' is a valid release".make_green)
17
+ say("'#{tarball_path}' is a valid release".make_green)
18
18
  else
19
19
  say('Validation errors:'.make_red)
20
20
  tarball.errors.each do |error|
21
21
  say("- #{error}")
22
22
  end
23
- err("`#{tarball_path}' is not a valid release".make_red)
23
+ err("'#{tarball_path}' is not a valid release".make_red)
24
24
  end
25
25
  end
26
26
  end
@@ -19,12 +19,12 @@ class Restore < Base
19
19
  return
20
20
  end
21
21
 
22
- err("The file `#{path}' does not exist.".make_red) unless File.exists?(path)
23
- err("The file `#{path}' is not readable.".make_red) unless File.readable?(path)
22
+ err("The file '#{path}' does not exist.".make_red) unless File.exists?(path)
23
+ err("The file '#{path}' is not readable.".make_red) unless File.readable?(path)
24
24
 
25
25
  nl
26
26
  status = director.restore_db(path)
27
- err("Failed to restore the database, the status is `#{status}'") unless status == 202
27
+ err("Failed to restore the database, the status is '#{status}'") unless status == 202
28
28
  nl
29
29
  say('Starting restore of BOSH director.')
30
30
 
@@ -50,7 +50,7 @@ module Bosh::Cli::Command
50
50
  deployment_name = prepare_deployment_manifest(show_state: true).name
51
51
 
52
52
  unless job && index
53
- unless confirmed?("Are you sure you want to take a snapshot of all deployment `#{deployment_name}'?")
53
+ unless confirmed?("Are you sure you want to take a snapshot of all deployment '#{deployment_name}'?")
54
54
  say('Canceled taking snapshot'.make_green)
55
55
  return
56
56
  end
@@ -68,14 +68,14 @@ module Bosh::Cli::Command
68
68
 
69
69
  deployment_name = prepare_deployment_manifest(show_state: true).name
70
70
 
71
- unless confirmed?("Are you sure you want to delete snapshot `#{snapshot_cid}'?")
71
+ unless confirmed?("Are you sure you want to delete snapshot '#{snapshot_cid}'?")
72
72
  say('Canceled deleting snapshot'.make_green)
73
73
  return
74
74
  end
75
75
 
76
76
  status, task_id = director.delete_snapshot(deployment_name, snapshot_cid)
77
77
 
78
- task_report(status, task_id, "Deleted Snapshot `#{snapshot_cid}'")
78
+ task_report(status, task_id, "Deleted Snapshot '#{snapshot_cid}'")
79
79
  end
80
80
 
81
81
  usage 'delete snapshots'
@@ -85,14 +85,14 @@ module Bosh::Cli::Command
85
85
 
86
86
  deployment_name = prepare_deployment_manifest(show_state: true).name
87
87
 
88
- unless confirmed?("Are you sure you want to delete all snapshots of deployment `#{deployment_name}'?")
88
+ unless confirmed?("Are you sure you want to delete all snapshots of deployment '#{deployment_name}'?")
89
89
  say('Canceled deleting snapshots'.make_green)
90
90
  return
91
91
  end
92
92
 
93
93
  status, task_id = director.delete_all_snapshots(deployment_name)
94
94
 
95
- task_report(status, task_id, "Deleted all snapshots of deployment `#{deployment_name}'")
95
+ task_report(status, task_id, "Deleted all snapshots of deployment '#{deployment_name}'")
96
96
  end
97
97
  end
98
98
  end