Class: Bosh::Cli::Command::Base
Direct Known Subclasses
Backup, Biff, BlobManagement, CloudCheck, CloudConfig, Complete, Deployment, DeploymentDiff, Disks, Errand, Events, Help, Ignore, Instances, Job, JobManagement, 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, Restore, RuntimeConfig, 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
#build_manifest, #cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_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
22
|
# 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 = []
@info = {}
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 info.
7
8
9
|
# File 'lib/cli/base_command.rb', line 7
def info
@info
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
34
35
36
|
# File 'lib/cli/base_command.rb', line 34
def add_option(name, value)
@options[name] = value
end
|
#blob_manager ⇒ Object
63
64
65
|
# File 'lib/cli/base_command.rb', line 63
def blob_manager
@blob_manager ||= Bosh::Cli::BlobManager.new(release, config.max_parallel_downloads, progress_renderer)
end
|
#blobstore ⇒ Object
67
68
69
|
# File 'lib/cli/base_command.rb', line 67
def blobstore
release.blobstore
end
|
#cache_dir ⇒ Object
131
132
133
|
# File 'lib/cli/base_command.rb', line 131
def cache_dir
File.join(Dir.home, '.bosh', 'cache')
end
|
Returns Current configuration.
25
26
27
28
29
30
31
32
|
# File 'lib/cli/base_command.rb', line 25
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
95
96
97
98
|
# File 'lib/cli/base_command.rb', line 95
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.
110
111
112
|
# File 'lib/cli/base_command.rb', line 110
def deployment
options[:deployment] || config.deployment
end
|
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cli/base_command.rb', line 42
def director
return @director if @director
director_client_options = [:no_track, :ca_cert]
@director = Bosh::Cli::Client::Director.new(
target,
credentials,
@options.select { |k, _| director_client_options.include?(k) }
)
end
|
#interactive? ⇒ Boolean
79
80
81
|
# File 'lib/cli/base_command.rb', line 79
def interactive?
!non_interactive?
end
|
#logged_in? ⇒ Boolean
71
72
73
|
# File 'lib/cli/base_command.rb', line 71
def logged_in?
!!(credentials && credentials.)
end
|
#non_interactive? ⇒ Boolean
75
76
77
|
# File 'lib/cli/base_command.rb', line 75
def non_interactive?
options[:non_interactive]
end
|
#redirect(*args) ⇒ Object
87
88
89
|
# File 'lib/cli/base_command.rb', line 87
def redirect(*args)
Bosh::Cli::Runner.new(args, @options).run
end
|
53
54
55
56
57
|
# File 'lib/cli/base_command.rb', line 53
def release
return @release if @release
check_if_release_dir
@release = Bosh::Cli::Release.new(release_directory, options[:final])
end
|
#remove_option(name) ⇒ Object
38
39
40
|
# File 'lib/cli/base_command.rb', line 38
def remove_option(name)
@options.delete(name)
end
|
#run_nested_command(*args) ⇒ Object
91
92
93
|
# File 'lib/cli/base_command.rb', line 91
def run_nested_command(*args)
Bosh::Cli::Runner.new(args, @options).run(false)
end
|
#show_current_state(deployment_name = nil) ⇒ Object
135
136
137
138
139
140
141
|
# File 'lib/cli/base_command.rb', line 135
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.
101
102
103
104
105
|
# File 'lib/cli/base_command.rb', line 101
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
127
128
129
|
# File 'lib/cli/base_command.rb', line 127
def target_name
options[:target] || config.target_name || target_url
end
|
#verbose? ⇒ Boolean
83
84
85
|
# File 'lib/cli/base_command.rb', line 83
def verbose?
@options[:verbose]
end
|