bosh_cli 1.3137.0 → 1.3138.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/client/director.rb +2 -2
- data/lib/cli/commands/instances.rb +57 -16
- data/lib/cli/commands/job_management.rb +10 -11
- data/lib/cli/job_state.rb +37 -19
- data/lib/cli/resources/job.rb +2 -2
- data/lib/cli/version.rb +1 -1
- metadata +8 -9
- data/lib/cli/vm_state.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cab55032d94ca82ccfcbabbccf72afae4dd11893
|
4
|
+
data.tar.gz: c8403927639e04ad6765c193d36ddbbcaaa23228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168282461378d2884f3dd028f4b1814a6b7f2f903d89987245ca42985a6da688c6e2b25b0f32f8563ecfabc4df98004f3bbde410ab03c64f89c5d202db1baa62
|
7
|
+
data.tar.gz: 0eb3d0bdcbd5cdde1c752873c3db06cba5c579e184c0457be96f080a22b94ada7b75b0b9e531a72fbeb2d132f707354f356086a51e74be4e60dd27d4ee7921a3
|
data/lib/cli/client/director.rb
CHANGED
@@ -300,12 +300,12 @@ module Bosh
|
|
300
300
|
end
|
301
301
|
|
302
302
|
def change_job_state(deployment_name, manifest_yaml,
|
303
|
-
|
303
|
+
job, index, new_state, options = {})
|
304
304
|
options = options.dup
|
305
305
|
|
306
306
|
skip_drain = !!options.delete(:skip_drain)
|
307
307
|
|
308
|
-
url = "/deployments/#{deployment_name}/jobs/#{
|
308
|
+
url = "/deployments/#{deployment_name}/jobs/#{job}"
|
309
309
|
url += "/#{index}" if index
|
310
310
|
url += "?state=#{new_state}"
|
311
311
|
url += "&skip_drain=true" if skip_drain
|
@@ -48,6 +48,8 @@ module Bosh::Cli::Command
|
|
48
48
|
|
49
49
|
row_count = 0
|
50
50
|
has_disk_cid = instances[0].has_key?('disk_cid')
|
51
|
+
has_uptime = instances[0]['processes'] && instances[0]['processes'].size > 0 && instances[0]['processes'][0].has_key?('uptime')
|
52
|
+
has_cpu = instances[0]['processes'] && instances[0]['processes'].size > 0 && instances[0]['processes'][0].has_key?('cpu')
|
51
53
|
|
52
54
|
instances_table = table do |t|
|
53
55
|
headings = ['Instance', 'State', 'Resource Pool', 'IPs']
|
@@ -58,16 +60,21 @@ module Bosh::Cli::Command
|
|
58
60
|
headings += ['VM CID', 'Agent ID', 'Resurrection']
|
59
61
|
end
|
60
62
|
end
|
63
|
+
|
61
64
|
if options[:dns]
|
62
65
|
headings += ['DNS A records']
|
63
66
|
end
|
67
|
+
|
64
68
|
if options[:vitals]
|
69
|
+
headings += [{:value => "Uptime", :alignment => :center}] if options[:ps] && has_uptime
|
65
70
|
headings += [{:value => "Load\n(avg01, avg05, avg15)", :alignment => :center}]
|
66
|
-
headings += ["CPU
|
71
|
+
headings += [{:value => "CPU %\n(User, Sys, Wait)", :alignment => :center}]
|
72
|
+
headings += ["CPU %"] if options[:ps] && has_cpu
|
67
73
|
headings += ['Memory Usage', 'Swap Usage']
|
68
74
|
headings += ["System\nDisk Usage", "Ephemeral\nDisk Usage", "Persistent\nDisk Usage"]
|
69
75
|
end
|
70
|
-
|
76
|
+
|
77
|
+
last_job = ''
|
71
78
|
sorted.each do |instance|
|
72
79
|
if options[:failing]
|
73
80
|
if options[:ps]
|
@@ -92,6 +99,7 @@ module Bosh::Cli::Command
|
|
92
99
|
vitals = instance['vitals']
|
93
100
|
|
94
101
|
row = [job, instance['job_state'], instance['resource_pool'], ips]
|
102
|
+
t << :separator if row_count.between?(2, instance_count) && (options[:ps] || last_job != '' && instance['job_name'] != last_job)
|
95
103
|
|
96
104
|
if options[:details]
|
97
105
|
if has_disk_cid
|
@@ -112,10 +120,10 @@ module Bosh::Cli::Command
|
|
112
120
|
swap = vitals['swap']
|
113
121
|
disk = vitals['disk']
|
114
122
|
|
123
|
+
row << '' if options[:ps] && has_uptime && instance['processes'].size > 0
|
115
124
|
row << vitals['load'].join(', ')
|
116
|
-
row << "#{cpu['user']}%"
|
117
|
-
row <<
|
118
|
-
row << "#{cpu['wait']}%"
|
125
|
+
row << "#{cpu['user']}%, #{cpu['sys']}%, #{cpu['wait']}%"
|
126
|
+
row << '' if options[:ps] && has_cpu && instance['processes'].size > 0
|
119
127
|
row << "#{mem['percent']}% (#{pretty_size(mem['kb'].to_i * 1024)})"
|
120
128
|
row << "#{swap['percent']}% (#{pretty_size(swap['kb'].to_i * 1024)})"
|
121
129
|
row << "#{disk['system']['percent']}%"
|
@@ -132,21 +140,54 @@ module Bosh::Cli::Command
|
|
132
140
|
else
|
133
141
|
9.times { row << 'n/a' }
|
134
142
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
t << row
|
144
|
+
|
145
|
+
if options[:ps] && instance['processes']
|
146
|
+
instance['processes'].each do |process|
|
147
|
+
prow = [' ' + process['name'], process['state'], '', '']
|
148
|
+
if options[:details]
|
149
|
+
prow += ['','','']
|
150
|
+
prow << '' if has_disk_cid
|
151
|
+
end
|
152
|
+
if has_uptime
|
153
|
+
if process['uptime']
|
154
|
+
uptime = Integer(process['uptime']['secs'])
|
155
|
+
days = uptime/60/60/24
|
156
|
+
hours = uptime/60/60%24
|
157
|
+
minutes = uptime/60%60
|
158
|
+
seconds = uptime%60
|
159
|
+
prow << "#{days}d #{hours}h #{minutes}m #{seconds}s"
|
160
|
+
else
|
161
|
+
prow << ''
|
162
|
+
end
|
163
|
+
end
|
164
|
+
prow += ['','']
|
165
|
+
prow << (process['cpu'] ? "#{process['cpu']['total']}%":'') if has_cpu
|
166
|
+
prow << (process['mem'] ? "#{process['mem']['percent']}% (#{pretty_size(process['mem']['kb'].to_i * 1024)})":'')
|
167
|
+
4.times { prow << '' }
|
168
|
+
t << prow
|
169
|
+
end
|
170
|
+
end
|
171
|
+
else
|
172
|
+
t << row
|
173
|
+
if options[:ps] && instance['processes']
|
174
|
+
instance['processes'].each do |process|
|
175
|
+
name = process['name']
|
176
|
+
state = process['state']
|
177
|
+
process_row = [" #{name}", "#{state}"]
|
178
|
+
(headings.size - 2).times { process_row << '' }
|
179
|
+
t << process_row
|
180
|
+
end
|
145
181
|
end
|
182
|
+
end
|
146
183
|
|
147
|
-
|
184
|
+
last_job = instance['job_name'] || 'unknown'
|
185
|
+
if instance['processes'].size == 0 && instance_count == 1
|
186
|
+
headings.delete_at(4)
|
187
|
+
headings.delete_at(6)
|
148
188
|
end
|
149
189
|
end
|
190
|
+
t.headings = headings
|
150
191
|
end
|
151
192
|
|
152
193
|
if options[:failing] && row_count == 0
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009-2012 VMware, Inc.
|
2
2
|
require 'cli/job_state'
|
3
|
-
require 'cli/vm_state'
|
4
3
|
|
5
4
|
module Bosh::Cli
|
6
5
|
module Command
|
@@ -18,12 +17,12 @@ module Bosh::Cli
|
|
18
17
|
|
19
18
|
# bosh stop
|
20
19
|
usage 'stop'
|
21
|
-
desc 'Stop job/instance'
|
20
|
+
desc 'Stop all jobs/job/instance'
|
22
21
|
option '--soft', 'Stop process only'
|
23
22
|
option '--hard', 'Power off VM'
|
24
23
|
option '--force', FORCE
|
25
24
|
option '--skip-drain', SKIP_DRAIN
|
26
|
-
def stop_job(job, index = nil)
|
25
|
+
def stop_job(job = '*', index = nil)
|
27
26
|
if hard?
|
28
27
|
change_job_state(:detach, job, index)
|
29
28
|
else
|
@@ -53,12 +52,13 @@ module Bosh::Cli
|
|
53
52
|
|
54
53
|
def change_job_state(state, job, index = nil)
|
55
54
|
auth_required
|
56
|
-
manifest = parse_manifest(state
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
manifest = parse_manifest(state)
|
56
|
+
unless job == '*'
|
57
|
+
job_must_exist_in_deployment(manifest.hash, job)
|
58
|
+
index = valid_index_for(manifest.hash, job, index) unless state == :stop || state == :detach
|
59
|
+
end
|
60
|
+
job_state = JobState.new(self, manifest, skip_drain: skip_drain?)
|
61
|
+
status, task_id, completion_desc = job_state.change(state, job, index, force?)
|
62
62
|
task_report(status, task_id, completion_desc)
|
63
63
|
end
|
64
64
|
|
@@ -78,9 +78,8 @@ module Bosh::Cli
|
|
78
78
|
!!options[:skip_drain]
|
79
79
|
end
|
80
80
|
|
81
|
-
def parse_manifest(operation
|
81
|
+
def parse_manifest(operation)
|
82
82
|
manifest = prepare_deployment_manifest(show_state: true)
|
83
|
-
job_must_exist_in_deployment(manifest.hash, job)
|
84
83
|
|
85
84
|
if hard? && soft?
|
86
85
|
err('Cannot handle both --hard and --soft options, please choose one')
|
data/lib/cli/job_state.rb
CHANGED
@@ -3,7 +3,7 @@ module Bosh::Cli
|
|
3
3
|
OPERATION_DESCRIPTIONS = {
|
4
4
|
start: 'start %s',
|
5
5
|
stop: 'stop %s',
|
6
|
-
detach: 'stop %s and
|
6
|
+
detach: 'stop %s and delete its VM(s)',
|
7
7
|
restart: 'restart %s',
|
8
8
|
recreate: 'recreate %s'
|
9
9
|
}
|
@@ -17,39 +17,57 @@ module Bosh::Cli
|
|
17
17
|
}
|
18
18
|
|
19
19
|
COMPLETION_DESCRIPTIONS = {
|
20
|
-
start: '%s
|
21
|
-
stop: '%s
|
22
|
-
detach: '%s
|
23
|
-
restart: '%s
|
24
|
-
recreate: '%s
|
20
|
+
start: '%s started',
|
21
|
+
stop: '%s stopped, VM(s) still running',
|
22
|
+
detach: '%s detached, VM(s) deleted',
|
23
|
+
restart: '%s restarted',
|
24
|
+
recreate: '%s recreated'
|
25
25
|
}
|
26
26
|
|
27
|
-
def initialize(command,
|
27
|
+
def initialize(command, manifest, options)
|
28
28
|
@command = command
|
29
|
-
@
|
29
|
+
@manifest = manifest
|
30
30
|
@options = options
|
31
31
|
end
|
32
32
|
|
33
|
-
def change(state, job, index)
|
34
|
-
|
35
|
-
op_desc = OPERATION_DESCRIPTIONS.fetch(state) %
|
33
|
+
def change(state, job, index, force)
|
34
|
+
description = job_description(job, index)
|
35
|
+
op_desc = OPERATION_DESCRIPTIONS.fetch(state) % description
|
36
36
|
new_state = NEW_STATES.fetch(state)
|
37
|
-
completion_desc = COMPLETION_DESCRIPTIONS.fetch(state) %
|
38
|
-
|
39
|
-
status, task_id = perform_vm_state_change(job, index, new_state, op_desc)
|
37
|
+
completion_desc = COMPLETION_DESCRIPTIONS.fetch(state) % description.make_green
|
38
|
+
status, task_id = change_job_state(new_state, job, index, op_desc, force)
|
40
39
|
|
41
40
|
[status, task_id, completion_desc]
|
42
41
|
end
|
43
42
|
|
44
43
|
private
|
45
|
-
attr_reader :command, :vm_state
|
46
44
|
|
47
|
-
def
|
48
|
-
|
45
|
+
def change_job_state(new_state, job, index, operation_desc, force)
|
46
|
+
@command.say("You are about to #{operation_desc.make_green}")
|
47
|
+
|
48
|
+
check_if_manifest_changed(@manifest.hash, force)
|
49
|
+
unless @command.confirmed?("#{operation_desc.capitalize}?")
|
50
|
+
@command.cancel_deployment
|
51
|
+
end
|
52
|
+
|
53
|
+
@command.nl
|
54
|
+
@command.say("Performing `#{operation_desc}'...")
|
55
|
+
@command.director.change_job_state(@manifest.name, @manifest.yaml, job, index, new_state, @options)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def check_if_manifest_changed(manifest_hash, force)
|
60
|
+
other_changes_present = @command.inspect_deployment_changes(manifest_hash, show_empty_changeset: false)
|
61
|
+
|
62
|
+
if other_changes_present && !force
|
63
|
+
@command.err("Cannot perform job management when other deployment changes are present. Please use `--force' to override.")
|
64
|
+
end
|
49
65
|
end
|
50
66
|
|
51
|
-
def
|
52
|
-
|
67
|
+
def job_description(job, index)
|
68
|
+
return 'all jobs' if job == '*'
|
69
|
+
index ? "#{job}/#{index}" : "#{job}/*"
|
53
70
|
end
|
71
|
+
|
54
72
|
end
|
55
73
|
end
|
data/lib/cli/resources/job.rb
CHANGED
@@ -19,8 +19,8 @@ module Bosh::Cli::Resources
|
|
19
19
|
|
20
20
|
def spec
|
21
21
|
@spec ||= load_yaml_file(job_base.join('spec'))
|
22
|
-
rescue
|
23
|
-
raise Bosh::Cli::InvalidJob,
|
22
|
+
rescue Exception => e
|
23
|
+
raise Bosh::Cli::InvalidJob, "Job spec is missing or invalid: #{e.message}"
|
24
24
|
end
|
25
25
|
|
26
26
|
def name
|
data/lib/cli/version.rb
CHANGED
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.
|
4
|
+
version: 1.3138.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-11-
|
11
|
+
date: 2015-11-16 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.
|
19
|
+
version: 1.3138.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.
|
26
|
+
version: 1.3138.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.
|
33
|
+
version: 1.3138.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.
|
40
|
+
version: 1.3138.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.
|
131
|
+
version: 1.3138.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.
|
138
|
+
version: 1.3138.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: net-ssh
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -447,7 +447,6 @@ files:
|
|
447
447
|
- lib/cli/versions/releases_dir_migrator.rb
|
448
448
|
- lib/cli/versions/version_file_resolver.rb
|
449
449
|
- lib/cli/versions/versions_index.rb
|
450
|
-
- lib/cli/vm_state.rb
|
451
450
|
- lib/cli/yaml_helper.rb
|
452
451
|
homepage: https://github.com/cloudfoundry/bosh
|
453
452
|
licenses:
|
data/lib/cli/vm_state.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Bosh::Cli
|
2
|
-
class VmState
|
3
|
-
def initialize(command, manifest, force)
|
4
|
-
@command = command
|
5
|
-
@manifest = manifest
|
6
|
-
@force = force
|
7
|
-
end
|
8
|
-
|
9
|
-
def change(job, index, new_state, operation_desc, options = {})
|
10
|
-
command.say("You are about to #{operation_desc.make_green}")
|
11
|
-
|
12
|
-
check_if_manifest_changed(@manifest.hash)
|
13
|
-
|
14
|
-
unless command.confirmed?("#{operation_desc.capitalize}?")
|
15
|
-
command.cancel_deployment
|
16
|
-
end
|
17
|
-
|
18
|
-
command.nl
|
19
|
-
command.say("Performing `#{operation_desc}'...")
|
20
|
-
command.director.change_job_state(
|
21
|
-
@manifest.name,
|
22
|
-
@manifest.yaml,
|
23
|
-
job,
|
24
|
-
index,
|
25
|
-
new_state,
|
26
|
-
options
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
attr_reader :command
|
32
|
-
|
33
|
-
def force?
|
34
|
-
!!@force
|
35
|
-
end
|
36
|
-
|
37
|
-
def check_if_manifest_changed(manifest_hash)
|
38
|
-
other_changes_present = command.inspect_deployment_changes(manifest_hash, show_empty_changeset: false)
|
39
|
-
|
40
|
-
if other_changes_present && !force?
|
41
|
-
command.err("Cannot perform job management when other deployment changes are present. Please use `--force' to override.")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|