Add zaqar::keystone::auth_websocket
Adds a new zaqar::keystone::auth_websocket class to help create a 'messaging-websocket' Keystone endpoint. Users of zaqar websockets currently have to do substring replacement on the Zaqar HTTP URLs... having a dedicated endpoint for websockets will be much better. Change-Id: Idd3ca1765604d9a461f68fc7b4a18b23a3c19d5b
This commit is contained in:
parent
cca253d8ed
commit
837dad71f2
95
manifests/keystone/auth_websocket.pp
Normal file
95
manifests/keystone/auth_websocket.pp
Normal file
@ -0,0 +1,95 @@
|
||||
# == Class: zaqar::keystone::auth_websocket
|
||||
#
|
||||
# Configures zaqar-websocket user, service and endpoint in Keystone.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (required) Password for zaqar websocket user.
|
||||
#
|
||||
# [*auth_name*]
|
||||
# Username for zaqar service. Defaults to 'zaqar-websocket'.
|
||||
#
|
||||
# [*email*]
|
||||
# Email for zaqar websocket user. Defaults to 'zaqar-websocket@localhost'.
|
||||
#
|
||||
# [*tenant*]
|
||||
# Tenant for zaqar websocket user. Defaults to 'services'.
|
||||
#
|
||||
# [*configure_endpoint*]
|
||||
# Should zaqar websocket endpoint be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*configure_user*]
|
||||
# (Optional) Should the service user be configured?
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*service_type*]
|
||||
# Type of service. Defaults to 'messaging'.
|
||||
#
|
||||
# [*public_url*]
|
||||
# (optional) The endpoint's public url.
|
||||
# (Defaults to 'ws://127.0.0.1:9000')
|
||||
#
|
||||
# [*internal_url*]
|
||||
# (optional) The endpoint's internal url.
|
||||
# (Defaults to 'ws://127.0.0.1:9000')
|
||||
#
|
||||
# [*admin_url*]
|
||||
# (optional) The endpoint's admin url.
|
||||
# (Defaults to 'ws://127.0.0.1:9000')
|
||||
#
|
||||
# [*region*]
|
||||
# Region for endpoint. Defaults to 'RegionOne'.
|
||||
#
|
||||
# [*service_name*]
|
||||
# (optional) Name of the service.
|
||||
# Defaults to 'zaqar-websocket'
|
||||
#
|
||||
# [*configure_service*]
|
||||
# Should zaqar websocket service be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*service_description*]
|
||||
# (optional) Description for keystone service.
|
||||
# Defaults to 'Openstack messaging websocket Service'.
|
||||
|
||||
# [*configure_user_role*]
|
||||
# (optional) Whether to configure the admin role for the service user.
|
||||
# Defaults to true
|
||||
#
|
||||
class zaqar::keystone::auth_websocket(
|
||||
$password,
|
||||
$email = 'zaqar-websocket@localhost',
|
||||
$auth_name = 'zaqar-websocket',
|
||||
$service_name = 'zaqar-websocket',
|
||||
$service_type = 'messaging-websocket',
|
||||
$public_url = 'ws://127.0.0.1:9000',
|
||||
$admin_url = 'ws://127.0.0.1:9000',
|
||||
$internal_url = 'ws://127.0.0.1:9000',
|
||||
$region = 'RegionOne',
|
||||
$tenant = 'services',
|
||||
$configure_endpoint = true,
|
||||
$configure_service = true,
|
||||
$configure_user = true,
|
||||
$configure_user_role = true,
|
||||
$service_description = 'Openstack messaging websocket Service',
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
|
||||
keystone::resource::service_identity { 'zaqar-websocket':
|
||||
configure_user => $configure_user,
|
||||
configure_user_role => $configure_user_role,
|
||||
configure_endpoint => $configure_endpoint,
|
||||
service_type => $service_type,
|
||||
service_description => $service_description,
|
||||
service_name => $service_name,
|
||||
auth_name => $auth_name,
|
||||
region => $region,
|
||||
password => $password,
|
||||
email => $email,
|
||||
tenant => $tenant,
|
||||
public_url => $public_url,
|
||||
admin_url => $admin_url,
|
||||
internal_url => $internal_url,
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Adds a new zaqar::keystone::auth_websocket class to help
|
||||
create a 'messaging-websocket' Keystone endpoint.
|
@ -15,6 +15,10 @@ describe 'basic zaqar' do
|
||||
password => 'a_big_secret',
|
||||
}
|
||||
|
||||
class { '::zaqar::keystone::auth_websocket':
|
||||
password => 'a_big_secret',
|
||||
}
|
||||
|
||||
include ::mongodb::globals
|
||||
include ::mongodb::client
|
||||
class { '::mongodb::server':
|
||||
|
132
spec/classes/zaqar_keystone_auth_websocket_spec.rb
Normal file
132
spec/classes/zaqar_keystone_auth_websocket_spec.rb
Normal file
@ -0,0 +1,132 @@
|
||||
#
|
||||
# Unit tests for zaqar::keystone::auth_websocket
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'zaqar::keystone::auth_websocket' do
|
||||
|
||||
|
||||
shared_examples_for 'zaqar::keystone::auth_websocket' do
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'zaqar_password',
|
||||
:tenant => 'foobar' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('zaqar-websocket').with(
|
||||
:ensure => 'present',
|
||||
:password => 'zaqar_password',
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_user_role('zaqar-websocket@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('zaqar-websocket::messaging-websocket').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Openstack messaging websocket Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar-websocket::messaging-websocket').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "ws://127.0.0.1:9000",
|
||||
:admin_url => "ws://127.0.0.1:9000",
|
||||
:internal_url => "ws://127.0.0.1:9000"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding public_url, internal_url and admin_url' do
|
||||
let :params do
|
||||
{ :password => 'zaqar_password',
|
||||
:public_url => 'ws://10.10.10.10:9000',
|
||||
:admin_url => 'ws://10.10.10.10:9000',
|
||||
:internal_url => 'ws://10.10.10.10:9000'
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar-websocket::messaging-websocket').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "ws://10.10.10.10:9000",
|
||||
:internal_url => "ws://10.10.10.10:9000",
|
||||
:admin_url => "ws://10.10.10.10:9000"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'zaqary' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('zaqary') }
|
||||
it { is_expected.to contain_keystone_user_role('zaqary@services') }
|
||||
it { is_expected.to contain_keystone_service('zaqar-websocket::messaging-websocket') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar-websocket::messaging-websocket') }
|
||||
end
|
||||
|
||||
describe 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => 'zaqar_service',
|
||||
:auth_name => 'zaqar-websocket',
|
||||
:password => 'zaqar_password' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('zaqar-websocket') }
|
||||
it { is_expected.to contain_keystone_user_role('zaqar-websocket@services') }
|
||||
it { is_expected.to contain_keystone_service('zaqar_service::messaging-websocket') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar_service::messaging-websocket') }
|
||||
end
|
||||
|
||||
describe 'when disabling user configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'zaqar_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('zaqar-websocket') }
|
||||
it { is_expected.to contain_keystone_user_role('zaqar-websocket@services') }
|
||||
it { is_expected.to contain_keystone_service('zaqar-websocket::messaging-websocket').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Openstack messaging websocket Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
describe 'when disabling user and user role configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'zaqar_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('zaqar-websocket') }
|
||||
it { is_expected.not_to contain_keystone_user_role('zaqar-websocket@services') }
|
||||
it { is_expected.to contain_keystone_service('zaqar-websocket::messaging-websocket').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Openstack messaging websocket Service'
|
||||
) }
|
||||
|
||||
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 'zaqar::keystone::auth_websocket'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user