class Beaker::DSL::PEClientTools::ConfigFileHelper::Private

Public Class Methods

config_path(host, config_level) click to toggle source
# File lib/beaker-pe/pe-client-tools/config_file_helper.rb, line 43
def self.config_path(host, config_level)

  puppetlabs_dir = 'puppetlabs'
  puppetlabs_dir.prepend('.') if config_level == 'user'
  client_tools_path_array = [puppetlabs_dir, 'client-tools']

  case config_level

    when /global/
      @base_path = global_base_path(host)
    when /user/
      @base_path = home_dir(host)
    else
      raise ArgumentError.new("Unknown config level #{config_level}")
  end

  client_tools_dir = client_tools_path_array.unshift(@base_path).join(path_separator(host))
  opts = {:cmdexe => true}

  if host.platform =~ /win/
    host.exec(Beaker::Command.new('MD', [client_tools_dir.gsub('\\', '\\\\\\')], opts), :accept_all_exit_codes => true)
  else
    host.exec(Beaker::Command.new("mkdir -p #{client_tools_dir}", [], opts), :accept_all_exit_codes => true)
  end
  client_tools_dir
end
file_name(tool) click to toggle source
# File lib/beaker-pe/pe-client-tools/config_file_helper.rb, line 29
def self.file_name(tool)
  if tool =~ /orchestrator|job|app/i
    'orchestrator.conf'
  elsif tool =~ /code/i
    'puppet-code.conf'
  elsif tool =~ /access/i
    'puppet-access.conf'
  elsif tool =~ /db|query/i
    'puppetdb.conf'
  else
    raise ArgumentError.new("Unknown pe-client-tool type '#{tool}'")
  end
end
global_base_path(host) click to toggle source
# File lib/beaker-pe/pe-client-tools/config_file_helper.rb, line 80
def self.global_base_path(host)

  (host.platform =~ /win/) ?host.exec(Beaker::Command.new('echo', ['%PROGRAMDATA%'], :cmdexe => true)).stdout.chomp : '/etc//'
end
home_dir(host) click to toggle source
# File lib/beaker-pe/pe-client-tools/config_file_helper.rb, line 70
def self.home_dir(host)

  if (host.platform =~ /win/) then
    @cmd = Beaker::Command.new('echo', ['%userprofile%'], :cmdexe => true)
  else
    @cmd = Beaker::Command.new('echo', ['$HOME'])
  end
  host.exec(@cmd).stdout.chomp
end
path_separator(host) click to toggle source
# File lib/beaker-pe/pe-client-tools/config_file_helper.rb, line 85
def self.path_separator(host)

  (host.platform =~ /win/) ? '\\' : '/'
end