From 92390dcbec4772eb6ef4cc7cbdf56abb9132ff8d Mon Sep 17 00:00:00 2001 From: Rohit Pagedar Date: Wed, 14 Oct 2015 16:36:35 -0400 Subject: [PATCH] Making instance_name_template configurable. This will allow users to configure the value. The parameter will be added only if required, and exposed via heat templates. instance_name_template is a template string to be used to generate instance names. Added spec tests for instance_name_template Change-Id: Ic2b9b9f34521afbb2744690945230e14052f84d2 --- manifests/api.pp | 15 +++++++++++++++ spec/classes/nova_api_spec.rb | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/manifests/api.pp b/manifests/api.pp index 066a035be..48a0c0c25 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -110,6 +110,10 @@ # Class instead. # Defaults to undef # +# [*instance_name_template*] +# (optional) Template string to be used to generate instance names +# Defaults to undef +# # [*sync_db*] # (optional) Run nova-manage db sync on api nodes after installing the package. # Defaults to true @@ -194,6 +198,7 @@ class nova::api( 'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory', $validate = false, $validation_options = {}, + $instance_name_template = undef, # DEPRECATED PARAMETER $auth_protocol = 'http', $auth_port = 35357, @@ -220,6 +225,16 @@ class nova::api( warning('The conductor_workers parameter is deprecated and has no effect. Use workers parameter of nova::conductor class instead.') } + if $instance_name_template { + nova_config { + 'DEFAULT/instance_name_template': value => $instance_name_template; + } + } else { + nova_config{ + 'DEFAULT/instance_name_template': ensure => absent; + } + } + nova::generic_service { 'api': enabled => $enabled, manage_service => $manage_service, diff --git a/spec/classes/nova_api_spec.rb b/spec/classes/nova_api_spec.rb index 869830968..77642bd70 100644 --- a/spec/classes/nova_api_spec.rb +++ b/spec/classes/nova_api_spec.rb @@ -56,6 +56,8 @@ describe 'nova::api' do 'keystone_authtoken/admin_password').with_value('passw0rd').with_secret(true) end + it { is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_ensure('absent')} + it 'configures various stuff' do is_expected.to contain_nova_config('DEFAULT/ec2_listen').with('value' => '0.0.0.0') is_expected.to contain_nova_config('DEFAULT/ec2_listen_port').with('value' => '8773') @@ -270,6 +272,17 @@ describe 'nova::api' do it { is_expected.to contain_nova_config('database/idle_timeout').with_value('30') } end + context 'with custom instance_name_template' do + before do + params.merge!({ + :instance_name_template => 'instance-%08x', + }) + end + it 'configures instance_name_template' do + is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('instance-%08x'); + end + end + context 'with custom keystone identity_uri' do before do params.merge!({