Implement Gnocchi keystone resources
* Manage user, user/role, service and endpoints. * Update the README with service description.
This commit is contained in:
parent
ff8030151f
commit
5b9d6a5bc6
|
@ -25,7 +25,8 @@ Setup
|
|||
|
||||
**What the gnocchi module affects:**
|
||||
|
||||
* gnocchi, the HTTP API to store metrics and index resources for OpenStack.
|
||||
* gnocchi, the HTTP API to store metrics and index resources for OpenStack
|
||||
(OpenStack Datapoint Service).
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
#
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# gnocchi::keystone::auth
|
||||
#
|
||||
# Configures Gnocchi user, service and endpoint in Keystone.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (required) Password for Gnocchi user.
|
||||
#
|
||||
# [*auth_name*]
|
||||
# Username for Gnocchi service. Defaults to 'gnocchi'.
|
||||
#
|
||||
# [*email*]
|
||||
# Email for Gnocchi user. Defaults to 'gnocchi@localhost'.
|
||||
#
|
||||
# [*tenant*]
|
||||
# Tenant for Gnocchi user. Defaults to 'services'.
|
||||
#
|
||||
# [*configure_endpoint*]
|
||||
# Should Gnocchi endpoint be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*configure_user*]
|
||||
# Should Gnocchi user be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*configure_user_role*]
|
||||
# Should Gnocchi user/role association be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*service_type*]
|
||||
# Type of service. Defaults to 'gnocchi'.
|
||||
#
|
||||
# [*public_protocol*]
|
||||
# Protocol for public endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*public_address*]
|
||||
# Public address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*public_port*]
|
||||
# Port for public endpoint.
|
||||
# Defaults to '8041'.
|
||||
#
|
||||
# [*admin_protocol*]
|
||||
# Protocol for admin endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*admin_address*]
|
||||
# Admin address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*admin_port*]
|
||||
# Port for admin endpoint.
|
||||
# Defaults to '8041'.
|
||||
#
|
||||
# [*internal_protocol*]
|
||||
# Protocol for internal endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*internal_address*]
|
||||
# Internal address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*internal_port*]
|
||||
# Port for internal endpoint.
|
||||
# Defaults to '8041'.
|
||||
#
|
||||
# [*region*]
|
||||
# Region for endpoint. Defaults to 'RegionOne'.
|
||||
#
|
||||
#
|
||||
class gnocchi::keystone::auth (
|
||||
$password,
|
||||
$auth_name = 'gnocchi',
|
||||
$email = 'gnocchi@localhost',
|
||||
$tenant = 'services',
|
||||
$configure_endpoint = true,
|
||||
$configure_user = true,
|
||||
$configure_user_role = true,
|
||||
$service_type = 'gnocchi',
|
||||
$public_protocol = 'http',
|
||||
$public_address = '127.0.0.1',
|
||||
$public_port = '8041',
|
||||
$admin_protocol = 'http',
|
||||
$admin_address = '127.0.0.1',
|
||||
$admin_port = '8041',
|
||||
$internal_protocol = 'http',
|
||||
$internal_address = '127.0.0.1',
|
||||
$internal_port = '8041',
|
||||
$region = 'RegionOne'
|
||||
) {
|
||||
|
||||
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'gnocchi-api' |>
|
||||
Keystone_endpoint["${region}/${auth_name}"] ~> Service <| name == 'gnocchi-api' |>
|
||||
|
||||
keystone::resource::service_identity { $auth_name:
|
||||
configure_user => true,
|
||||
configure_user_role => true,
|
||||
configure_endpoint => $configure_endpoint,
|
||||
service_type => $service_type,
|
||||
service_description => 'OpenStack Datapoint Service',
|
||||
region => $region,
|
||||
password => $password,
|
||||
email => $email,
|
||||
tenant => $tenant,
|
||||
public_url => "${public_protocol}://${public_address}:${public_port}",
|
||||
internal_url => "${internal_protocol}://${internal_address}:${internal_port}",
|
||||
admin_url => "${admin_protocol}://${admin_address}:${admin_port}",
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# Unit tests for gnocchi::keystone::auth
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'gnocchi::keystone::auth' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'gnocchi_password',
|
||||
:tenant => 'foobar' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('gnocchi').with(
|
||||
:ensure => 'present',
|
||||
:password => 'gnocchi_password',
|
||||
:tenant => 'foobar'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_user_role('gnocchi@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('gnocchi').with(
|
||||
:ensure => 'present',
|
||||
:type => 'gnocchi',
|
||||
:description => 'Gnocchi Datapoint Service'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/gnocchi').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "http://127.0.0.1:8041",
|
||||
:admin_url => "http://127.0.0.1:8041",
|
||||
:internal_url => "http://127.0.0.1:8041"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding public_protocol, public_port and public_address' do
|
||||
let :params do
|
||||
{ :password => 'gnocchi_password',
|
||||
:public_protocol => 'https',
|
||||
:public_port => '80',
|
||||
:public_address => '10.10.10.10',
|
||||
:port => '81',
|
||||
:internal_address => '10.10.10.11',
|
||||
:admin_address => '10.10.10.12' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/gnocchi').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "https://10.10.10.10:80",
|
||||
:internal_url => "http://10.10.10.11:81",
|
||||
:admin_url => "http://10.10.10.12:81"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'gnocchy' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('gnocchy') }
|
||||
it { should contain_keystone_user_role('gnocchy@services') }
|
||||
it { should contain_keystone_service('gnocchy') }
|
||||
it { should contain_keystone_endpoint('RegionOne/gnocchy') }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue