Class: Bosh::Cli::Command::Base
Direct Known Subclasses
Backup, Biff, BlobManagement, CloudCheck, CloudConfig, Complete, Deployment, Errand, Help, Instances, Job, JobManagement, JobRename, Locks, LogManagement, Login, Maintenance, Misc, Package, PropertyManagement, Release::CreateRelease, Release::DeleteRelease, Release::ExportRelease, Release::FinalizeRelease, Release::InitRelease, Release::InspectRelease, Release::ListReleases, Release::ResetRelease, Release::UploadRelease, Release::VerifyRelease, Snapshot, Ssh, Stemcell, Task, User, Vm, Vms
Constant Summary
collapse
- DEFAULT_DIRECTOR_PORT =
25555
Instance Attribute Summary collapse
Instance Method Summary
collapse
desc, method_added, option, register_command, usage
#cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_in_deployment?, #job_must_exist_in_deployment, #job_unique_in_deployment?, #jobs_and_indexes, #prepare_deployment_manifest, #prompt_for_errand_name, #prompt_for_job_and_index
Constructor Details
#initialize(runner = nil, director = nil) ⇒ Base
Returns a new instance of Base.
13
14
15
16
17
18
19
20
21
|
# File 'lib/cli/base_command.rb', line 13
def initialize(runner = nil, director = nil)
@runner = runner
@director = director
@options = {}
@work_dir = Dir.pwd
@exit_code = 0
@out = nil
@args = []
end
|
Instance Attribute Details
Returns the value of attribute args.
7
8
9
|
# File 'lib/cli/base_command.rb', line 7
def args
@args
end
|
#exit_code ⇒ Object
Returns the value of attribute exit_code.
8
9
10
|
# File 'lib/cli/base_command.rb', line 8
def exit_code
@exit_code
end
|
Returns the value of attribute options.
7
8
9
|
# File 'lib/cli/base_command.rb', line 7
def options
@options
end
|
Returns the value of attribute out.
7
8
9
|
# File 'lib/cli/base_command.rb', line 7
def out
@out
end
|
Returns the value of attribute runner.
8
9
10
|
# File 'lib/cli/base_command.rb', line 8
def runner
@runner
end
|
Returns the value of attribute work_dir.
8
9
10
|
# File 'lib/cli/base_command.rb', line 8
def work_dir
@work_dir
end
|
Instance Method Details
#add_option(name, value) ⇒ Object
33
34
35
|
# File 'lib/cli/base_command.rb', line 33
def add_option(name, value)
@options[name] = value
end
|
#blob_manager ⇒ Object
56
57
58
|
# File 'lib/cli/base_command.rb', line 56
def blob_manager
@blob_manager ||= Bosh::Cli::BlobManager.new(release, config.max_parallel_downloads, progress_renderer)
end
|
#blobstore ⇒ Object
60
61
62
|
# File 'lib/cli/base_command.rb', line 60
def blobstore
release.blobstore
end
|
#cache_dir ⇒ Object
121
122
123
|
# File 'lib/cli/base_command.rb', line 121
def cache_dir
File.join(Dir.home, '.bosh', 'cache')
end
|
Returns Current configuration.
24
25
26
27
28
29
30
31
|
# File 'lib/cli/base_command.rb', line 24
def config
@config ||= begin
env_bosh_config = ENV['BOSH_CONFIG'].to_s.empty? ? nil : ENV['BOSH_CONFIG']
config_file = options[:config] || env_bosh_config || Bosh::Cli::DEFAULT_CONFIG_PATH
Bosh::Cli::Config.new(config_file)
end
end
|
#confirmed?(question = 'Are you sure?') ⇒ Boolean
84
85
86
87
|
# File 'lib/cli/base_command.rb', line 84
def confirmed?(question = 'Are you sure?')
return true if non_interactive?
ask("#{question} (type 'yes' to continue): ") == 'yes'
end
|
#credentials ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/cli/base_command.rb', line 103
def credentials
return @credentials if @credentials
if auth_info.uaa?
token_decoder = Client::Uaa::TokenDecoder.new
uaa_token_provider = Client::Uaa::TokenProvider.new(auth_info, config, token_decoder, target)
@credentials = Client::UaaCredentials.new(uaa_token_provider)
elsif username && password
@credentials = Client::BasicCredentials.new(username, password)
end
@credentials
end
|
#deployment ⇒ String
Returns Deployment manifest path.
99
100
101
|
# File 'lib/cli/base_command.rb', line 99
def deployment
options[:deployment] || config.deployment
end
|
41
42
43
44
|
# File 'lib/cli/base_command.rb', line 41
def director
@director ||= Bosh::Cli::Client::Director.new(
target, credentials, @options.select { |k, _| k == :no_track })
end
|
#interactive? ⇒ Boolean
72
73
74
|
# File 'lib/cli/base_command.rb', line 72
def interactive?
!non_interactive?
end
|
#logged_in? ⇒ Boolean
64
65
66
|
# File 'lib/cli/base_command.rb', line 64
def logged_in?
!!(credentials && credentials.)
end
|
#non_interactive? ⇒ Boolean
68
69
70
|
# File 'lib/cli/base_command.rb', line 68
def non_interactive?
options[:non_interactive]
end
|
#redirect(*args) ⇒ Object
80
81
82
|
# File 'lib/cli/base_command.rb', line 80
def redirect(*args)
Bosh::Cli::Runner.new(args, @options).run
end
|
46
47
48
49
50
|
# File 'lib/cli/base_command.rb', line 46
def release
return @release if @release
check_if_release_dir
@release = Bosh::Cli::Release.new(release_directory, options[:final])
end
|
#remove_option(name) ⇒ Object
37
38
39
|
# File 'lib/cli/base_command.rb', line 37
def remove_option(name)
@options.delete(name)
end
|
#show_current_state(deployment_name = nil) ⇒ Object
125
126
127
128
129
130
131
|
# File 'lib/cli/base_command.rb', line 125
def show_current_state(deployment_name=nil)
user_desc = auth_info.client_auth? ? 'client' : 'user'
msg = "Acting as #{user_desc} '#{credentials.username.to_s.make_green}'"
msg += " on deployment '#{deployment_name.make_green}'" if deployment_name
msg += " on '#{target_name.make_green}'" if target_name
warn(msg)
end
|
#target ⇒ String
Also known as:
target_url
Returns Target director URL.
90
91
92
93
94
|
# File 'lib/cli/base_command.rb', line 90
def target
raw_url = options[:target] || config.target
url = config.resolve_alias(:target, raw_url) || raw_url
url ? normalize_url(url) : nil
end
|
#target_name ⇒ Object
117
118
119
|
# File 'lib/cli/base_command.rb', line 117
def target_name
options[:target] || config.target_name || target_url
end
|
#verbose? ⇒ Boolean
76
77
78
|
# File 'lib/cli/base_command.rb', line 76
def verbose?
@options[:verbose]
end
|