Class: Bosh::Cli::Command::PropertyManagement
- Defined in:
- lib/cli/commands/property_management.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#args, #exit_code, #info, #options, #out, #runner, #work_dir
Instance Method Summary collapse
Methods inherited from Base
#add_option, #blob_manager, #blobstore, #cache_dir, #config, #confirmed?, #credentials, #deployment, #director, #initialize, #interactive?, #logged_in?, #non_interactive?, #progress_renderer, #redirect, #release, #remove_option, #run_nested_command, #show_current_state, #target, #target_name, #verbose?
Methods included from Bosh::Cli::CommandDiscovery
#desc, #method_added, #option, #register_command, #usage
Methods included from DeploymentHelper
#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
This class inherits a constructor from Bosh::Cli::Command::Base
Instance Method Details
#get(name) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cli/commands/property_management.rb', line 72 def get(name) prepare show_header status, body = director.get_property(@deployment_name, name) if status == 200 say("Property '#{name.make_green}' value is " + "'#{format_property(body["value"]).make_green}'") else err(director.(status, body)) end end |
#list ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cli/commands/property_management.rb', line 89 def list prepare terse = [:terse] show_header unless terse properties = director.list_properties(@deployment_name) unless properties.kind_of?(Enumerable) err("Invalid properties format, please check your director") end output = properties.sort do |p1, p2| p1["name"] <=> p2["name"] end.map do |property| [property["name"], format_property(property["value"])] end if terse output.each { |row| say("#{row[0]}\t#{row[1]}") } else if output.size > 0 properties_table = table do |t| t.headings = %w(Name Value) output.each { |row| t << [row[0], row[1].truncate(40)] } end say(properties_table) else say("No properties found") end end end |
#set(name, value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cli/commands/property_management.rb', line 8 def set(name, value) prepare show_header begin status, body = director.get_property(@deployment_name, name) existing_property = status == 200 rescue Bosh::Cli::DirectorError existing_property = false end if existing_property say("Current '#{name.make_green}' value is " + "'#{format_property(body["value"]).make_green}'") else say("This will be a new property") end prompt = "Are you sure you want to set property" + " '#{name.make_green}' to '#{format_property(value).make_green}'?" unless confirmed?(prompt) err("Canceled") end if existing_property status, body = director.update_property(@deployment_name, name, value) else status, body = director.create_property(@deployment_name, name, value) end if status == 204 say("Property '#{name.make_green}' set to '#{value.make_green}'") else err(director.(status, body)) end end |
#unset(name) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cli/commands/property_management.rb', line 49 def unset(name) prepare show_header prompt = "Are you sure you want to unset property " + "'#{name.make_green}'?" unless confirmed?(prompt) err("Canceled") end status, body = director.delete_property(@deployment_name, name) if status == 204 say("Property '#{name.make_green}' has been unset") else err(director.(status, body)) end end |