bosh_cli 1.2862.0 → 1.2865.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 +4 -4
- data/lib/cli/client/director.rb +6 -0
- data/lib/cli/commands/login.rb +35 -0
- data/lib/cli/commands/misc.rb +0 -57
- data/lib/cli/config.rb +37 -8
- data/lib/cli/login_service.rb +40 -0
- data/lib/cli/terminal.rb +30 -0
- data/lib/cli/version.rb +1 -1
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd312c4c998f31d9f79fd35a586deb701246207
|
4
|
+
data.tar.gz: 4f052201dbc90e01f5d1759919863aecd43b86d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236e568970014d4abab3d2ace8a42f6743cf1ee1abed16574ee8eab88fcf76c15f412fb05d3afb017cf65a2fccede4451bba88dbde25f0ca1ded9f28c3a94048
|
7
|
+
data.tar.gz: 63c9739f69ca88620c607c46f20123cc20475fb1d6c4ad339412475b990b121bdc8528e1b89edd8c202aa026971d7b4b7eefada5fb6da96feb7bdeb23ff86428
|
data/lib/cli/client/director.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'cli/terminal'
|
2
|
+
require 'cli/login_service'
|
3
|
+
|
4
|
+
module Bosh::Cli::Command
|
5
|
+
class Login < Base
|
6
|
+
# bosh login
|
7
|
+
usage "login"
|
8
|
+
desc "Log in to currently targeted director. " +
|
9
|
+
"The username and password can also be " +
|
10
|
+
"set in the BOSH_USER and BOSH_PASSWORD " +
|
11
|
+
"environment variables."
|
12
|
+
def login(username = nil, password = nil)
|
13
|
+
target_required
|
14
|
+
|
15
|
+
terminal = Bosh::Cli::Terminal.new(HighLine.new)
|
16
|
+
Bosh::Cli::LoginService.new(terminal, director, config, interactive?).login(target, username.to_s, password.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
# bosh logout
|
20
|
+
usage "logout"
|
21
|
+
desc "Forget saved credentials for targeted director"
|
22
|
+
def logout
|
23
|
+
target_required
|
24
|
+
config.set_credentials(target, nil, nil)
|
25
|
+
config.save
|
26
|
+
say("You are no longer logged in to `#{target}'".make_yellow)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def get_director_status
|
32
|
+
Bosh::Cli::Client::Director.new(target).get_status
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/cli/commands/misc.rb
CHANGED
@@ -62,63 +62,6 @@ module Bosh::Cli::Command
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
# bosh login
|
66
|
-
usage "login"
|
67
|
-
desc "Log in to currently targeted director. " +
|
68
|
-
"The username and password can also be " +
|
69
|
-
"set in the BOSH_USER and BOSH_PASSWORD " +
|
70
|
-
"environment variables."
|
71
|
-
def login(username = nil, password = nil)
|
72
|
-
target_required
|
73
|
-
|
74
|
-
if interactive?
|
75
|
-
username = ask("Your username: ").to_s if username.blank?
|
76
|
-
|
77
|
-
password_retries = 0
|
78
|
-
while password.blank? && password_retries < 3
|
79
|
-
password = ask("Enter password: ") { |q| q.echo = "*" }.to_s
|
80
|
-
password_retries += 1
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
if username.blank? || password.blank?
|
85
|
-
err("Please provide username and password")
|
86
|
-
end
|
87
|
-
logged_in = false
|
88
|
-
|
89
|
-
#Converts HighLine::String to String
|
90
|
-
username = username.to_s
|
91
|
-
password = password.to_s
|
92
|
-
|
93
|
-
director.user = username
|
94
|
-
director.password = password
|
95
|
-
|
96
|
-
if director.authenticated?
|
97
|
-
say("Logged in as `#{username}'".make_green)
|
98
|
-
logged_in = true
|
99
|
-
elsif non_interactive?
|
100
|
-
err("Cannot log in as `#{username}'".make_red)
|
101
|
-
else
|
102
|
-
say("Cannot log in as `#{username}', please try again".make_red)
|
103
|
-
login(username)
|
104
|
-
end
|
105
|
-
|
106
|
-
if logged_in
|
107
|
-
config.set_credentials(target, username, password)
|
108
|
-
config.save
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# bosh logout
|
113
|
-
usage "logout"
|
114
|
-
desc "Forget saved credentials for targeted director"
|
115
|
-
def logout
|
116
|
-
target_required
|
117
|
-
config.set_credentials(target, nil, nil)
|
118
|
-
config.save
|
119
|
-
say("You are no longer logged in to `#{target}'".make_yellow)
|
120
|
-
end
|
121
|
-
|
122
65
|
# bosh target
|
123
66
|
usage "target"
|
124
67
|
desc "Choose director to talk to (optionally creating an alias). " +
|
data/lib/cli/config.rb
CHANGED
@@ -158,15 +158,44 @@ module Bosh::Cli
|
|
158
158
|
@config_file["deployment"][target] = deployment_file_path
|
159
159
|
end
|
160
160
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
read(attr, false)
|
165
|
-
end
|
161
|
+
def target
|
162
|
+
read(:target, false)
|
163
|
+
end
|
166
164
|
|
167
|
-
|
168
|
-
|
169
|
-
|
165
|
+
def target=(value)
|
166
|
+
write_global(:target, value)
|
167
|
+
end
|
168
|
+
|
169
|
+
def target_name
|
170
|
+
read(:target_name, false)
|
171
|
+
end
|
172
|
+
|
173
|
+
def target_name=(value)
|
174
|
+
write_global(:target_name, value)
|
175
|
+
end
|
176
|
+
|
177
|
+
def target_version
|
178
|
+
read(:target_version, false)
|
179
|
+
end
|
180
|
+
|
181
|
+
def target_version=(value)
|
182
|
+
write_global(:target_version, value)
|
183
|
+
end
|
184
|
+
|
185
|
+
def release
|
186
|
+
read(:release, false)
|
187
|
+
end
|
188
|
+
|
189
|
+
def release=(value)
|
190
|
+
write_global(:release, value)
|
191
|
+
end
|
192
|
+
|
193
|
+
def target_uuid
|
194
|
+
read(:target_uuid, false)
|
195
|
+
end
|
196
|
+
|
197
|
+
def target_uuid=(value)
|
198
|
+
write_global(:target_uuid, value)
|
170
199
|
end
|
171
200
|
|
172
201
|
# Read the max parallel downloads configuration.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'highline'
|
2
|
+
require 'cli/core_ext'
|
3
|
+
require 'cli/errors'
|
4
|
+
|
5
|
+
module Bosh
|
6
|
+
module Cli
|
7
|
+
class LoginService
|
8
|
+
def initialize(terminal, director, config, interactive)
|
9
|
+
@terminal = terminal
|
10
|
+
@director = director
|
11
|
+
@config = config
|
12
|
+
@interactive = interactive
|
13
|
+
end
|
14
|
+
|
15
|
+
def login(target, username, password)
|
16
|
+
if @interactive
|
17
|
+
username = @terminal.ask("Your username: ") if username.blank?
|
18
|
+
password = @terminal.ask_password("Enter password: ") if password.blank?
|
19
|
+
end
|
20
|
+
|
21
|
+
if username.blank? || password.blank?
|
22
|
+
raise Bosh::Cli::CliError.new("Please provide username and password")
|
23
|
+
end
|
24
|
+
|
25
|
+
if @director.login(username, password)
|
26
|
+
@terminal.say_green("Logged in as `#{username}'")
|
27
|
+
@config.set_credentials(target, username, password)
|
28
|
+
@config.save
|
29
|
+
else
|
30
|
+
if @interactive
|
31
|
+
@terminal.say_red("Cannot log in as `#{username}', please try again")
|
32
|
+
login(target, username, '')
|
33
|
+
else
|
34
|
+
raise Bosh::Cli::CliError.new("Cannot log in as `#{username}'")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/cli/terminal.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bosh
|
2
|
+
module Cli
|
3
|
+
class Terminal
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
def initialize(highline)
|
7
|
+
@highline = highline
|
8
|
+
end
|
9
|
+
|
10
|
+
def ask(prompt)
|
11
|
+
highline.ask(prompt).to_s # make sure we return a String not a HighLine::String
|
12
|
+
end
|
13
|
+
|
14
|
+
def ask_password(prompt)
|
15
|
+
highline.ask(prompt) { |q| q.echo = false }.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def say_green(message)
|
19
|
+
highline.say(message.make_green)
|
20
|
+
end
|
21
|
+
|
22
|
+
def say_red(message)
|
23
|
+
highline.say(message.make_red)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
attr_reader :highline
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
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.2865.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-03-
|
11
|
+
date: 2015-03-06 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.2865.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.2865.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.2865.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.2865.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json_pure
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.2865.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.2865.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: net-ssh
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +194,7 @@ dependencies:
|
|
194
194
|
version: 0.5.4
|
195
195
|
description: |-
|
196
196
|
BOSH CLI
|
197
|
-
|
197
|
+
14ebaf
|
198
198
|
email: support@cloudfoundry.com
|
199
199
|
executables:
|
200
200
|
- bosh
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/cli/commands/job_rename.rb
|
232
232
|
- lib/cli/commands/locks.rb
|
233
233
|
- lib/cli/commands/log_management.rb
|
234
|
+
- lib/cli/commands/login.rb
|
234
235
|
- lib/cli/commands/maintenance.rb
|
235
236
|
- lib/cli/commands/misc.rb
|
236
237
|
- lib/cli/commands/package.rb
|
@@ -266,6 +267,7 @@ files:
|
|
266
267
|
- lib/cli/job_property_validator.rb
|
267
268
|
- lib/cli/job_state.rb
|
268
269
|
- lib/cli/line_wrap.rb
|
270
|
+
- lib/cli/login_service.rb
|
269
271
|
- lib/cli/logs_downloader.rb
|
270
272
|
- lib/cli/manifest_warnings.rb
|
271
273
|
- lib/cli/name_version_pair.rb
|
@@ -293,6 +295,7 @@ files:
|
|
293
295
|
- lib/cli/task_tracking/task_log_renderer.rb
|
294
296
|
- lib/cli/task_tracking/task_tracker.rb
|
295
297
|
- lib/cli/task_tracking/total_duration.rb
|
298
|
+
- lib/cli/terminal.rb
|
296
299
|
- lib/cli/validation.rb
|
297
300
|
- lib/cli/version.rb
|
298
301
|
- lib/cli/versions/local_artifact_storage.rb
|