From 19b93455997cd46e4a7ec9b7ecc32a5ac51b91a5 Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Mon, 22 Jan 2024 12:10:33 +0900
Subject: [PATCH] Provide config class interface for rootwrap.conf

This introduces the new neutron::config class parameter to allow users
to inject arbitrary configurations to rootwrap.conf.

Change-Id: If4dade21a7f10f6138c71d275ef84c608289be1a
---
 manifests/config.pp                            |  5 +++++
 ...onfig-rootwrap_config-dc7cc63b57426226.yaml |  4 ++++
 spec/classes/neutron_config_spec.rb            | 18 +++++++++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 releasenotes/notes/config-rootwrap_config-dc7cc63b57426226.yaml

diff --git a/manifests/config.pp b/manifests/config.pp
index 6e2fc0f76..10ff46516 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -27,6 +27,9 @@
 # [*api_paste_ini*]
 #   (optional) Manage configuration of api-paste.ini
 #
+# [*rootwrap_config*]
+#   (optional) Allow configuration of rootwrap.conf configurations.
+#
 # [*ovs_agent_config*]
 #   (optional) Manage configuration of openvswitch_agent.ini
 #
@@ -98,6 +101,7 @@
 class neutron::config (
   Hash $server_config                 = {},
   Hash $api_paste_ini                 = {},
+  Hash $rootwrap_config               = {},
   Hash $ovs_agent_config              = {},
   Hash $ovn_agent_config              = {},
   Hash $sriov_agent_config            = {},
@@ -144,6 +148,7 @@ class neutron::config (
 
   create_resources('neutron_config', $server_config)
   create_resources('neutron_api_paste_ini', $api_paste_ini)
+  create_resources('neutron_rootwrap_config', $rootwrap_config)
   create_resources('neutron_agent_ovs', $ovs_agent_config)
   create_resources('neutron_agent_ovn', $ovn_agent_config)
   create_resources('neutron_sriov_agent_config', $sriov_agent_config)
diff --git a/releasenotes/notes/config-rootwrap_config-dc7cc63b57426226.yaml b/releasenotes/notes/config-rootwrap_config-dc7cc63b57426226.yaml
new file mode 100644
index 000000000..5fc916fe4
--- /dev/null
+++ b/releasenotes/notes/config-rootwrap_config-dc7cc63b57426226.yaml
@@ -0,0 +1,4 @@
+---
+features:
+  - |
+    The new ``neutron::config::rootwrap_config`` parameter has been added.
diff --git a/spec/classes/neutron_config_spec.rb b/spec/classes/neutron_config_spec.rb
index a18573c24..8e2235b9e 100644
--- a/spec/classes/neutron_config_spec.rb
+++ b/spec/classes/neutron_config_spec.rb
@@ -27,13 +27,28 @@ describe 'neutron::config' do
       { :api_paste_ini => config_hash }
     end
 
-    it 'configures arbitrary neutron-api-config configurations' do
+    it 'configures arbitrary neutron-api-paste configurations' do
       should contain_neutron_api_paste_ini('DEFAULT/foo').with_value('fooValue')
       should contain_neutron_api_paste_ini('DEFAULT/bar').with_value('barValue')
       should contain_neutron_api_paste_ini('DEFAULT/baz').with_ensure('absent')
     end
   end
 
+
+  shared_examples 'neutron_rootwrap_config' do
+    let :params do
+      { :rootwrap_config => config_hash }
+    end
+
+    it { should contain_class('neutron::deps') }
+
+    it 'configures arbitrary rootwrap configurations' do
+      should contain_neutron_rootwrap_config('DEFAULT/foo').with_value('fooValue')
+      should contain_neutron_rootwrap_config('DEFAULT/bar').with_value('barValue')
+      should contain_neutron_rootwrap_config('DEFAULT/baz').with_ensure('absent')
+    end
+  end
+
   shared_examples 'neutron_service_config' do
     let :params do
       { :sfc_service_config  => config_hash,
@@ -184,6 +199,7 @@ describe 'neutron::config' do
 
       it_behaves_like 'neutron_config'
       it_behaves_like 'neutron_api_paste_ini'
+      it_behaves_like 'neutron_rootwrap_config'
       it_behaves_like 'neutron_service_config'
       it_behaves_like 'neutron_agent_config'
       it_behaves_like 'neutron_plugin_config'