Class: Bosh::Cli::Command::Base
Direct Known Subclasses
Backup, Biff, BlobManagement, CloudCheck, CloudConfig, Complete, Deployment, Errand, ExportCompiledPackages, Help, ImportCompiledPackages, Job, JobManagement, JobRename, Locks, LogManagement, Login, Maintenance, Misc, Package, PropertyManagement, Release::CreateRelease, Release::DeleteRelease, Release::InitRelease, 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, #latest_release_versions, #prepare_deployment_manifest, #prompt_for_errand_name, #prompt_for_job_and_index, #resolve_release_aliases, #warn_about_stemcell_changes
Constructor Details
#initialize(runner = nil, director = nil) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
20
21
22
23
|
# File 'lib/cli/base_command.rb', line 15
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.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def args
@args
end
|
#exit_code ⇒ Object
Returns the value of attribute exit_code.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def exit_code
@exit_code
end
|
Returns the value of attribute options.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def options
@options
end
|
Returns the value of attribute out.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def out
@out
end
|
Returns the value of attribute runner.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def runner
@runner
end
|
Returns the value of attribute work_dir.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def work_dir
@work_dir
end
|
Instance Method Details
#add_option(name, value) ⇒ Object
35
36
37
|
# File 'lib/cli/base_command.rb', line 35
def add_option(name, value)
@options[name] = value
end
|
#blob_manager ⇒ Object
58
59
60
|
# File 'lib/cli/base_command.rb', line 58
def blob_manager
@blob_manager ||= Bosh::Cli::BlobManager.new(release, config.max_parallel_downloads, progress_renderer)
end
|
#blobstore ⇒ Object
62
63
64
|
# File 'lib/cli/base_command.rb', line 62
def blobstore
release.blobstore
end
|
#cache_dir ⇒ Object
119
120
121
|
# File 'lib/cli/base_command.rb', line 119
def cache_dir
File.join(Dir.home, '.bosh', 'cache')
end
|
Returns Current configuration.
26
27
28
29
30
31
32
33
|
# File 'lib/cli/base_command.rb', line 26
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
86
87
88
89
|
# File 'lib/cli/base_command.rb', line 86
def confirmed?(question = 'Are you sure?')
return true if non_interactive?
ask("#{question} (type 'yes' to continue): ") == 'yes'
end
|
#deployment ⇒ String
Returns Deployment manifest path.
100
101
102
|
# File 'lib/cli/base_command.rb', line 100
def deployment
options[:deployment] || config.deployment
end
|
43
44
45
46
|
# File 'lib/cli/base_command.rb', line 43
def director
@director ||= Bosh::Cli::Client::Director.new(
target, credentials, @options.select { |k, _| k == :no_track })
end
|
#interactive? ⇒ Boolean
74
75
76
|
# File 'lib/cli/base_command.rb', line 74
def interactive?
!non_interactive?
end
|
#logged_in? ⇒ Boolean
66
67
68
|
# File 'lib/cli/base_command.rb', line 66
def logged_in?
!!(credentials)
end
|
#non_interactive? ⇒ Boolean
70
71
72
|
# File 'lib/cli/base_command.rb', line 70
def non_interactive?
options[:non_interactive]
end
|
#redirect(*args) ⇒ Object
82
83
84
|
# File 'lib/cli/base_command.rb', line 82
def redirect(*args)
Bosh::Cli::Runner.new(args, @options).run
end
|
48
49
50
51
52
|
# File 'lib/cli/base_command.rb', line 48
def release
return @release if @release
check_if_release_dir
@release = Bosh::Cli::Release.new(work_dir, options[:final])
end
|
#remove_option(name) ⇒ Object
39
40
41
|
# File 'lib/cli/base_command.rb', line 39
def remove_option(name)
@options.delete(name)
end
|
#target ⇒ String
Also known as:
target_url
Returns Target director URL.
92
93
94
95
96
|
# File 'lib/cli/base_command.rb', line 92
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
115
116
117
|
# File 'lib/cli/base_command.rb', line 115
def target_name
options[:target] || config.target_name || target_url
end
|
#verbose? ⇒ Boolean
78
79
80
|
# File 'lib/cli/base_command.rb', line 78
def verbose?
@options[:verbose]
end
|