From 40188356321c3a65bacc32311856569b53d45b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Gagne=CC=81?= Date: Mon, 10 Mar 2014 21:46:17 -0400 Subject: [PATCH] Introduce nova::config Add a new class nova::config which allows the creation and management of arbitrary nova_config and nova_api_paste_ini resources. This will add the ability for the end user to use Hiera to manage those resources. Change-Id: Iad7a2b764884887a75f5f6db3e1660644e07c5c0 Closes-bug: #1290634 --- manifests/config.pp | 25 +++++++++++++++++++++++++ spec/classes/nova_config_spec.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 manifests/config.pp create mode 100644 spec/classes/nova_config_spec.rb diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 000000000..abdad7f66 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,25 @@ +# == Class: nova::config +# +# This class is used to manage arbitrary Nova configurations. +# +# === Parameters +# +# [*nova_config*] +# (optional) Allow configuration of arbitrary Nova configurations. +# The value is an hash of nova_config resources. Example: +# { 'DEFAULT/foo': value => 'fooValue'; 'DEFAULT/bar': value => 'barValue'} +# +# NOTE: The configuration MUST NOT be already handled by this module +# or Puppet catalog compilation will fail with duplicate resources. +# +class nova::config ( + $nova_config = {}, + $nova_paste_api_ini = {}, +) { + + validate_hash($nova_config) + validate_hash($nova_paste_api_ini) + + create_resources('nova_config', $nova_config) + create_resources('nova_paste_api_ini', $nova_paste_api_ini) +} diff --git a/spec/classes/nova_config_spec.rb b/spec/classes/nova_config_spec.rb new file mode 100644 index 000000000..9bfe92a39 --- /dev/null +++ b/spec/classes/nova_config_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'nova::config' do + + let :params do + { :nova_config => { + 'DEFAULT/foo' => { 'value' => 'fooValue' }, + 'DEFAULT/bar' => { 'value' => 'barValue' }, + 'DEFAULT/baz' => { 'ensure' => 'absent' } + }, + :nova_paste_api_ini => { + 'DEFAULT/foo2' => { 'value' => 'fooValue' }, + 'DEFAULT/bar2' => { 'value' => 'barValue' }, + 'DEFAULT/baz2' => { 'ensure' => 'absent' } + } + } + end + + it 'configures arbitrary nova configurations' do + should contain_nova_config('DEFAULT/foo').with_value('fooValue') + should contain_nova_config('DEFAULT/bar').with_value('barValue') + should contain_nova_config('DEFAULT/baz').with_ensure('absent') + end + + it 'configures arbitrary nova api-paste configurations' do + should contain_nova_paste_api_ini('DEFAULT/foo2').with_value('fooValue') + should contain_nova_paste_api_ini('DEFAULT/bar2').with_value('barValue') + should contain_nova_paste_api_ini('DEFAULT/baz2').with_ensure('absent') + end +end