Class: Exec::ServiceConfLs
- Inherits:
-
ExecutableCommand
- Object
- ExecutableCommand
- Exec::ServiceConfLs
- Defined in:
- lib/exec/service_conf_ls.rb
Overview
Allows the user to display a configuration about cluster.
Instance Attribute Summary
Attributes inherited from ExecutableCommand
#argv, #command_name, #logger, #options, #stderr, #stdin, #stdout, #values
Instance Method Summary collapse
-
#display_configurations(cluster_name = @values["cluster"], prefix = '') ⇒ Object
private
display the configurations of a cluster.
-
#exec ⇒ Object
The execution of the command.
-
#set_options ⇒ Object
private
Parse and check the parameters of the function.
Methods inherited from ExecutableCommand
#check_parameters, #create_logger, #initialize, #run
Constructor Details
This class inherits a constructor from Exec::ExecutableCommand
Instance Method Details
#display_configurations(cluster_name = @values["cluster"], prefix = '') ⇒ Object (private)
display the configurations of a cluster.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/exec/service_conf_ls.rb', line 51 def display_configurations(cluster_name = @values["cluster"], prefix = '') @logger.begin_main_step("listConfigurations") begin configs = Array.new output = Array.new command = Command::.new(cluster_name) data = command.exec() return "No configurations available on the cluster '#{cluster_name}'.\n" if data.nil? || data.empty? error = false data.each{|conf| if !conf['active'].nil? if conf['active'] active = Color::color_green("[Active]") configs << "#{prefix}#{conf['type']} : #{conf['tag']} #{active}\n" else configs << "#{prefix}#{conf['type']} : #{conf['tag']} [Not Active]\n" end else error = true end } rescue => e raise e end @logger.debug("configuration list output: #{output}") @logger.end_main_step("listConfigurations") if error output << "" output << "Error: Retrieve the configuration on the cluster '#{cluster_name}'." output << "\n" else configs = configs.sort output << "" output << "Configurations available on the cluster '#{cluster_name}' :" output << "\n\n" output << "#{prefix}[TYPE : TAG] [Status]\n" configs.each{|conf| output << conf } output << "\n" end return output end |
#exec ⇒ Object
The execution of the command.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/exec/service_conf_ls.rb', line 31 def exec Color::print_log("NONE", "Display a configuration about the cluster '#{@values["cluster"]}'", @stdout) if !@values["cluster"].nil? output = display_configurations(@values["cluster"], "\t - ") end Color::echo_ok(@stdout) output.each{|conf| @stdout.print conf } end |
#set_options ⇒ Object (private)
Parse and check the parameters of the function.
23 24 25 26 |
# File 'lib/exec/service_conf_ls.rb', line 23 def @logger.info("setting options") .add_option("C", "cluster", "The cluster name.", true, true, method(:check_cluster_name)) end |