Add vitrage auth and client class

* auth.pp for vitrage authentication
* client.pp for vitrage client installation

Change-Id: I7bb2a372908614871eaca8c1aed82aaf002e4b90
This commit is contained in:
Eyal 2016-05-29 11:52:22 +03:00
parent df32501f11
commit 223d161b44
5 changed files with 165 additions and 0 deletions

61
manifests/auth.pp Normal file
View File

@ -0,0 +1,61 @@
# The vitrage::auth class helps configure auth settings
#
# == Parameters
# [*auth_url*]
# the keystone public endpoint
# Optional. Defaults to 'http://localhost:5000'
#
# [*auth_region*]
# the keystone region of this node
# Optional. Defaults to 'RegionOne'
#
# [*auth_user*]
# the keystone user for vitrage services
# Optional. Defaults to 'vitrage'
#
# [*auth_password*]
# the keystone password for vitrage services
# Required.
#
# [*auth_tenant_name*]
# the keystone tenant name for vitrage services
# Optional. Defaults to 'services'
#
# [*auth_tenant_id*]
# the keystone tenant id for vitrage services.
# Optional. Defaults to $::os_service_default.
#
# [*auth_cacert*]
# Certificate chain for SSL validation.
# Optional. Defaults to $::os_service_default.
#
# [*auth_endpoint_type*]
# Type of endpoint in Identity service catalog to use for
# communication with OpenStack services.
# Optional. Defaults to $::os_service_default.
#
class vitrage::auth (
$auth_password,
$auth_url = 'http://localhost:5000',
$auth_region = 'RegionOne',
$auth_user = 'vitrage',
$auth_tenant_name = 'services',
$auth_tenant_id = $::os_service_default,
$auth_cacert = $::os_service_default,
$auth_endpoint_type = $::os_service_default,
) {
vitrage_config {
'service_credentials/os_auth_url' : value => $auth_url;
'service_credentials/os_region_name' : value => $auth_region;
'service_credentials/os_username' : value => $auth_user;
'service_credentials/os_password' : value => $auth_password, secret => true;
'service_credentials/os_tenant_name' : value => $auth_tenant_name;
'service_credentials/os_tenant_id' : value => $auth_tenant_id;
'service_credentials/os_endpoint_type' : value => $auth_endpoint_type;
'service_credentials/os_cacert' : value => $auth_cacert
}
}

21
manifests/client.pp Normal file
View File

@ -0,0 +1,21 @@
#
# Installs the vitrage python library.
#
# == parameters
# [*ensure*]
# ensure state for package.
#
class vitrage::client (
$ensure = 'present'
) {
include ::vitrage::params
package { 'python-vitrageclient':
ensure => $ensure,
name => $::vitrage::params::client_package_name,
tag => 'openstack',
}
}

View File

@ -2,6 +2,8 @@
#
class vitrage::params {
$client_package_name = 'python-vitrageclient'
case $::osfamily {
'RedHat': {
$api_package_name = 'openstack-vitrage-api'

View File

@ -0,0 +1,51 @@
require 'spec_helper'
describe 'vitrage::auth' do
let :params do
{ :auth_url => 'http://localhost:5000',
:auth_region => 'RegionOne',
:auth_user => 'vitrage',
:auth_password => 'password',
:auth_tenant_name => 'services',
}
end
shared_examples_for 'vitrage-auth' do
it 'configures authentication' do
is_expected.to contain_vitrage_config('service_credentials/os_auth_url').with_value('http://localhost:5000')
is_expected.to contain_vitrage_config('service_credentials/os_region_name').with_value('RegionOne')
is_expected.to contain_vitrage_config('service_credentials/os_username').with_value('vitrage')
is_expected.to contain_vitrage_config('service_credentials/os_password').with_value('password')
is_expected.to contain_vitrage_config('service_credentials/os_password').with_value(params[:auth_password]).with_secret(true)
is_expected.to contain_vitrage_config('service_credentials/os_tenant_name').with_value('services')
is_expected.to contain_vitrage_config('service_credentials/os_cacert').with_value('<SERVICE DEFAULT>')
end
context 'when overriding parameters' do
before do
params.merge!(
:auth_cacert => '/tmp/dummy.pem',
:auth_endpoint_type => 'internalURL',
)
end
it { is_expected.to contain_vitrage_config('service_credentials/os_cacert').with_value(params[:auth_cacert]) }
it { is_expected.to contain_vitrage_config('service_credentials/os_endpoint_type').with_value(params[:auth_endpoint_type]) }
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 'vitrage-auth'
end
end
end

View File

@ -0,0 +1,30 @@
require 'spec_helper'
describe 'vitrage::client' do
shared_examples_for 'vitrage client' do
it { is_expected.to contain_class('vitrage::params') }
it 'installs vitrage client package' do
is_expected.to contain_package('python-vitrageclient').with(
:ensure => 'present',
:name => 'python-vitrageclient',
:tag => 'openstack',
)
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 'vitrage client'
end
end
end