diff --git a/manifests/server/placement.pp b/manifests/server/placement.pp new file mode 100644 index 000000000..b355e02ca --- /dev/null +++ b/manifests/server/placement.pp @@ -0,0 +1,98 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: neutron::server::placement +# +# Configure Placement API Options +# +# === Parameters +# +# [*password*] +# (required) Password for connection to nova in admin context. +# +# [*auth_type*] +# (optional) An authentication type to use with an OpenStack Identity server. +# The value should contain auth plugin name +# Defaults to 'password' +# +# [*username*] +# (optional) Username for connection to nova in admin context +# Defaults to 'nova' +# +# [*project_domain_id*] +# (optional) Nova project's domain ID +# Defaults to 'default' +# +# [*project_domain_name*] +# (Optional) Name of domain for $project_name +# Defaults to 'Default' +# +# [*project_name*] +# (optional) Nova project's name +# Defaults to 'services' +# +# [*user_domain_id*] +# (optional) User's domain ID for connection to nova in admin context +# Defaults to 'default' +# +# [*user_domain_name*] +# (Optional) Name of domain for $username +# Defaults to 'Default' +# +# [*auth_url*] +# (optional) Authorization URL for connection to nova in admin context. +# If version independent identity plugin is used available versions will be +# determined using auth_url +# Defaults to 'http://127.0.0.1:35357' +# +# [*region_name*] +# (optional) Name of nova region to use. Useful if keystone manages more than +# one region. +# Defaults to $::os_service_default +# +# [*endpoint_type*] +# (optional) The type of nova endpoint to use when looking up in +# the keystone catalog. +# Defaults to $::os_service_default +# + +class neutron::server::placement ( + $password, + $auth_type = 'password', + $username = 'nova', + $project_domain_id = 'default', + $project_domain_name = 'Default', + $project_name = 'services', + $user_domain_id = 'default', + $user_domain_name = 'Default', + $auth_url = 'http://127.0.0.1:35357', + $region_name = $::os_service_default, + $endpoint_type = $::os_service_default, +) { + + include ::neutron::deps + + neutron_config { + 'placement/auth_url': value => $auth_url; + 'placement/username': value => $username; + 'placement/password': value => $password, secret => true; + 'placement/project_domain_id': value => $project_domain_id; + 'placement/project_domain_name': value => $project_domain_name; + 'placement/project_name': value => $project_name; + 'placement/user_domain_id': value => $user_domain_id; + 'placement/user_domain_name': value => $user_domain_name; + 'placement/region_name': value => $region_name; + 'placement/endpoint_type': value => $endpoint_type; + 'placement/auth_type': value => $auth_type; + } + +} diff --git a/releasenotes/notes/add-server-placement-class-e6dd6c0c45f7ba2e.yaml b/releasenotes/notes/add-server-placement-class-e6dd6c0c45f7ba2e.yaml new file mode 100644 index 000000000..34ce32627 --- /dev/null +++ b/releasenotes/notes/add-server-placement-class-e6dd6c0c45f7ba2e.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add neutron::server::placement class to manage placement related options diff --git a/spec/classes/neutron_server_placement_spec.rb b/spec/classes/neutron_server_placement_spec.rb new file mode 100644 index 000000000..96c7f9e70 --- /dev/null +++ b/spec/classes/neutron_server_placement_spec.rb @@ -0,0 +1,114 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for neutron::server::placement class +# + +require 'spec_helper' + +describe 'neutron::server::placement' do + + let :params do + { + :auth_type => 'password', + :username => 'nova', + :password => 'secrete', + :project_domain_id => 'default', + :project_domain_name => 'Default', + :project_name => 'services', + :user_domain_id => 'default', + :user_domain_name => 'Default', + :auth_url => 'http://127.0.0.1:35357', + } + end + + let :test_facts do + { :operatingsystem => 'default', + :operatingsystemrelease => 'default' + } + end + + shared_examples_for 'neutron server placement' do + + it 'configure neutron.conf' do + is_expected.to contain_neutron_config('placement/auth_type').with_value('password') + is_expected.to contain_neutron_config('placement/auth_url').with_value('http://127.0.0.1:35357') + is_expected.to contain_neutron_config('placement/username').with_value('nova') + is_expected.to contain_neutron_config('placement/password').with_value('secrete') + is_expected.to contain_neutron_config('placement/password').with_secret( true ) + is_expected.to contain_neutron_config('placement/region_name').with_value('') + is_expected.to contain_neutron_config('placement/project_domain_id').with_value('default') + is_expected.to contain_neutron_config('placement/project_domain_name').with_value('Default') + is_expected.to contain_neutron_config('placement/user_domain_id').with_value('default') + is_expected.to contain_neutron_config('placement/user_domain_name').with_value('Default') + is_expected.to contain_neutron_config('placement/endpoint_type').with_value('') + end + + context 'when overriding parameters' do + before :each do + params.merge!( + :auth_url => 'http://keystone:35357/v2.0', + :auth_type => 'v2password', + :username => 'joe', + :region_name => 'MyRegion', + :project_domain_id => 'default_1', + :project_domain_name => 'Default_2', + :user_domain_id => 'default_3', + :user_domain_name => 'Default_4', + :endpoint_type => 'internal' + ) + end + it 'should configure neutron server with overrided parameters' do + is_expected.to contain_neutron_config('placement/auth_url').with_value('http://keystone:35357/v2.0') + is_expected.to contain_neutron_config('placement/auth_type').with_value('v2password') + is_expected.to contain_neutron_config('placement/username').with_value('joe') + is_expected.to contain_neutron_config('placement/password').with_value('secrete') + is_expected.to contain_neutron_config('placement/password').with_secret( true ) + is_expected.to contain_neutron_config('placement/region_name').with_value('MyRegion') + is_expected.to contain_neutron_config('placement/project_domain_id').with_value('default_1') + is_expected.to contain_neutron_config('placement/project_domain_name').with_value('Default_2') + is_expected.to contain_neutron_config('placement/user_domain_id').with_value('default_3') + is_expected.to contain_neutron_config('placement/user_domain_name').with_value('Default_4') + is_expected.to contain_neutron_config('placement/endpoint_type').with_value('internal') + end + end + end + context 'on Debian platforms' do + let :facts do + @default_facts.merge(test_facts.merge({ + :osfamily => 'Debian' + })) + end + + let :platform_params do + {} + end + + it_configures 'neutron server placement' + end + + context 'on RedHat platforms' do + let :facts do + @default_facts.merge(test_facts.merge({ + :osfamily => 'RedHat', + :operatingsystemrelease => '7' + })) + end + + let :platform_params do + {} + end + + it_configures 'neutron server placement' + end + +end