From 27b28f38263ded85c9795e0d6c3b82018007822b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 15 Nov 2021 14:22:38 +0900 Subject: [PATCH] Add support for [octavia_client] parameters Change-Id: Id34a8b2a34f17c32a6d0f11537e0c6e1bac5ee88 --- manifests/clients.pp | 1 + manifests/clients/octavia.pp | 53 +++++++++++++++++ .../octavia_client-ae19dc0bde7981ac.yaml | 4 ++ spec/classes/magnum_clients_octavia_spec.rb | 57 +++++++++++++++++++ spec/classes/magnum_clients_spec.rb | 1 + 5 files changed, 116 insertions(+) create mode 100644 manifests/clients/octavia.pp create mode 100644 releasenotes/notes/octavia_client-ae19dc0bde7981ac.yaml create mode 100644 spec/classes/magnum_clients_octavia_spec.rb diff --git a/manifests/clients.pp b/manifests/clients.pp index 1942f8a..b5d20f7 100644 --- a/manifests/clients.pp +++ b/manifests/clients.pp @@ -47,4 +47,5 @@ class magnum::clients ( include magnum::clients::magnum include magnum::clients::neutron include magnum::clients::nova + include magnum::clients::octavia } diff --git a/manifests/clients/octavia.pp b/manifests/clients/octavia.pp new file mode 100644 index 0000000..a175d1a --- /dev/null +++ b/manifests/clients/octavia.pp @@ -0,0 +1,53 @@ +# == Class: magnum::clients::octavia +# +# Manages octavia clients configuration in magnum server +# +# === Parameters: +# +# [*region_name*] +# (optional) Region in Identity service catalog to use for communication +# with the OpenStack service. +# Defaults to RegionOne +# +# [*endpoint_type*] +# (optional) Type of endpoint in Identity service catalog to use for +# communication with the OpenStack service. +# Defaults to publicURL +# +# [*ca_file*] +# (optional) CA cert file to use in SSL connections. +# Defaults to $::os_service_default +# +# [*cert_file*] +# (optional) PEM-formatted certificate chain file. +# Defaults to $::os_service_default +# +# [*key_file*] +# (optional) PEM-formatted file that contains the private key. +# Defaults to $::os_service_default +# +# [*insecure*] +# (optional) If set, then the server's certificate will not be verified. +# Defaults to false +# +class magnum::clients::octavia( + $region_name = $magnum::clients::region_name, + $endpoint_type = $magnum::clients::endpoint_type, + $ca_file = $magnum::clients::ca_file, + $cert_file = $magnum::clients::cert_file, + $key_file = $magnum::clients::key_file, + $insecure = $magnum::clients::insecure, +){ + + include magnum::deps + include magnum::params + + magnum_config { + 'octavia_client/region_name': value => $region_name; + 'octavia_client/endpoint_type': value => $endpoint_type; + 'octavia_client/ca_file': value => $ca_file; + 'octavia_client/cert_file': value => $cert_file; + 'octavia_client/key_file': value => $key_file; + 'octavia_client/insecure': value => $insecure; + } +} diff --git a/releasenotes/notes/octavia_client-ae19dc0bde7981ac.yaml b/releasenotes/notes/octavia_client-ae19dc0bde7981ac.yaml new file mode 100644 index 0000000..cc99465 --- /dev/null +++ b/releasenotes/notes/octavia_client-ae19dc0bde7981ac.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + The new ``magnum::clients::octavia`` class has been added. diff --git a/spec/classes/magnum_clients_octavia_spec.rb b/spec/classes/magnum_clients_octavia_spec.rb new file mode 100644 index 0000000..a016f73 --- /dev/null +++ b/spec/classes/magnum_clients_octavia_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'magnum::clients::octavia' do + + shared_examples 'magnum::clients::octavia' do + + context 'with default parameters' do + let :params do + { :region_name => 'RegionOne', + :endpoint_type => 'publicURL', + :ca_file => '', + :cert_file => '', + :key_file => '', + :insecure => false, + } + end + + it { is_expected.to contain_magnum_config('octavia_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('octavia_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('octavia_client/ca_file').with_value('') } + it { is_expected.to contain_magnum_config('octavia_client/cert_file').with_value('') } + it { is_expected.to contain_magnum_config('octavia_client/key_file').with_value('') } + it { is_expected.to contain_magnum_config('octavia_client/insecure').with_value(false) } + end + + context 'with specific parameters' do + let :params do + { :region_name => 'RegionTwo', + :endpoint_type => 'adminURL', + :ca_file => '/etc/magnum/certs/ca.pem', + :cert_file => '/etc/magnum/certs/cert.pem', + :key_file => '/etc/magnum/certs/pri.key', + :insecure => true, + } + end + + it { is_expected.to contain_magnum_config('octavia_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('octavia_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('octavia_client/ca_file').with_value('/etc/magnum/certs/ca.pem') } + it { is_expected.to contain_magnum_config('octavia_client/cert_file').with_value('/etc/magnum/certs/cert.pem') } + it { is_expected.to contain_magnum_config('octavia_client/key_file').with_value('/etc/magnum/certs/pri.key') } + it { is_expected.to contain_magnum_config('octavia_client/insecure').with_value(true) } + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_configures 'magnum::clients::octavia' + end + end +end diff --git a/spec/classes/magnum_clients_spec.rb b/spec/classes/magnum_clients_spec.rb index edc0ae5..d09c1d2 100644 --- a/spec/classes/magnum_clients_spec.rb +++ b/spec/classes/magnum_clients_spec.rb @@ -14,6 +14,7 @@ describe 'magnum::clients' do is_expected.to contain_class('magnum::clients::nova') is_expected.to contain_class('magnum::clients::magnum') is_expected.to contain_class('magnum::clients::neutron') + is_expected.to contain_class('magnum::clients::octavia') end end