From 0959e03f96a2af8e82b666efd4d3f646cd40ba3f Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Thu, 4 Apr 2024 12:00:06 +0900
Subject: [PATCH] Add support for [network] network_isolation

Change-Id: Ifdd4aad61df32ab4baba55eebaa9cf42567968c4
---
 manifests/init.pp                                          | 6 ++++++
 releasenotes/notes/network_isolation-d7b0f489fb53d578.yaml | 4 ++++
 spec/classes/trove_init_spec.rb                            | 3 +++
 3 files changed, 13 insertions(+)
 create mode 100644 releasenotes/notes/network_isolation-d7b0f489fb53d578.yaml

diff --git a/manifests/init.pp b/manifests/init.pp
index a9e50513..0ad0cb44 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -276,6 +276,10 @@
 #   (optional) The network that trove will attach by default.
 #   Defaults to $facts['os_service_default'].
 #
+# [*network_isolation*]
+#   (optional) Whether to plug user defined port to database container.
+#   Defaults to $facts['os_service_default'].
+#
 # [*trove_volume_support*]
 #   (optional) Whether to provision a Cinder volume for datadir.
 #   Defaults to $facts['os_service_default'].
@@ -350,6 +354,7 @@ class trove(
   $trove_endpoint_type                = $facts['os_service_default'],
   $neutron_endpoint_type              = $facts['os_service_default'],
   $management_networks                = $facts['os_service_default'],
+  $network_isolation                  = $facts['os_service_default'],
   $trove_volume_support               = $facts['os_service_default'],
   $volume_rootdisk_support            = $facts['os_service_default'],
   $volume_rootdisk_size               = $facts['os_service_default'],
@@ -414,6 +419,7 @@ class trove(
     'DEFAULT/network_label_regex': value => '.*';
     'DEFAULT/network_driver':      value => 'trove.network.neutron.NeutronDriver';
     'DEFAULT/management_networks': value => join(any2array($management_networks), ',');
+    'network/network_isolation':   value => $network_isolation;
   }
 
   # volume
diff --git a/releasenotes/notes/network_isolation-d7b0f489fb53d578.yaml b/releasenotes/notes/network_isolation-d7b0f489fb53d578.yaml
new file mode 100644
index 00000000..9b667dee
--- /dev/null
+++ b/releasenotes/notes/network_isolation-d7b0f489fb53d578.yaml
@@ -0,0 +1,4 @@
+---
+features:
+  - |
+    The new ``trove::network_isolation`` parameter has been added.
diff --git a/spec/classes/trove_init_spec.rb b/spec/classes/trove_init_spec.rb
index 1fd08c58..8dcd16e3 100644
--- a/spec/classes/trove_init_spec.rb
+++ b/spec/classes/trove_init_spec.rb
@@ -44,6 +44,7 @@ describe 'trove' do
         is_expected.to contain_trove_config('DEFAULT/neutron_endpoint_type').with_value('<SERVICE DEFAULT>')
         is_expected.to contain_trove_config('DEFAULT/glance_endpoint_type').with_value('<SERVICE DEFAULT>')
         is_expected.to contain_trove_config('DEFAULT/management_networks').with_value('<SERVICE DEFAULT>')
+        is_expected.to contain_trove_config('network/network_isolation').with_value('<SERVICE DEFAULT>')
         is_expected.to contain_trove_config('DEFAULT/trove_volume_support').with_value('<SERVICE DEFAULT>')
         is_expected.to contain_trove_config('DEFAULT/volume_rootdisk_support').with_value('<SERVICE DEFAULT>')
         is_expected.to contain_trove_config('DEFAULT/volume_rootdisk_size').with_value('<SERVICE DEFAULT>')
@@ -124,6 +125,7 @@ describe 'trove' do
           :swift_service_type        => 'object-store',
           :neutron_service_type      => 'network',
           :glance_service_type       => 'image',
+          :network_isolation         => true,
           :trove_volume_support      => true,
           :volume_rootdisk_support   => true,
           :volume_rootdisk_size      => 10,
@@ -141,6 +143,7 @@ describe 'trove' do
         is_expected.to contain_trove_config('DEFAULT/swift_service_type').with_value('object-store')
         is_expected.to contain_trove_config('DEFAULT/neutron_service_type').with_value('network')
         is_expected.to contain_trove_config('DEFAULT/glance_service_type').with_value('image')
+        is_expected.to contain_trove_config('network/network_isolation').with_value(true)
         is_expected.to contain_trove_config('DEFAULT/trove_volume_support').with_value(true)
         is_expected.to contain_trove_config('DEFAULT/volume_rootdisk_support').with_value(true)
         is_expected.to contain_trove_config('DEFAULT/volume_rootdisk_size').with_value(10)