bosh_cli 1.5.0.pre.1323 → 1.5.0.pre.1324
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/lib/cli.rb +0 -4
- data/lib/cli/base_command.rb +0 -5
- data/lib/cli/commands/misc.rb +0 -12
- data/lib/cli/commands/stemcell.rb +7 -7
- data/lib/cli/commands/task.rb +0 -5
- data/lib/cli/config.rb +0 -4
- data/lib/cli/errors.rb +0 -4
- data/lib/cli/runner.rb +1 -6
- data/lib/cli/stemcell.rb +28 -39
- data/lib/cli/task_tracker.rb +1 -27
- data/lib/cli/version.rb +1 -1
- metadata +6 -7
- data/lib/cli/cache.rb +0 -44
data/lib/cli.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh
|
4
2
|
module Cli
|
5
3
|
DEFAULT_CONFIG_PATH = File.expand_path('~/.bosh_config')
|
6
|
-
DEFAULT_CACHE_DIR = File.expand_path('~/.bosh_cache')
|
7
4
|
end
|
8
5
|
end
|
9
6
|
|
@@ -50,7 +47,6 @@ require 'cli/dependency_helper'
|
|
50
47
|
require 'cli/deployment_manifest'
|
51
48
|
require 'cli/deployment_helper'
|
52
49
|
require 'cli/validation'
|
53
|
-
require 'cli/cache'
|
54
50
|
require 'cli/stemcell'
|
55
51
|
require 'cli/client/director'
|
56
52
|
require 'cli/director_task'
|
data/lib/cli/base_command.rb
CHANGED
data/lib/cli/commands/misc.rb
CHANGED
@@ -137,18 +137,6 @@ module Bosh::Cli::Command
|
|
137
137
|
say("You are no longer logged in to `#{target}'".make_yellow)
|
138
138
|
end
|
139
139
|
|
140
|
-
# bosh purge
|
141
|
-
usage "purge"
|
142
|
-
desc "Purge local manifest cache"
|
143
|
-
def purge_cache
|
144
|
-
if cache.cache_dir != Bosh::Cli::DEFAULT_CACHE_DIR
|
145
|
-
err("Cache directory overriden, please remove manually")
|
146
|
-
else
|
147
|
-
FileUtils.rm_rf(cache.cache_dir)
|
148
|
-
say("Purged cache".make_green)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
140
|
# bosh target
|
153
141
|
usage "target"
|
154
142
|
desc "Choose director to talk to (optionally creating an alias). " +
|
@@ -17,7 +17,7 @@ module Bosh::Cli::Command
|
|
17
17
|
usage "verify stemcell"
|
18
18
|
desc "Verify stemcell"
|
19
19
|
def verify(tarball_path)
|
20
|
-
stemcell = Bosh::Cli::Stemcell.new(tarball_path
|
20
|
+
stemcell = Bosh::Cli::Stemcell.new(tarball_path)
|
21
21
|
|
22
22
|
nl
|
23
23
|
say("Verifying stemcell...")
|
@@ -43,28 +43,28 @@ module Bosh::Cli::Command
|
|
43
43
|
|
44
44
|
stemcell_type = stemcell_location =~ /^#{URI::regexp}$/ ? "remote" : "local"
|
45
45
|
if stemcell_type == "local"
|
46
|
-
stemcell = Bosh::Cli::Stemcell.new(stemcell_location
|
47
|
-
|
46
|
+
stemcell = Bosh::Cli::Stemcell.new(stemcell_location)
|
47
|
+
|
48
48
|
nl
|
49
49
|
say("Verifying stemcell...")
|
50
50
|
stemcell.validate
|
51
51
|
nl
|
52
|
-
|
52
|
+
|
53
53
|
unless stemcell.valid?
|
54
54
|
err("Stemcell is invalid, please fix, verify and upload again")
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
say("Checking if stemcell already exists...")
|
58
58
|
name = stemcell.manifest["name"]
|
59
59
|
version = stemcell.manifest["version"]
|
60
|
-
|
60
|
+
|
61
61
|
if exists?(name, version)
|
62
62
|
err("Stemcell `#{name}/#{version}' already exists, " +
|
63
63
|
"increment the version if it has changed")
|
64
64
|
else
|
65
65
|
say("No")
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
stemcell_location = stemcell.stemcell_file
|
69
69
|
|
70
70
|
nl
|
data/lib/cli/commands/task.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Cli::Command
|
4
2
|
class Task < Base
|
5
3
|
|
@@ -8,7 +6,6 @@ module Bosh::Cli::Command
|
|
8
6
|
# bosh task
|
9
7
|
usage "task"
|
10
8
|
desc "Show task status and start tracking its output"
|
11
|
-
option "--no-cache", "Don't cache output locally"
|
12
9
|
option "--event", "Track event log"
|
13
10
|
option "--cpi", "Track CPI log"
|
14
11
|
option "--debug", "Track debug log"
|
@@ -18,7 +15,6 @@ module Bosh::Cli::Command
|
|
18
15
|
def track(task_id = nil)
|
19
16
|
auth_required
|
20
17
|
use_filter = !options.key?(:no_filter)
|
21
|
-
use_cache = !options.key?(:no_cache)
|
22
18
|
raw_output = options[:raw]
|
23
19
|
|
24
20
|
log_type = "event"
|
@@ -50,7 +46,6 @@ module Bosh::Cli::Command
|
|
50
46
|
|
51
47
|
track_options = {
|
52
48
|
:log_type => log_type,
|
53
|
-
:use_cache => use_cache,
|
54
49
|
:raw_output => raw_output
|
55
50
|
}
|
56
51
|
|
data/lib/cli/config.rb
CHANGED
@@ -17,9 +17,6 @@ module Bosh::Cli
|
|
17
17
|
# @return [Boolean] Is CLI being used interactively?
|
18
18
|
attr_accessor :interactive
|
19
19
|
|
20
|
-
# @return [Bosh::Cli::Cache] CLI cache (to save task logs etc.)
|
21
|
-
attr_accessor :cache
|
22
|
-
|
23
20
|
# @return [Integer] CLI polling interval
|
24
21
|
attr_accessor :poll_interval
|
25
22
|
end
|
@@ -28,7 +25,6 @@ module Bosh::Cli
|
|
28
25
|
@colorize = true
|
29
26
|
@output = nil
|
30
27
|
@interactive = false
|
31
|
-
@cache = nil
|
32
28
|
|
33
29
|
# Register command with BOSH CLI
|
34
30
|
# @param [Bosh::Cli::CommandDefinition] command
|
data/lib/cli/errors.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Cli
|
4
2
|
class CliError < StandardError
|
5
3
|
attr_reader :exit_code
|
@@ -34,8 +32,6 @@ module Bosh::Cli
|
|
34
32
|
class CliExit < CliError; error_code(400); end
|
35
33
|
class GracefulExit < CliExit; error_code(401); end
|
36
34
|
|
37
|
-
class CacheDirectoryError < CliError; error_code(301); end
|
38
|
-
|
39
35
|
class InvalidPackage < CliError; error_code(500); end
|
40
36
|
class InvalidJob < CliError; error_code(501); end
|
41
37
|
class InvalidRelease < CliError; error_code(503); end
|
data/lib/cli/runner.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Cli
|
4
2
|
class ParseTreeNode < Hash
|
5
3
|
attr_accessor :command
|
@@ -36,7 +34,6 @@ module Bosh::Cli
|
|
36
34
|
parse_global_options
|
37
35
|
|
38
36
|
Config.interactive = !@options[:non_interactive]
|
39
|
-
Config.cache = Bosh::Cli::Cache.new(@options[:cache_dir])
|
40
37
|
Config.poll_interval = @options[:poll_interval]
|
41
38
|
|
42
39
|
load_plugins
|
@@ -112,9 +109,7 @@ module Bosh::Cli
|
|
112
109
|
opts.on("-c", "--config FILE", config_desc) do |file|
|
113
110
|
@options[:config] = file
|
114
111
|
end
|
115
|
-
|
116
|
-
@options[:cache_dir] = dir
|
117
|
-
end
|
112
|
+
|
118
113
|
opts.on("--[no-]color", "Toggle colorized output") do |v|
|
119
114
|
Config.colorize = v
|
120
115
|
end
|
data/lib/cli/stemcell.rb
CHANGED
@@ -4,9 +4,8 @@ module Bosh::Cli
|
|
4
4
|
|
5
5
|
attr_reader :stemcell_file, :manifest
|
6
6
|
|
7
|
-
def initialize(tarball_path
|
7
|
+
def initialize(tarball_path)
|
8
8
|
@stemcell_file = File.expand_path(tarball_path, Dir.pwd)
|
9
|
-
@cache = cache
|
10
9
|
end
|
11
10
|
|
12
11
|
def perform_validation(options = {})
|
@@ -17,52 +16,42 @@ module Bosh::Cli
|
|
17
16
|
File.exists?(@stemcell_file) && File.readable?(@stemcell_file)
|
18
17
|
end
|
19
18
|
|
20
|
-
|
19
|
+
say("Verifying tarball...")
|
21
20
|
|
22
|
-
|
21
|
+
stemcell_mf = "stemcell.MF"
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
tar = nil
|
32
|
-
step("Read tarball",
|
33
|
-
"Cannot read tarball #{@stemcell_file}", :fatal) do
|
34
|
-
tgz = Zlib::GzipReader.new(File.open(@stemcell_file))
|
35
|
-
tar = Minitar.open(tgz)
|
36
|
-
!!tar
|
37
|
-
end
|
38
|
-
|
39
|
-
manifest = false
|
40
|
-
image = false
|
41
|
-
tar.each do |entry|
|
42
|
-
if entry.full_name == stemcell_mf
|
43
|
-
tar.extract_entry(tmp_dir, entry)
|
44
|
-
manifest = true
|
45
|
-
elsif entry.full_name == "image"
|
46
|
-
image = true
|
47
|
-
end
|
48
|
-
end
|
23
|
+
tar = nil
|
24
|
+
step("Read tarball",
|
25
|
+
"Cannot read tarball #{@stemcell_file}", :fatal) do
|
26
|
+
tgz = Zlib::GzipReader.new(File.open(@stemcell_file))
|
27
|
+
tar = Minitar.open(tgz)
|
28
|
+
!!tar
|
29
|
+
end
|
49
30
|
|
50
|
-
|
51
|
-
manifest
|
52
|
-
end
|
31
|
+
manifest = false # assign false because we return something truthy
|
53
32
|
|
54
|
-
|
55
|
-
|
56
|
-
|
33
|
+
image = false
|
34
|
+
tar.each do |entry|
|
35
|
+
if entry.full_name == stemcell_mf
|
36
|
+
tar.extract_entry(tmp_dir, entry)
|
37
|
+
manifest = true
|
38
|
+
elsif entry.full_name == "image"
|
39
|
+
image = true
|
57
40
|
end
|
41
|
+
end
|
58
42
|
|
59
|
-
|
43
|
+
step("Manifest exists", "Cannot find stemcell manifest", :fatal) do
|
44
|
+
manifest
|
45
|
+
end
|
60
46
|
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
step("Stemcell image file",
|
48
|
+
"Stemcell image file is missing", :fatal) do
|
49
|
+
image
|
64
50
|
end
|
65
51
|
|
52
|
+
manifest_file = File.expand_path(stemcell_mf, tmp_dir)
|
53
|
+
manifest_yaml = File.read(manifest_file)
|
54
|
+
|
66
55
|
manifest = Psych.load(manifest_yaml)
|
67
56
|
|
68
57
|
step("Stemcell properties",
|
data/lib/cli/task_tracker.rb
CHANGED
@@ -24,10 +24,8 @@ module Bosh
|
|
24
24
|
default_log_type = @quiet ? "none" : "event"
|
25
25
|
|
26
26
|
@log_type = options[:log_type] || default_log_type
|
27
|
-
@use_cache = options.key?(:use_cache) ? @options[:use_cache] : true
|
28
27
|
|
29
28
|
@output = nil
|
30
|
-
@cache = Config.cache
|
31
29
|
@task = Bosh::Cli::DirectorTask.new(@director, @task_id, @log_type)
|
32
30
|
|
33
31
|
if options[:renderer]
|
@@ -49,19 +47,10 @@ module Bosh
|
|
49
47
|
nl
|
50
48
|
@renderer.time_adjustment = @director.get_time_difference
|
51
49
|
say("Director task #{@task_id.to_s.make_yellow}")
|
52
|
-
|
53
|
-
cached_output = get_cached_task_output
|
54
|
-
if cached_output
|
55
|
-
task_status = @task.state.to_sym
|
56
|
-
output_received(cached_output)
|
57
|
-
@renderer.refresh
|
58
|
-
else
|
59
|
-
task_status = poll
|
60
|
-
end
|
50
|
+
task_status = poll
|
61
51
|
|
62
52
|
print_task_summary(task_status)
|
63
53
|
|
64
|
-
save_task_output unless cached_output
|
65
54
|
task_status
|
66
55
|
end
|
67
56
|
|
@@ -160,21 +149,6 @@ module Bosh
|
|
160
149
|
def interactive?
|
161
150
|
Bosh::Cli::Config.interactive
|
162
151
|
end
|
163
|
-
|
164
|
-
def get_cached_task_output
|
165
|
-
return nil unless @use_cache
|
166
|
-
@cache.read(task_cache_key)
|
167
|
-
end
|
168
|
-
|
169
|
-
def save_task_output
|
170
|
-
return nil unless @output && @use_cache
|
171
|
-
@cache.write(task_cache_key, @output)
|
172
|
-
end
|
173
|
-
|
174
|
-
def task_cache_key
|
175
|
-
"task/#{@director.uuid}/#{@task_id}/#{@log_type}"
|
176
|
-
end
|
177
|
-
|
178
152
|
end
|
179
153
|
end
|
180
154
|
end
|
data/lib/cli/version.rb
CHANGED
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.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1324
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.5.0.pre.
|
21
|
+
version: 1.5.0.pre.1324
|
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.5.0.pre.
|
29
|
+
version: 1.5.0.pre.1324
|
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.5.0.pre.
|
117
|
+
version: 1.5.0.pre.1324
|
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.5.0.pre.
|
125
|
+
version: 1.5.0.pre.1324
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: net-ssh
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,7 @@ dependencies:
|
|
221
221
|
version: '0'
|
222
222
|
description: ! 'BOSH CLI
|
223
223
|
|
224
|
-
|
224
|
+
f83ef2'
|
225
225
|
email: support@cloudfoundry.com
|
226
226
|
executables:
|
227
227
|
- bosh
|
@@ -233,7 +233,6 @@ files:
|
|
233
233
|
- lib/cli/backup_destination_path.rb
|
234
234
|
- lib/cli/base_command.rb
|
235
235
|
- lib/cli/blob_manager.rb
|
236
|
-
- lib/cli/cache.rb
|
237
236
|
- lib/cli/changeset_helper.rb
|
238
237
|
- lib/cli/client/compiled_packages_client.rb
|
239
238
|
- lib/cli/client/director.rb
|
data/lib/cli/cache.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
|
-
module Bosh::Cli
|
4
|
-
class Cache
|
5
|
-
|
6
|
-
attr_reader :cache_dir
|
7
|
-
|
8
|
-
def initialize(cache_dir = nil)
|
9
|
-
@cache_dir = cache_dir || Bosh::Cli::DEFAULT_CACHE_DIR
|
10
|
-
|
11
|
-
if File.exists?(@cache_dir) && !File.directory?(@cache_dir)
|
12
|
-
raise CacheDirectoryError, "BOSH cache directory error: " +
|
13
|
-
"`#{@cache_dir}' is a file, not directory"
|
14
|
-
end
|
15
|
-
|
16
|
-
unless File.exists?(@cache_dir)
|
17
|
-
FileUtils.mkdir_p(@cache_dir)
|
18
|
-
File.chmod(0700, @cache_dir)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def read(key)
|
23
|
-
cached_file = path(key)
|
24
|
-
return nil unless File.exists?(cached_file)
|
25
|
-
File.read(cached_file)
|
26
|
-
end
|
27
|
-
|
28
|
-
def write(key, value)
|
29
|
-
File.open(path(key), "w") do |f|
|
30
|
-
f.write(value)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def path(key)
|
37
|
-
File.expand_path(hash_for(key), @cache_dir)
|
38
|
-
end
|
39
|
-
|
40
|
-
def hash_for(key)
|
41
|
-
Digest::SHA1.hexdigest(key)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|