summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilyin <dilyin@mirantis.com>2016-07-14 13:35:34 -0500
committerDmitry Ilyin <dilyin@mirantis.com>2016-07-18 11:41:36 -0500
commitd8c88d2d9d84585d8d4bd510e9d4ed84d716aa62 (patch)
tree9228c22ba7cdf9d3ffe3294e4c8c91803cb39663
parent9c48a9799e4094f69e115746d7e880dc1b6ca5db (diff)
Add plugin hiera files support
* Put plugun files to hiera/plugins/$yaml_name/ Change-Id: I21389dcb9bf065a3a6f09753e423fdf942afb767
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+2: Dmitry Ilyin <dilyin@mirantis.com> Workflow+1: Dmitry Ilyin <dilyin@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 18 Jul 2016 17:59:48 +0000 Reviewed-on: https://review.openstack.org/342353 Project: openstack/fuel-noop-fixtures Branch: refs/heads/master
-rw-r--r--doc/usage.rst12
-rw-r--r--hiera/plugins/master/.gitkeep0
-rw-r--r--lib/noop/config/hiera.rb10
-rw-r--r--lib/noop/manager/library.rb23
-rw-r--r--lib/noop/task/hiera.rb24
5 files changed, 67 insertions, 2 deletions
diff --git a/doc/usage.rst b/doc/usage.rst
index 76a6d31..c76d3d7 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -217,6 +217,18 @@ the override file name *firewall-firewall.yaml* and
217*openstack-controller-keystone.yaml* if these files are found in the 217*openstack-controller-keystone.yaml* if these files are found in the
218override folders. 218override folders.
219 219
220Using hiera plugin overrides
221----------------------------
222
223If you have several additional YAML files that should be applied on top of
224the base Hiera files, for example, files, provided or generated by plugins
225or the other tasks, you can use the plugin override system. Any files which
226have been placed to the *hiera/plugins/${yaml_base_name}/* folder will be
227applied on top of this YAML file when it will be used in the Noop tests.
228
229Multiple files inside this directory will be ordered alphabetically with
230the former letters having the higher priority.
231
220Working with report files 232Working with report files
221------------------------- 233-------------------------
222 234
diff --git a/hiera/plugins/master/.gitkeep b/hiera/plugins/master/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hiera/plugins/master/.gitkeep
diff --git a/lib/noop/config/hiera.rb b/lib/noop/config/hiera.rb
index ddc5ee3..217a7f4 100644
--- a/lib/noop/config/hiera.rb
+++ b/lib/noop/config/hiera.rb
@@ -32,5 +32,15 @@ module Noop
32 def self.default_hiera_file_name 32 def self.default_hiera_file_name
33 Pathname.new 'novanet-primary-controller.yaml' 33 Pathname.new 'novanet-primary-controller.yaml'
34 end 34 end
35
36 # @return [Pathname]
37 def self.file_name_hiera_plugins
38 Pathname.new 'plugins'
39 end
40
41 # @return [Pathname]
42 def self.file_path_hiera_plugins
43 Noop::Config.dir_path_hiera + file_name_hiera_plugins
44 end
35 end 45 end
36end 46end
diff --git a/lib/noop/manager/library.rb b/lib/noop/manager/library.rb
index e88f92f..3c3dafe 100644
--- a/lib/noop/manager/library.rb
+++ b/lib/noop/manager/library.rb
@@ -46,7 +46,7 @@ module Noop
46 def hiera_file_names 46 def hiera_file_names
47 return @hiera_file_names if @hiera_file_names 47 return @hiera_file_names if @hiera_file_names
48 error "No #{Noop::Config.dir_path_hiera} directory!" unless Noop::Config.dir_path_hiera.directory? 48 error "No #{Noop::Config.dir_path_hiera} directory!" unless Noop::Config.dir_path_hiera.directory?
49 exclude = [ Noop::Config.dir_name_hiera_override, Noop::Config.dir_name_globals ] 49 exclude = [ Noop::Config.dir_name_hiera_override, Noop::Config.dir_name_globals, Noop::Config.file_name_hiera_plugins ]
50 @hiera_file_names = find_files(Noop::Config.dir_path_hiera, Noop::Config.dir_path_hiera, exclude) do |file| 50 @hiera_file_names = find_files(Noop::Config.dir_path_hiera, Noop::Config.dir_path_hiera, exclude) do |file|
51 file.to_s.end_with? '.yaml' 51 file.to_s.end_with? '.yaml'
52 end 52 end
@@ -393,6 +393,27 @@ module Noop
393 @task_list 393 @task_list
394 end 394 end
395 395
396 # Collect all hiera plugins into a data structure.
397 # Used only for debugging purposes.
398 # @return [Hash<String => Pathname>]
399 def hiera_plugins
400 return @hiera_plugins if @hiera_plugins
401 @hiera_plugins = {}
402 return @hiera_plugins unless Noop::Config.file_path_hiera_plugins.directory?
403 Noop::Config.file_path_hiera_plugins.children.each do |hiera|
404 next unless hiera.directory?
405 hiera_name = hiera.basename.to_s
406 hiera.children.each do |file|
407 next unless file.file?
408 next unless file.to_s.end_with? '.yaml'
409 file = file.relative_path_from Noop::Config.dir_path_hiera
410 @hiera_plugins[hiera_name] = [] unless @hiera_plugins[hiera_name]
411 @hiera_plugins[hiera_name] << file
412 end
413 end
414 @hiera_plugins
415 end
416
396 # Loop through all task files and find those that 417 # Loop through all task files and find those that
397 # do not have a corresponding spec file present 418 # do not have a corresponding spec file present
398 # @return [Array<Pathname>] 419 # @return [Array<Pathname>]
diff --git a/lib/noop/task/hiera.rb b/lib/noop/task/hiera.rb
index dd9efc7..8f94a20 100644
--- a/lib/noop/task/hiera.rb
+++ b/lib/noop/task/hiera.rb
@@ -60,6 +60,27 @@ module Noop
60 Noop::Config.dir_name_hiera_override + override_file.sub_ext('') 60 Noop::Config.dir_name_hiera_override + override_file.sub_ext('')
61 end 61 end
62 62
63 # @return [Pathname]
64 def dir_path_task_hiera_plugins
65 Noop::Config.file_path_hiera_plugins + file_base_hiera
66 end
67
68 # @return [Array<Pathname>]
69 def list_hiera_plugins
70 return @list_hiera_plugins if @list_hiera_plugins
71 @list_hiera_plugins = [] unless @list_hiera_plugins
72 return @list_hiera_plugins unless dir_path_task_hiera_plugins.directory?
73 dir_path_task_hiera_plugins.children.each do |file|
74 next unless file.file?
75 next unless file.to_s.end_with? '.yaml'
76 file = file.relative_path_from Noop::Config.dir_path_hiera
77 file = file.sub_ext('')
78 @list_hiera_plugins << file
79 end
80 @list_hiera_plugins.sort!
81 @list_hiera_plugins
82 end
83
63 # @return [String] 84 # @return [String]
64 def hiera_logger 85 def hiera_logger
65 if ENV['SPEC_PUPPET_DEBUG'] 86 if ENV['SPEC_PUPPET_DEBUG']
@@ -72,9 +93,10 @@ module Noop
72 # @return [Array<String>] 93 # @return [Array<String>]
73 def hiera_hierarchy 94 def hiera_hierarchy
74 elements = [] 95 elements = []
96 elements += list_hiera_plugins.map(&:to_s) if list_hiera_plugins.any?
75 elements << element_hiera_override.to_s if file_present_hiera_override? 97 elements << element_hiera_override.to_s if file_present_hiera_override?
76 elements << element_hiera.to_s if file_present_hiera?
77 elements << element_globals.to_s if file_present_globals? 98 elements << element_globals.to_s if file_present_globals?
99 elements << element_hiera.to_s if file_present_hiera?
78 elements 100 elements
79 end 101 end
80 102