Validate service_identity resources
* When creating an user, show a warning if no password has been set. * When creating a service, validate that a service_type is set. * When creating endpoints, validate *_url are set. It avoid catalog failures if a parameter is missing. Change-Id: Ibe6c467a875bbdb09faad91d7ee39edf35e30624
This commit is contained in:
parent
f654d3cd9b
commit
a41504d2df
@ -156,6 +156,9 @@ define keystone::resource::service_identity(
|
||||
'ignore_default_tenant' => $ignore_default_tenant,
|
||||
'domain' => $user_domain_real,
|
||||
})
|
||||
if ! $password {
|
||||
warning("No password had been set for ${auth_name} user.")
|
||||
}
|
||||
}
|
||||
|
||||
if $configure_user_role {
|
||||
@ -166,19 +169,27 @@ define keystone::resource::service_identity(
|
||||
}
|
||||
|
||||
if $configure_service {
|
||||
ensure_resource('keystone_service', $service_name_real, {
|
||||
'ensure' => 'present',
|
||||
'type' => $service_type,
|
||||
'description' => $service_description,
|
||||
})
|
||||
if $service_type {
|
||||
ensure_resource('keystone_service', $service_name_real, {
|
||||
'ensure' => 'present',
|
||||
'type' => $service_type,
|
||||
'description' => $service_description,
|
||||
})
|
||||
} else {
|
||||
fail ('When configuring a service, you need to set the service_type parameter.')
|
||||
}
|
||||
}
|
||||
|
||||
if $configure_endpoint {
|
||||
ensure_resource('keystone_endpoint', "${region}/${service_name_real}", {
|
||||
'ensure' => 'present',
|
||||
'public_url' => $public_url,
|
||||
'admin_url' => $admin_url,
|
||||
'internal_url' => $internal_url,
|
||||
})
|
||||
if $public_url and $admin_url and $internal_url {
|
||||
ensure_resource('keystone_endpoint', "${region}/${service_name_real}", {
|
||||
'ensure' => 'present',
|
||||
'public_url' => $public_url,
|
||||
'admin_url' => $admin_url,
|
||||
'internal_url' => $internal_url,
|
||||
})
|
||||
} else {
|
||||
fail ('When configuring an endpoint, you need to set the _url parameters.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,11 +62,20 @@ describe 'keystone::resource::service_identity' do
|
||||
)}
|
||||
end
|
||||
|
||||
context 'when omitting a required parameter password' do
|
||||
context 'when trying to create a service without service_type' do
|
||||
let :params do
|
||||
required_params.delete(:password)
|
||||
required_params.delete(:service_type)
|
||||
required_params
|
||||
end
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
it_raises 'a Puppet::Error', /When configuring a service, you need to set the service_type parameter/
|
||||
end
|
||||
|
||||
context 'when trying to create an endpoint without url' do
|
||||
let :params do
|
||||
required_params.delete(:public_url)
|
||||
required_params
|
||||
end
|
||||
it_raises 'a Puppet::Error', /When configuring an endpoint, you need to set the _url parameters/
|
||||
end
|
||||
|
||||
context 'with user domain' do
|
||||
|
Loading…
Reference in New Issue
Block a user