bosh_cli 1.0.3 → 1.5.0.pre.1113
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.
- data/bin/bosh +0 -9
- data/lib/cli.rb +69 -64
- data/lib/cli/backup_destination_path.rb +33 -0
- data/lib/cli/base_command.rb +57 -56
- data/lib/cli/blob_manager.rb +12 -12
- data/lib/cli/changeset_helper.rb +6 -7
- data/lib/cli/client/director.rb +724 -0
- data/lib/cli/command_handler.rb +6 -7
- data/lib/cli/commands/backup.rb +39 -0
- data/lib/cli/commands/biff.rb +42 -21
- data/lib/cli/commands/blob_management.rb +1 -1
- data/lib/cli/commands/cloudcheck.rb +11 -13
- data/lib/cli/commands/deployment.rb +53 -37
- data/lib/cli/commands/help.rb +3 -2
- data/lib/cli/commands/job_management.rb +67 -103
- data/lib/cli/commands/job_rename.rb +6 -8
- data/lib/cli/commands/log_management.rb +78 -55
- data/lib/cli/commands/maintenance.rb +36 -30
- data/lib/cli/commands/misc.rb +72 -51
- data/lib/cli/commands/package.rb +2 -2
- data/lib/cli/commands/property_management.rb +10 -12
- data/lib/cli/commands/release.rb +236 -133
- data/lib/cli/commands/snapshot.rb +93 -0
- data/lib/cli/commands/ssh.rb +216 -213
- data/lib/cli/commands/stemcell.rb +46 -34
- data/lib/cli/commands/task.rb +2 -2
- data/lib/cli/commands/user.rb +27 -3
- data/lib/cli/commands/vm.rb +28 -0
- data/lib/cli/commands/vms.rb +81 -23
- data/lib/cli/config.rb +6 -2
- data/lib/cli/core_ext.rb +31 -30
- data/lib/cli/deployment_helper.rb +134 -159
- data/lib/cli/deployment_manifest.rb +66 -0
- data/lib/cli/deployment_manifest_compiler.rb +0 -3
- data/lib/cli/event_log_renderer.rb +10 -10
- data/lib/cli/file_with_progress_bar.rb +52 -0
- data/lib/cli/job_builder.rb +1 -1
- data/lib/cli/job_command_args.rb +23 -0
- data/lib/cli/job_property_collection.rb +4 -7
- data/lib/cli/job_property_validator.rb +22 -12
- data/lib/cli/job_state.rb +54 -0
- data/lib/cli/line_wrap.rb +54 -0
- data/lib/cli/packaging_helper.rb +10 -10
- data/lib/cli/release.rb +18 -15
- data/lib/cli/release_builder.rb +9 -4
- data/lib/cli/release_compiler.rb +9 -9
- data/lib/cli/release_tarball.rb +3 -6
- data/lib/cli/resurrection.rb +31 -0
- data/lib/cli/runner.rb +56 -30
- data/lib/cli/stemcell.rb +25 -10
- data/lib/cli/task_log_renderer.rb +1 -1
- data/lib/cli/task_tracker.rb +10 -9
- data/lib/cli/validation.rb +3 -1
- data/lib/cli/version.rb +1 -1
- data/lib/cli/version_calc.rb +5 -18
- data/lib/cli/versions_index.rb +1 -1
- data/lib/cli/vm_state.rb +43 -0
- data/lib/cli/yaml_helper.rb +26 -35
- metadata +75 -208
- data/Rakefile +0 -56
- data/lib/cli/director.rb +0 -628
- data/spec/assets/biff/bad_gateway_config.yml +0 -28
- data/spec/assets/biff/good_simple_config.yml +0 -63
- data/spec/assets/biff/good_simple_golden_config.yml +0 -63
- data/spec/assets/biff/good_simple_template.erb +0 -69
- data/spec/assets/biff/ip_out_of_range.yml +0 -63
- data/spec/assets/biff/multiple_subnets_config.yml +0 -40
- data/spec/assets/biff/network_only_template.erb +0 -34
- data/spec/assets/biff/no_cc_config.yml +0 -27
- data/spec/assets/biff/no_range_config.yml +0 -27
- data/spec/assets/biff/no_subnet_config.yml +0 -16
- data/spec/assets/biff/ok_network_config.yml +0 -30
- data/spec/assets/biff/properties_template.erb +0 -6
- data/spec/assets/config/atmos/config/final.yml +0 -6
- data/spec/assets/config/atmos/config/private.yml +0 -4
- data/spec/assets/config/bad-providers/config/final.yml +0 -5
- data/spec/assets/config/bad-providers/config/private.yml +0 -4
- data/spec/assets/config/deprecation/config/final.yml +0 -5
- data/spec/assets/config/deprecation/config/private.yml +0 -2
- data/spec/assets/config/local/config/final.yml +0 -5
- data/spec/assets/config/local/config/private.yml +0 -1
- data/spec/assets/config/s3/config/final.yml +0 -5
- data/spec/assets/config/s3/config/private.yml +0 -5
- data/spec/assets/config/swift-hp/config/final.yml +0 -6
- data/spec/assets/config/swift-hp/config/private.yml +0 -7
- data/spec/assets/config/swift-rackspace/config/final.yml +0 -6
- data/spec/assets/config/swift-rackspace/config/private.yml +0 -6
- data/spec/assets/deployment.MF +0 -0
- data/spec/assets/plugins/bosh/cli/commands/echo.rb +0 -43
- data/spec/assets/plugins/bosh/cli/commands/ruby.rb +0 -24
- data/spec/assets/release/jobs/cacher.tgz +0 -0
- data/spec/assets/release/jobs/cacher/config/file1.conf +0 -0
- data/spec/assets/release/jobs/cacher/config/file2.conf +0 -0
- data/spec/assets/release/jobs/cacher/job.MF +0 -6
- data/spec/assets/release/jobs/cacher/monit +0 -1
- data/spec/assets/release/jobs/cleaner.tgz +0 -0
- data/spec/assets/release/jobs/cleaner/job.MF +0 -4
- data/spec/assets/release/jobs/cleaner/monit +0 -1
- data/spec/assets/release/jobs/sweeper.tgz +0 -0
- data/spec/assets/release/jobs/sweeper/config/test.conf +0 -1
- data/spec/assets/release/jobs/sweeper/job.MF +0 -5
- data/spec/assets/release/jobs/sweeper/monit +0 -1
- data/spec/assets/release/packages/mutator.tar.gz +0 -0
- data/spec/assets/release/packages/stuff.tgz +0 -0
- data/spec/assets/release/release.MF +0 -17
- data/spec/assets/release_invalid_checksum.tgz +0 -0
- data/spec/assets/release_invalid_jobs.tgz +0 -0
- data/spec/assets/release_no_name.tgz +0 -0
- data/spec/assets/release_no_version.tgz +0 -0
- data/spec/assets/stemcell/image +0 -1
- data/spec/assets/stemcell/stemcell.MF +0 -6
- data/spec/assets/stemcell_invalid_mf.tgz +0 -0
- data/spec/assets/stemcell_no_image.tgz +0 -0
- data/spec/assets/valid_release.tgz +0 -0
- data/spec/assets/valid_stemcell.tgz +0 -0
- data/spec/spec_helper.rb +0 -28
- data/spec/unit/base_command_spec.rb +0 -87
- data/spec/unit/biff_spec.rb +0 -172
- data/spec/unit/blob_manager_spec.rb +0 -288
- data/spec/unit/cache_spec.rb +0 -36
- data/spec/unit/cli_commands_spec.rb +0 -356
- data/spec/unit/config_spec.rb +0 -125
- data/spec/unit/core_ext_spec.rb +0 -81
- data/spec/unit/dependency_helper_spec.rb +0 -52
- data/spec/unit/deployment_manifest_compiler_spec.rb +0 -63
- data/spec/unit/deployment_manifest_spec.rb +0 -153
- data/spec/unit/director_spec.rb +0 -471
- data/spec/unit/director_task_spec.rb +0 -48
- data/spec/unit/event_log_renderer_spec.rb +0 -171
- data/spec/unit/hash_changeset_spec.rb +0 -73
- data/spec/unit/job_builder_spec.rb +0 -455
- data/spec/unit/job_property_collection_spec.rb +0 -111
- data/spec/unit/job_property_validator_spec.rb +0 -7
- data/spec/unit/job_rename_spec.rb +0 -200
- data/spec/unit/package_builder_spec.rb +0 -593
- data/spec/unit/release_builder_spec.rb +0 -120
- data/spec/unit/release_spec.rb +0 -173
- data/spec/unit/release_tarball_spec.rb +0 -29
- data/spec/unit/runner_spec.rb +0 -7
- data/spec/unit/ssh_spec.rb +0 -84
- data/spec/unit/stemcell_spec.rb +0 -17
- data/spec/unit/task_tracker_spec.rb +0 -131
- data/spec/unit/version_calc_spec.rb +0 -27
- data/spec/unit/versions_index_spec.rb +0 -144
data/bin/bosh
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
gemfile = File.expand_path("../../Gemfile", __FILE__)
|
|
4
|
-
|
|
5
|
-
if File.exists?(gemfile)
|
|
6
|
-
ENV["BUNDLE_GEMFILE"] = gemfile
|
|
7
|
-
require "rubygems"
|
|
8
|
-
require "bundler/setup"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
$:.unshift(File.expand_path("../../lib", __FILE__))
|
|
12
3
|
require "cli"
|
|
13
4
|
|
|
14
5
|
begin
|
data/lib/cli.rb
CHANGED
|
@@ -2,88 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
module Bosh
|
|
4
4
|
module Cli
|
|
5
|
-
DEFAULT_CONFIG_PATH = File.expand_path(
|
|
6
|
-
DEFAULT_CACHE_DIR = File.expand_path(
|
|
5
|
+
DEFAULT_CONFIG_PATH = File.expand_path('~/.bosh_config')
|
|
6
|
+
DEFAULT_CACHE_DIR = File.expand_path('~/.bosh_cache')
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
autoload :HTTPClient,
|
|
11
|
-
Bosh.autoload :Blobstore, "blobstore_client"
|
|
10
|
+
autoload :HTTPClient, 'httpclient'
|
|
12
11
|
|
|
13
|
-
require
|
|
14
|
-
require
|
|
15
|
-
require
|
|
16
|
-
require
|
|
17
|
-
require
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
21
|
-
require
|
|
22
|
-
require
|
|
23
|
-
require
|
|
24
|
-
require
|
|
25
|
-
require
|
|
26
|
-
require
|
|
27
|
-
require
|
|
28
|
-
require
|
|
29
|
-
require
|
|
30
|
-
require
|
|
31
|
-
require
|
|
12
|
+
require 'blobstore_client'
|
|
13
|
+
require 'base64'
|
|
14
|
+
require 'digest/sha1'
|
|
15
|
+
require 'fileutils'
|
|
16
|
+
require 'highline/import'
|
|
17
|
+
require 'json'
|
|
18
|
+
require 'monitor'
|
|
19
|
+
require 'optparse'
|
|
20
|
+
require 'ostruct'
|
|
21
|
+
require 'pathname'
|
|
22
|
+
require 'progressbar'
|
|
23
|
+
require 'resolv'
|
|
24
|
+
require 'set'
|
|
25
|
+
require 'tempfile'
|
|
26
|
+
require 'terminal-table/import'
|
|
27
|
+
require 'time'
|
|
28
|
+
require 'timeout'
|
|
29
|
+
require 'tmpdir'
|
|
30
|
+
require 'uri'
|
|
31
|
+
require 'yaml'
|
|
32
|
+
require 'netaddr'
|
|
33
|
+
require 'zlib'
|
|
34
|
+
require 'archive/tar/minitar'
|
|
35
|
+
include Archive::Tar
|
|
32
36
|
|
|
33
37
|
unless defined?(Bosh::Cli::VERSION)
|
|
34
|
-
require
|
|
38
|
+
require 'cli/version'
|
|
35
39
|
end
|
|
36
40
|
|
|
37
|
-
require
|
|
41
|
+
require 'common/common'
|
|
42
|
+
require 'common/exec'
|
|
38
43
|
|
|
39
|
-
require
|
|
40
|
-
require
|
|
41
|
-
require
|
|
42
|
-
require
|
|
43
|
-
require
|
|
44
|
-
require
|
|
45
|
-
require
|
|
46
|
-
require
|
|
47
|
-
require
|
|
48
|
-
require
|
|
49
|
-
require
|
|
50
|
-
require
|
|
44
|
+
require 'cli/config'
|
|
45
|
+
require 'cli/core_ext'
|
|
46
|
+
require 'cli/errors'
|
|
47
|
+
require 'cli/yaml_helper'
|
|
48
|
+
require 'cli/version_calc'
|
|
49
|
+
require 'cli/dependency_helper'
|
|
50
|
+
require 'cli/deployment_manifest'
|
|
51
|
+
require 'cli/deployment_helper'
|
|
52
|
+
require 'cli/validation'
|
|
53
|
+
require 'cli/cache'
|
|
54
|
+
require 'cli/stemcell'
|
|
55
|
+
require 'cli/client/director'
|
|
56
|
+
require 'cli/director_task'
|
|
51
57
|
|
|
52
|
-
require
|
|
53
|
-
require
|
|
54
|
-
require "cli/package_builder"
|
|
55
|
-
require "cli/job_builder"
|
|
56
|
-
require "cli/changeset_helper"
|
|
57
|
-
require "cli/task_tracker"
|
|
58
|
-
require "cli/task_log_renderer"
|
|
59
|
-
require "cli/event_log_renderer"
|
|
60
|
-
require "cli/null_renderer"
|
|
61
|
-
require "cli/deployment_manifest_compiler"
|
|
58
|
+
require 'cli/line_wrap'
|
|
59
|
+
require 'cli/backup_destination_path'
|
|
62
60
|
|
|
63
|
-
require
|
|
64
|
-
require
|
|
65
|
-
require
|
|
66
|
-
require
|
|
61
|
+
require 'cli/versions_index'
|
|
62
|
+
require 'cli/packaging_helper'
|
|
63
|
+
require 'cli/package_builder'
|
|
64
|
+
require 'cli/job_builder'
|
|
65
|
+
require 'cli/changeset_helper'
|
|
66
|
+
require 'cli/task_tracker'
|
|
67
|
+
require 'cli/task_log_renderer'
|
|
68
|
+
require 'cli/event_log_renderer'
|
|
69
|
+
require 'cli/null_renderer'
|
|
70
|
+
require 'cli/deployment_manifest_compiler'
|
|
67
71
|
|
|
68
|
-
require
|
|
72
|
+
require 'cli/release'
|
|
73
|
+
require 'cli/release_builder'
|
|
74
|
+
require 'cli/release_compiler'
|
|
75
|
+
require 'cli/release_tarball'
|
|
69
76
|
|
|
70
|
-
require
|
|
71
|
-
require "cli/job_property_collection"
|
|
72
|
-
require "cli/job_property_validator"
|
|
77
|
+
require 'cli/blob_manager'
|
|
73
78
|
|
|
74
|
-
require
|
|
75
|
-
require
|
|
76
|
-
require
|
|
77
|
-
require "cli/base_command"
|
|
79
|
+
require 'common/properties'
|
|
80
|
+
require 'cli/job_property_collection'
|
|
81
|
+
require 'cli/job_property_validator'
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
require 'cli/command_discovery'
|
|
84
|
+
require 'cli/command_handler'
|
|
85
|
+
require 'cli/runner'
|
|
86
|
+
require 'cli/base_command'
|
|
82
87
|
|
|
83
88
|
tmpdir = Dir.mktmpdir
|
|
84
89
|
at_exit { FileUtils.rm_rf(tmpdir) }
|
|
85
|
-
ENV[
|
|
90
|
+
ENV['TMPDIR'] = tmpdir
|
|
86
91
|
|
|
87
|
-
Dir[File.dirname(__FILE__) +
|
|
92
|
+
Dir[File.dirname(__FILE__) + '/cli/commands/*.rb'].each do |file|
|
|
88
93
|
require file
|
|
89
94
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Bosh::Cli
|
|
4
|
+
class BackupDestinationPath
|
|
5
|
+
def initialize(director)
|
|
6
|
+
@director = director
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create_from_path(dest_path = nil)
|
|
10
|
+
dest_path ||= Dir.pwd
|
|
11
|
+
|
|
12
|
+
if File.directory?(dest_path)
|
|
13
|
+
File.join(dest_path, default_backup_name)
|
|
14
|
+
else
|
|
15
|
+
is_tar_path?(dest_path) ? dest_path : "#{dest_path}.tgz"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def default_backup_name
|
|
22
|
+
"bosh_backup_#{bosh_director_name}_#{Time.now.to_i}.tgz"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def bosh_director_name
|
|
26
|
+
@director.get_status['name']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def is_tar_path?(path)
|
|
30
|
+
path.end_with?('.tar.gz') || path.end_with?('.tgz')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/cli/base_command.rb
CHANGED
|
@@ -4,21 +4,17 @@ module Bosh::Cli
|
|
|
4
4
|
module Command
|
|
5
5
|
class Base
|
|
6
6
|
extend Bosh::Cli::CommandDiscovery
|
|
7
|
+
include Bosh::Cli::DeploymentHelper
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
attr_reader :work_dir
|
|
10
|
-
attr_reader :runner
|
|
11
|
-
|
|
12
|
-
attr_accessor :out
|
|
13
|
-
|
|
14
|
-
# @return [Array] Arguments passed to command handler
|
|
15
|
-
attr_accessor :args
|
|
9
|
+
attr_accessor :options, :out, :args
|
|
10
|
+
attr_reader :work_dir, :exit_code, :runner
|
|
16
11
|
|
|
17
12
|
DEFAULT_DIRECTOR_PORT = 25555
|
|
18
13
|
|
|
19
14
|
# @param [Bosh::Cli::Runner] runner
|
|
20
|
-
def initialize(runner = nil)
|
|
15
|
+
def initialize(runner = nil, director = nil)
|
|
21
16
|
@runner = runner
|
|
17
|
+
@director = director
|
|
22
18
|
@options = {}
|
|
23
19
|
@work_dir = Dir.pwd
|
|
24
20
|
@exit_code = 0
|
|
@@ -34,7 +30,9 @@ module Bosh::Cli
|
|
|
34
30
|
# @return [Bosh::Cli::Config] Current configuration
|
|
35
31
|
def config
|
|
36
32
|
@config ||= begin
|
|
37
|
-
|
|
33
|
+
# Handle the environment variable being set to the empty string.
|
|
34
|
+
env_bosh_config = ENV['BOSH_CONFIG'].to_s.empty? ? nil : ENV['BOSH_CONFIG']
|
|
35
|
+
config_file = options[:config] || env_bosh_config || Bosh::Cli::DEFAULT_CONFIG_PATH
|
|
38
36
|
Bosh::Cli::Config.new(config_file)
|
|
39
37
|
end
|
|
40
38
|
end
|
|
@@ -48,8 +46,8 @@ module Bosh::Cli
|
|
|
48
46
|
end
|
|
49
47
|
|
|
50
48
|
def director
|
|
51
|
-
@director ||= Bosh::Cli::Director.new(
|
|
52
|
-
|
|
49
|
+
@director ||= Bosh::Cli::Client::Director.new(
|
|
50
|
+
target, username, password, @options.select { |k, _| k == :no_track })
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
def release
|
|
@@ -86,9 +84,9 @@ module Bosh::Cli
|
|
|
86
84
|
Bosh::Cli::Runner.new(args, @options).run
|
|
87
85
|
end
|
|
88
86
|
|
|
89
|
-
def confirmed?(question =
|
|
87
|
+
def confirmed?(question = 'Are you sure?')
|
|
90
88
|
return true if non_interactive?
|
|
91
|
-
ask("#{question} (type 'yes' to continue): ") ==
|
|
89
|
+
ask("#{question} (type 'yes' to continue): ") == 'yes'
|
|
92
90
|
end
|
|
93
91
|
|
|
94
92
|
# @return [String] Target director URL
|
|
@@ -106,28 +104,19 @@ module Bosh::Cli
|
|
|
106
104
|
|
|
107
105
|
# @return [String] Director username
|
|
108
106
|
def username
|
|
109
|
-
options[:username] || ENV[
|
|
107
|
+
options[:username] || ENV['BOSH_USER'] || config.username(target)
|
|
110
108
|
end
|
|
111
109
|
|
|
112
110
|
# @return [String] Director password
|
|
113
111
|
def password
|
|
114
|
-
options[:password] || ENV[
|
|
112
|
+
options[:password] || ENV['BOSH_PASSWORD'] || config.password(target)
|
|
115
113
|
end
|
|
116
114
|
|
|
117
115
|
def target_name
|
|
118
|
-
config.target_name || target_url
|
|
116
|
+
options[:target] || config.target_name || target_url
|
|
119
117
|
end
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
# @param [optional,Integer] code If param is given, sets exit code. If
|
|
123
|
-
# it's nil, returns previously set exit_code
|
|
124
|
-
def exit_code(code = nil)
|
|
125
|
-
if code
|
|
126
|
-
@exit_code = code
|
|
127
|
-
else
|
|
128
|
-
@exit_code
|
|
129
|
-
end
|
|
130
|
-
end
|
|
119
|
+
protected
|
|
131
120
|
|
|
132
121
|
# Prints director task completion report. Note that event log usually
|
|
133
122
|
# contains pretty detailed error report and other UI niceties, so most
|
|
@@ -137,11 +126,11 @@ module Bosh::Cli
|
|
|
137
126
|
def task_report(status, task_id, success_msg = nil, error_msg = nil)
|
|
138
127
|
case status
|
|
139
128
|
when :non_trackable
|
|
140
|
-
report = "Can't track director task".
|
|
129
|
+
report = "Can't track director task".make_red
|
|
141
130
|
when :track_timeout
|
|
142
|
-
report =
|
|
131
|
+
report = 'Task tracking timeout'.make_red
|
|
143
132
|
when :running
|
|
144
|
-
report = "
|
|
133
|
+
report = "Task #{task_id.make_yellow} running"
|
|
145
134
|
when :error
|
|
146
135
|
report = error_msg
|
|
147
136
|
when :done
|
|
@@ -150,70 +139,82 @@ module Bosh::Cli
|
|
|
150
139
|
report = nil
|
|
151
140
|
end
|
|
152
141
|
|
|
153
|
-
|
|
154
|
-
exit_code
|
|
142
|
+
unless [:running, :done].include?(status)
|
|
143
|
+
@exit_code = 1
|
|
155
144
|
end
|
|
156
145
|
|
|
157
146
|
say("\n#{report}") if report
|
|
147
|
+
say("\nFor a more detailed error report, run: bosh task #{task_id} --debug") if status == :error
|
|
158
148
|
end
|
|
159
149
|
|
|
160
|
-
protected
|
|
161
|
-
|
|
162
150
|
def auth_required
|
|
163
151
|
target_required
|
|
164
|
-
err(
|
|
152
|
+
err('Please log in first') unless logged_in?
|
|
165
153
|
end
|
|
166
154
|
|
|
167
155
|
def target_required
|
|
168
|
-
err(
|
|
156
|
+
err('Please choose target first') if target.nil?
|
|
169
157
|
end
|
|
170
158
|
|
|
171
159
|
def deployment_required
|
|
172
|
-
err(
|
|
160
|
+
err('Please choose deployment first') if deployment.nil?
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def show_deployment
|
|
164
|
+
say("Current deployment is #{deployment.make_green}")
|
|
173
165
|
end
|
|
174
166
|
|
|
175
167
|
def no_track_unsupported
|
|
176
168
|
if @options.delete(:no_track)
|
|
177
|
-
say(
|
|
169
|
+
say('Ignoring `' + '--no-track'.make_yellow + "' option")
|
|
178
170
|
end
|
|
179
171
|
end
|
|
180
172
|
|
|
181
173
|
def check_if_release_dir
|
|
182
174
|
unless in_release_dir?
|
|
183
|
-
err("Sorry, your current directory doesn't look "
|
|
184
|
-
"like release directory")
|
|
175
|
+
err("Sorry, your current directory doesn't look like release directory")
|
|
185
176
|
end
|
|
186
177
|
end
|
|
187
178
|
|
|
188
|
-
def
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
"Use the --force option to skip this check.")
|
|
194
|
-
end
|
|
179
|
+
def raise_dirty_state_error
|
|
180
|
+
say("\n%s\n" % [`git status`])
|
|
181
|
+
err('Your current directory has some local modifications, ' +
|
|
182
|
+
"please discard or commit them first.\n\n" +
|
|
183
|
+
'Use the --force option to skip this check.')
|
|
195
184
|
end
|
|
196
185
|
|
|
197
186
|
def in_release_dir?
|
|
198
|
-
File.directory?(
|
|
199
|
-
|
|
200
|
-
|
|
187
|
+
File.directory?('packages') &&
|
|
188
|
+
File.directory?('jobs') &&
|
|
189
|
+
File.directory?('src')
|
|
201
190
|
end
|
|
202
191
|
|
|
203
192
|
def dirty_state?
|
|
204
|
-
`
|
|
205
|
-
|
|
206
|
-
|
|
193
|
+
git_status = `git status 2>&1`
|
|
194
|
+
case $?.exitstatus
|
|
195
|
+
when 128 # Not in a git repo
|
|
196
|
+
false
|
|
197
|
+
when 127 # git command not found
|
|
198
|
+
false
|
|
199
|
+
else
|
|
200
|
+
!git_status.lines.to_a.last.include?('nothing to commit')
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def valid_index_for(job, index, options = {})
|
|
205
|
+
index = '0' if job_unique_in_deployment?(job)
|
|
206
|
+
err('You should specify the job index. There is more than one instance of this job type.') if index.nil?
|
|
207
|
+
index = index.to_i if options[:integer_index]
|
|
208
|
+
index
|
|
207
209
|
end
|
|
208
210
|
|
|
209
211
|
def normalize_url(url)
|
|
210
212
|
had_port = url.to_s =~ /:\d+$/
|
|
211
|
-
url = "
|
|
213
|
+
url = "https://#{url}" unless url.match(/^http:?/)
|
|
212
214
|
uri = URI.parse(url)
|
|
213
215
|
uri.port = DEFAULT_DIRECTOR_PORT unless had_port
|
|
214
|
-
uri.to_s.strip.gsub(/\/$/,
|
|
216
|
+
uri.to_s.strip.gsub(/\/$/, '')
|
|
215
217
|
end
|
|
216
|
-
|
|
217
218
|
end
|
|
218
219
|
end
|
|
219
220
|
end
|
data/lib/cli/blob_manager.rb
CHANGED
|
@@ -77,7 +77,7 @@ module Bosh::Cli
|
|
|
77
77
|
process_blobs_directory
|
|
78
78
|
|
|
79
79
|
unless dirty?
|
|
80
|
-
say("No blobs to upload".
|
|
80
|
+
say("No blobs to upload".make_green)
|
|
81
81
|
return
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -85,16 +85,16 @@ module Bosh::Cli
|
|
|
85
85
|
say("You have some blobs that need to be uploaded:")
|
|
86
86
|
@new_blobs.each do |blob|
|
|
87
87
|
size = File.size(File.join(@blobs_dir, blob))
|
|
88
|
-
say("%s\t%s\t%s" % ["new".
|
|
88
|
+
say("%s\t%s\t%s" % ["new".make_green, blob, pretty_size(size)])
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
@updated_blobs.each do |blob|
|
|
92
92
|
size = File.size(File.join(@blobs_dir, blob))
|
|
93
|
-
say("%s\t%s\t%s" % ["new version".
|
|
93
|
+
say("%s\t%s\t%s" % ["new version".make_yellow, blob, pretty_size(size)])
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
nl
|
|
97
|
-
say("When ready please run `#{"bosh upload blobs".
|
|
97
|
+
say("When ready please run `#{"bosh upload blobs".make_green}'")
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
# Registers a file as BOSH blob
|
|
@@ -137,13 +137,13 @@ module Bosh::Cli
|
|
|
137
137
|
FileUtils.cp(local_path, blob_dst, :preserve => true)
|
|
138
138
|
FileUtils.chmod(0644, blob_dst)
|
|
139
139
|
if update
|
|
140
|
-
say("Updated #{blob_path.
|
|
140
|
+
say("Updated #{blob_path.make_yellow}")
|
|
141
141
|
else
|
|
142
|
-
say("Added #{blob_path.
|
|
142
|
+
say("Added #{blob_path.make_yellow}")
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
say("When you are done testing the new blob, please run\n" +
|
|
146
|
-
"`#{"bosh upload blobs".
|
|
146
|
+
"`#{"bosh upload blobs".make_green}' and commit changes.")
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
# Synchronizes the contents of blobs directory with blobs index.
|
|
@@ -222,7 +222,7 @@ module Bosh::Cli
|
|
|
222
222
|
if checksum == entry["sha"]
|
|
223
223
|
need_download = false
|
|
224
224
|
else
|
|
225
|
-
progress(path, "checksum mismatch, re-downloading...\n".
|
|
225
|
+
progress(path, "checksum mismatch, re-downloading...\n".make_red)
|
|
226
226
|
end
|
|
227
227
|
end
|
|
228
228
|
|
|
@@ -251,7 +251,7 @@ module Bosh::Cli
|
|
|
251
251
|
|
|
252
252
|
progress(path, "uploading...")
|
|
253
253
|
object_id = @blobstore.create(File.open(blob_path, "r"))
|
|
254
|
-
progress(path, "uploaded\n".
|
|
254
|
+
progress(path, "uploaded\n".make_green)
|
|
255
255
|
|
|
256
256
|
@index[path] = {
|
|
257
257
|
"object_id" => object_id,
|
|
@@ -295,7 +295,7 @@ module Bosh::Cli
|
|
|
295
295
|
@blobstore.get(blob["object_id"], tmp_file)
|
|
296
296
|
tmp_file.close
|
|
297
297
|
progress_bar.kill
|
|
298
|
-
progress(path, "downloaded\n".
|
|
298
|
+
progress(path, "downloaded\n".make_green)
|
|
299
299
|
|
|
300
300
|
if file_checksum(tmp_file.path) != blob["sha"]
|
|
301
301
|
err("Checksum mismatch for downloaded blob `#{path}'")
|
|
@@ -311,7 +311,7 @@ module Bosh::Cli
|
|
|
311
311
|
# @param [String] label Operation happening to a blob
|
|
312
312
|
def progress(path, label)
|
|
313
313
|
say("\r", " " * 80)
|
|
314
|
-
say("\r#{path.truncate(40).
|
|
314
|
+
say("\r#{path.truncate(40).make_yellow} #{label}", "")
|
|
315
315
|
Bosh::Cli::Config.output.flush # Ruby 1.8 compatibility
|
|
316
316
|
end
|
|
317
317
|
|
|
@@ -352,7 +352,7 @@ module Bosh::Cli
|
|
|
352
352
|
|
|
353
353
|
# Updates blobs index
|
|
354
354
|
def update_index
|
|
355
|
-
yaml =
|
|
355
|
+
yaml = Psych.dump(@index).gsub(/\s*$/, "")
|
|
356
356
|
|
|
357
357
|
index_file = Tempfile.new("blob_index")
|
|
358
358
|
index_file.puts(yaml)
|