module Bellows::Util
Constants
- ALL_PROJECTS
- CORE_PROJECTS
- PUPPET_PROJECTS
Public Class Methods
load_configs()
click to toggle source
# File lib/bellows/util.rb, line 14 def self.load_configs return @@configs if not @@configs.nil? config_file=ENV['BELLOWS_CONFIG_FILE'] if config_file.nil? then config_file=ENV['HOME']+File::SEPARATOR+".bellows.conf" if not File.exists?(config_file) then config_file="/etc/bellows.conf" end end if File.exists?(config_file) then configs = YAML.load_file(config_file) || {} raise_if_nil_or_empty(configs, "smokestack_url") raise_if_nil_or_empty(configs, "smokestack_username") raise_if_nil_or_empty(configs, "smokestack_password") @@configs=configs else raise "Failed to load bellows config file. Please configure /etc/bellows.conf or create a .bellows.conf config file in your HOME directory." end @@configs end
projects(project=nil)
click to toggle source
If a single project is provided return an array of that. Otherwise return the default projects from the config file or the default project list.
# File lib/bellows/util.rb, line 67 def self.projects(project=nil) if not project.nil? validate_project(project) return [project] end configs=self.load_configs proj_list = configs['projects'] if proj_list.nil? or proj_list.empty? then proj_list = CORE_PROJECTS + PUPPET_PROJECTS end return proj_list end
raise_if_nil_or_empty(options, key)
click to toggle source
# File lib/bellows/util.rb, line 42 def self.raise_if_nil_or_empty(options, key) if not options or options[key].nil? or options[key].empty? then raise "Please specify a valid #{key.to_s} parameter." end end
short_spec(refspec)
click to toggle source
# File lib/bellows/util.rb, line 48 def self.short_spec(refspec) refspec.sub(/\/[^\/]*$/, "") end
test_configs(project=nil)
click to toggle source
# File lib/bellows/util.rb, line 80 def self.test_configs(project=nil) configs=load_configs test_suite_ids = nil config_template_ids = nil # per project configs may be specified in the config file if not project.nil? and configs[project] then if configs[project]['test_suite_ids'] then test_suite_ids = configs[project]['test_suite_ids'].collect {|x| x.to_s } end if configs[project]['config_template_ids'] then config_template_ids = configs[project]['config_template_ids'].collect {|x| x.to_s } end end # if no configs specified use the configured defaults if test_suite_ids.nil? then test_suite_ids = configs['test_suite_ids'].collect {|x| x.to_s } end if config_template_ids.nil? then config_template_ids = configs['config_template_ids'].collect {|x| x.to_s } end return test_suite_ids, config_template_ids end
validate_project(project)
click to toggle source
# File lib/bellows/util.rb, line 52 def self.validate_project(project) configs=self.load_configs projects = configs['projects'] if projects.nil? or projects.empty? then projects = CORE_PROJECTS + PUPPET_PROJECTS end if not projects.include?(project) then puts "ERROR: Please specify a valid project name." exit 1 end end