From 7ddad2622413ef11424eb1e4e9e52fe09cdce4b2 Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Tue, 19 Mar 2019 09:46:41 -0230 Subject: [PATCH] Convert provider drivers to a json string for config file Setting octavia's provider_driver to a puppet hash results in a invalid config. This patch converts the has to a json string instead. Change-Id: If182949664f041bbfa44b62c55ce06fb5bd63e12 --- manifests/api.pp | 12 +++++++----- spec/classes/octavia_api_spec.rb | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index c51c202a..d81d06ee 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -84,10 +84,6 @@ class octavia::api ( include ::octavia::policy include ::octavia::db - if !is_service_default($provider_drivers) { - validate_hash($provider_drivers) - } - if $auth_strategy == 'keystone' { include ::octavia::keystone::authtoken } @@ -131,6 +127,12 @@ class octavia::api ( include ::octavia::db::sync } + if !is_service_default($provider_drivers) { + $provider_drivers_real = to_json($provider_drivers) + } else { + $provider_drivers_real = $provider_drivers + } + octavia_config { 'api_settings/bind_host': value => $host; 'api_settings/bind_port': value => $port; @@ -140,7 +142,7 @@ class octavia::api ( 'api_settings/api_v2_enabled': value => $api_v2_enabled; 'api_settings/allow_tls_terminated_listeners': value => $allow_tls_terminated_listeners; 'api_settings/default_provider_driver': value => $default_provider_driver; - 'api_settings/enabled_provider_drivers': value => $provider_drivers; + 'api_settings/enabled_provider_drivers': value => $provider_drivers_real; } } diff --git a/spec/classes/octavia_api_spec.rb b/spec/classes/octavia_api_spec.rb index 3badc2b3..a1311444 100644 --- a/spec/classes/octavia_api_spec.rb +++ b/spec/classes/octavia_api_spec.rb @@ -67,7 +67,7 @@ describe 'octavia::api' do is_expected.to contain_octavia_config('api_settings/api_v2_enabled').with_value( params[:api_v2_enabled] ) is_expected.to contain_octavia_config('api_settings/allow_tls_terminated_listeners').with_value( params[:allow_tls_terminated_listeners] ) is_expected.to contain_octavia_config('api_settings/default_provider_driver').with_value( params[:default_provider_driver] ) - is_expected.to contain_octavia_config('api_settings/enabled_provider_drivers').with_value( params[:provider_drivers] ) + is_expected.to contain_octavia_config('api_settings/enabled_provider_drivers').with_value( '{"amphora":"Octavia Amphora Driver","ovn":"Octavia OVN driver"}' ) end [{:enabled => true}, {:enabled => false}].each do |param_hash|