Class: Proctor::Command::FileCleanupCmd
- Inherits:
-
Object
- Object
- Proctor::Command::FileCleanupCmd
- Includes:
- Helpers::Command, Resource::Erb, Resource::Lookup
- Defined in:
- lib/proctor/command/file_cleanup_cmd.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(global, options, args) ⇒ FileCleanupCmd
constructor
A new instance of FileCleanupCmd.
Methods included from Resource::Lookup
#lookup_valid_group_template, #lookup_valid_manager, #lookup_valid_node, #lookup_valid_service, #lookup_valid_service_template, #lookup_valid_services, #lookup_valid_services_hash
Methods included from Resource::Erb
#erb_ify, #erb_ify_hash, #erb_ify_services, #generate_group_erb, #generate_group_header, #generate_service_erb, #generate_service_header, #render_group_template, #render_service_template
Methods included from Helpers::Command
#check_number_of_args, #options_msg
Constructor Details
#initialize(global, options, args) ⇒ FileCleanupCmd
Returns a new instance of FileCleanupCmd.
13 14 15 16 17 18 19 |
# File 'lib/proctor/command/file_cleanup_cmd.rb', line 13 def initialize(global, , args) @env = ['env'] @manager = args[0] @node = args[1] opts = {'MANAGERS' => @env.managers.names, 'NODES' => @env.nodes.names} check_number_of_args(args, 2, 'cleanup MANAGER NODE', opts) end |
Instance Method Details
#cleanup ⇒ Object
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/proctor/command/file_cleanup_cmd.rb', line 21 def cleanup manager = lookup_valid_manager(@manager, @env) #update_manager_with_cl_options(manager) use_node = manager.data["use_node_template"] # default = false use_service = manager.data["use_service_template"] use_service = true if use_service.nil? node = lookup_valid_node(@node, @env) env = @env manager.data.each_pair do |k,v| manager.data[k] = ERB.new(v).result(binding) if v.class == String end if use_node services = lookup_valid_services_hash(node.name, @env) template = lookup_valid_group_template(manager.name, node.name, @env) remove_node_text_from_disk(manager, node, @env) end if use_service node.services.each do |service_name| service = lookup_valid_service(service_name, @env) template = lookup_valid_service_template(manager.name, service.name, @env) remove_service_text_from_disk(manager, service, @env) end end end |