Class: GoldenBrindle::Cluster::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/golden_brindle/actions/cluster.rb

Instance Attribute Summary

Attributes inherited from Base

#done_validating, #original_args, #valid

Instance Method Summary collapse

Methods inherited from Base

#config_keys, #help, #initialize, #load_config, #options

Methods included from Validations

#can_change_user?, #failure, #valid?, #valid_dir?, #valid_exists?, #valid_file?, #valid_group?, #valid_user?

Constructor Details

This class inherits a constructor from GoldenBrindle::Base

Instance Method Details

#configureObject



5
6
7
8
9
10
# File 'lib/golden_brindle/actions/cluster.rb', line 5

def configure
  options [
    ["-c", "--conf_path PATH", "Path to golden_brindle configuration files", :@cwd, "."],
    ["-V", "", "Verbose output", :@verbose, false]
  ]
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/golden_brindle/actions/cluster.rb', line 18

def run
  command = self.class.to_s.downcase.split('::').last
  counter = 0
  errors = 0
  Dir.chdir @cwd do
    Dir.glob("**/*.{yml,conf}").each do |conf|
      cmd = "golden_brindle #{command} -C #{File.join(@cwd,conf)}"
      cmd += " -d" if command == "start" #daemonize only when start
      puts cmd if @verbose
      output = `#{cmd}`
      puts output if @verbose
      status = $?.success?
      puts "golden_brindle #{command} returned an error." unless status
      status ? counter += 1 : errors += 1
    end
  end
  puts "Success:#{counter}; Errors: #{errors}"
end

#validateObject



12
13
14
15
16
# File 'lib/golden_brindle/actions/cluster.rb', line 12

def validate
  @cwd = File.expand_path(@cwd)
  valid_dir? @cwd, "Invalid path to golden_brindle configuration files: #{@cwd}"
  @valid
end