Module: Bellows::Util
- Defined in:
- lib/bellows/util.rb
Constant Summary collapse
- CORE_PROJECTS =
['openstack/nova', 'openstack/glance', 'openstack/keystone', 'openstack/swift', 'openstack/cinder', 'openstack/neutron', 'openstack/ceilometer', 'openstack/heat']
- PUPPET_PROJECTS =
['stackforge/puppet-nova', 'stackforge/puppet-glance', 'stackforge/puppet-keystone', 'stackforge/puppet-swift', 'stackforge/puppet-cinder', 'stackforge/puppet-neutron', 'stackforge/puppet-ceilometer', 'stackforge/puppet-heat']
- ALL_PROJECTS =
CORE_PROJECTS + PUPPET_PROJECTS
- @@configs =
nil
Class Method Summary collapse
- .load_configs ⇒ Object
-
.projects(project = nil) ⇒ Object
If a single project is provided return an array of that.
- .raise_if_nil_or_empty(options, key) ⇒ Object
- .short_spec(refspec) ⇒ Object
- .test_configs(project = nil) ⇒ Object
- .validate_project(project) ⇒ Object
Class Method Details
.load_configs ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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) ⇒ Object
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.
67 68 69 70 71 72 73 74 75 76 77 78 |
# 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) ⇒ Object
42 43 44 45 46 |
# File 'lib/bellows/util.rb', line 42 def self.raise_if_nil_or_empty(, key) if not or [key].nil? or [key].empty? then raise "Please specify a valid #{key.to_s} parameter." end end |
.short_spec(refspec) ⇒ Object
48 49 50 |
# File 'lib/bellows/util.rb', line 48 def self.short_spec(refspec) refspec.sub(/\/[^\/]*$/, "") end |
.test_configs(project = nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# 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) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# 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 |