Added nova patching configuration parameters
These parameters are available in nova.conf, but were not configurable using puppet-nova. The monkey patching parameters allow patching a decorator for all functions in specified modules. This change create patch/config.pp file to make these parameters configurable. Change-Id: I51ef3e19daff1d98cfe5c2c16475c16e6a3e3e0f Closes-Bug: #1710292
This commit is contained in:
		
							
								
								
									
										28
									
								
								manifests/patch/config.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								manifests/patch/config.pp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
# == Class: nova:patch::config
 | 
			
		||||
#
 | 
			
		||||
# This class is aim to configure nova.patch parameters
 | 
			
		||||
#
 | 
			
		||||
# === Parameters:
 | 
			
		||||
#
 | 
			
		||||
# [*monkey_patch*]
 | 
			
		||||
#   (optional) Apply monkey patching or not
 | 
			
		||||
#   Defaults to false
 | 
			
		||||
#
 | 
			
		||||
# [*monkey_patch_modules*]
 | 
			
		||||
#   (optional) List of modules/decorators to monkey patch
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
class nova::patch::config (
 | 
			
		||||
  $monkey_patch                        = false,
 | 
			
		||||
  $monkey_patch_modules                = $::os_service_default,
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  include ::nova::deps
 | 
			
		||||
 | 
			
		||||
  $monkey_patch_modules_real = pick(join(any2array($monkey_patch_modules), ','), $::os_service_default)
 | 
			
		||||
 | 
			
		||||
  nova_config {
 | 
			
		||||
    'DEFAULT/monkey_patch':         value => $monkey_patch;
 | 
			
		||||
    'DEFAULT/monkey_patch_modules': value => $monkey_patch_modules_real;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
features:
 | 
			
		||||
  - Added nova patching configuration parameters. These parameters are available
 | 
			
		||||
    in nova.conf, but are not configurable using puppet-nova. The monkey patching
 | 
			
		||||
    parameters allow patching a decorator for all functions in specified modules.
 | 
			
		||||
    This change create patch/config.pp file to make these parameters configurable.
 | 
			
		||||
							
								
								
									
										53
									
								
								spec/classes/nova_patch_config_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								spec/classes/nova_patch_config_spec.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe 'nova::patch::config' do
 | 
			
		||||
 | 
			
		||||
  let :params do
 | 
			
		||||
    {}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  shared_examples 'nova::patch::config' do
 | 
			
		||||
 | 
			
		||||
    it { is_expected.to contain_class('nova::deps') }
 | 
			
		||||
 | 
			
		||||
    context 'with default parameters' do
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch').with_value('false') }
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch_modules').with(:value => '<SERVICE DEFAULT>') }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'when overriding parameters' do
 | 
			
		||||
      let :params do
 | 
			
		||||
        { :monkey_patch         => true,
 | 
			
		||||
          :monkey_patch_modules => ['nova.compute.api:nova.notifications.notify_decorator']
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch').with_value('true') }
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch_modules').with_value('nova.compute.api:nova.notifications.notify_decorator') }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'when overriding parameters with reset values' do
 | 
			
		||||
      let :params do
 | 
			
		||||
        { :monkey_patch         => false,
 | 
			
		||||
          :monkey_patch_modules => '<SERVICE DEFAULT>'
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch').with_value('false') }
 | 
			
		||||
      it { is_expected.to contain_nova_config('DEFAULT/monkey_patch_modules').with(:value => '<SERVICE DEFAULT>') }
 | 
			
		||||
    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 'nova::patch::config'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
		Reference in New Issue
	
	Block a user