Class: Bosh::Cli::Command::PropertyManagement
- Includes:
- DeploymentHelper
- Defined in:
- lib/cli/commands/property_management.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#args, #options, #out, #runner, #work_dir
Instance Method Summary collapse
Methods included from DeploymentHelper
#deployment_changed?, #inspect_deployment_changes, #prepare_deployment_manifest
Methods included from VersionCalc
#major_version, #minor_version, #version_cmp, #version_greater, #version_less, #version_same
Methods inherited from Base
#add_option, #blob_manager, #blobstore, #cache, #config, #confirmed?, #deployment, #director, #exit_code, #initialize, #interactive?, #logged_in?, #non_interactive?, #password, #redirect, #release, #remove_option, #target, #target_name, #task_report, #username, #verbose?
Methods included from Bosh::Cli::CommandDiscovery
#desc, #method_added, #option, #register_command, #usage
Constructor Details
This class inherits a constructor from Bosh::Cli::Command::Base
Instance Method Details
#get(name) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cli/commands/property_management.rb', line 74 def get(name) prepare show_header status, body = director.get_property(@deployment_name, name) if status == 200 say("Property `#{name.green}' value is " + "`#{format_property(body["value"]).green}'") else err(director.(status, body)) end end |
#list ⇒ Object
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 119 120 |
# File 'lib/cli/commands/property_management.rb', line 91 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
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 45 46 |
# File 'lib/cli/commands/property_management.rb', line 10 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.green}' value is " + "`#{format_property(body["value"]).green}'") else say("This will be a new property") end prompt = "Are you sure you want to set property" + " `#{name.green}' to `#{format_property(value).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.green}' set to `#{value.green}'") else err(director.(status, body)) end end |
#unset(name) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cli/commands/property_management.rb', line 51 def unset(name) prepare show_header prompt = "Are you sure you want to unset property " + "`#{name.green}'?" unless confirmed?(prompt) err("Canceled") end status, body = director.delete_property(@deployment_name, name) if status == 204 say("Property `#{name.green}' has been unset") else err(director.(status, body)) end end |