Fix hooks for external install & svc management

1) Add deps to all that is needed.
2) Fix hooks for external install & svc management.
3) Update releated spec tests.

Change-Id: Id3e0594631579c316c721dd53b0579808571ee95
This commit is contained in:
ZhongShengping 2016-12-01 17:54:42 +08:00
parent ecd93bf5f2
commit 8aee1f413f
18 changed files with 64 additions and 25 deletions

View File

@ -164,10 +164,6 @@ class watcher::api (
validate_string($watcher_client_password)
Watcher_config<||> ~> Service['watcher-api']
Class['watcher::policy'] ~> Service['watcher-api']
Package['watcher-api'] -> Service['watcher-api']
package { 'watcher-api':
ensure => $package_ensure,
name => $::watcher::params::api_package_name,
@ -239,7 +235,7 @@ class watcher::api (
}
}
$validation_options_hash = merge($defaults, $validation_options)
create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[watcher-api]'})
create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Anchor[watcher::service::end]'})
}
}

View File

@ -50,9 +50,6 @@ class watcher::applier (
include ::watcher::params
include ::watcher::deps
Watcher_config<||> ~> Service['watcher-applier']
Package['watcher-applier'] -> Service['watcher-applier']
package { 'watcher-applier':
ensure => $package_ensure,
name => $::watcher::params::applier_package_name,

View File

@ -24,6 +24,8 @@ class watcher::config (
$watcher_config = {},
) {
include ::watcher::deps
validate_hash($watcher_config)
create_resources('watcher_config', $watcher_config)

View File

@ -49,6 +49,8 @@ class watcher::db (
$database_max_overflow = $::os_service_default,
) {
include ::watcher::deps
validate_re($database_connection,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')

View File

@ -11,14 +11,15 @@
class watcher::db::create_schema(
$extra_params = '--config-file /etc/watcher/watcher.conf',
) {
include ::watcher::deps
exec { 'watcher-db-manage-create_schema':
command => "watcher-db-manage ${extra_params} create_schema",
path => '/usr/bin',
user => 'watcher',
refreshonly => true,
subscribe => [
Package['watcher'],
Watcher_config['database/connection'],
Anchor['watcher::install::end'],
Anchor['watcher::config::end'],
Anchor['watcher::db::create_schema::begin']
@ -26,5 +27,4 @@ class watcher::db::create_schema(
notify => Anchor['watcher::db::create_schema::end'],
}
Exec['watcher-db-manage-create_schema'] ~> Service<| title == 'watcher-db-manage-create_schema' |>
}

View File

@ -53,6 +53,8 @@ class watcher::db::mysql(
$allowed_hosts = undef
) {
include ::watcher::deps
validate_string($password)
::openstacklib::db::mysql { 'watcher':
@ -65,7 +67,8 @@ class watcher::db::mysql(
allowed_hosts => $allowed_hosts,
}
::Openstacklib::Db::Mysql['watcher'] ~> Exec<| title == 'watcher-db-manage-create_schema' |>
::Openstacklib::Db::Mysql['watcher'] ~> Exec<| title == 'watcher-db-manage-upgrade' |>
Anchor['watcher::db::begin']
~> Class['watcher::db::mysql']
~> Anchor['watcher::db::end']
}

View File

@ -40,7 +40,7 @@ class watcher::db::postgresql(
$privileges = 'ALL',
) {
Class['watcher::db::postgresql'] -> Service<| title == 'watcher' |>
include ::watcher::deps
::openstacklib::db::postgresql { 'watcher':
password_hash => postgresql_password($user, $password),
@ -50,7 +50,8 @@ class watcher::db::postgresql(
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['watcher'] ~> Exec<| title == 'watcher-db-manage-create_schema' |>
::Openstacklib::Db::Postgresql['watcher'] ~> Exec<| title == 'watcher-db-manage-upgrade' |>
Anchor['watcher::db::begin']
~> Class['watcher::db::postgresql']
~> Anchor['watcher::db::end']
}

View File

@ -12,14 +12,15 @@
class watcher::db::upgrade(
$extra_params = '--config-file /etc/watcher/watcher.conf',
) {
include ::watcher::deps
exec { 'watcher-db-manage-upgrade':
command => "watcher-db-manage ${extra_params} upgrade",
path => '/usr/bin',
user => 'watcher',
refreshonly => true,
subscribe => [
Package['watcher'],
Watcher_config['database/connection'],
Anchor['watcher::install::end'],
Anchor['watcher::config::end'],
Anchor['watcher::db::create_schema::end'],
@ -28,5 +29,4 @@ class watcher::db::upgrade(
notify => Anchor['watcher::db::upgrade::end'],
}
Exec['watcher-db-manage-upgrade'] ~> Service<| title == 'watcher-db-manage-upgrade' |>
}

View File

@ -82,9 +82,6 @@ class watcher::decision_engine (
$decision_engine_notification_topics_real = $decision_engine_notification_topics
}
Watcher_config<||> ~> Service['watcher-decision-engine']
Package['watcher-decision-engine'] -> Service['watcher-decision-engine']
package { 'watcher-decision-engine':
ensure => $package_ensure,
name => $::watcher::params::decision_engine_package_name,

View File

@ -19,6 +19,11 @@ class watcher::deps {
~> Service<| tag == 'watcher-service' |>
~> anchor { 'watcher::service::end': }
# policy config should occur in the config block also.
Anchor['watcher::config::begin']
-> Openstacklib::Policy::Base<||>
~> Anchor['watcher::config::end']
Anchor['watcher::install::end'] ~> Anchor['watcher::service::begin']
Anchor['watcher::config::end'] ~> Anchor['watcher::service::begin']

View File

@ -382,7 +382,6 @@ class watcher (
include ::watcher::db
include ::watcher::logging
Package['watcher'] -> Class['watcher::policy']
package { 'watcher':
ensure => $ensure_package,
name => $::watcher::params::common_package_name,

View File

@ -69,12 +69,17 @@ class watcher::keystone::auth (
$internal_url = 'http://127.0.0.1:9322',
) {
include ::watcher::deps
$real_service_name = pick($service_name, $auth_name)
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'watcher-server' |>
Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['watcher::service::end']
}
if $configure_endpoint {
Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Anchor['watcher::service::end']
}
Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Service <| name == 'watcher-server' |>
keystone::resource::service_identity { 'watcher':
configure_user => $configure_user,

View File

@ -113,6 +113,8 @@ class watcher::logging(
$log_date_format = $::os_service_default,
) {
include ::watcher::deps
oslo::log { 'watcher_config':
use_stderr => $use_stderr,
use_syslog => $use_syslog,

View File

@ -28,6 +28,8 @@ class watcher::policy (
$policy_path = '/etc/watcher/policy.json',
) {
include ::watcher::deps
validate_hash($policies)
Openstacklib::Policy::Base {

View File

@ -18,6 +18,7 @@ describe 'watcher::api' do
end
it { is_expected.to contain_class('watcher::params') }
it { is_expected.to contain_class('watcher::deps') }
it 'installs watcher-api package' do
is_expected.to contain_package('watcher-api').with(

View File

@ -10,6 +10,12 @@ describe 'watcher::db::create_schema' do
:path => '/usr/bin',
:user => 'watcher',
:refreshonly => 'true',
:subscribe => [
'Anchor[watcher::install::end]',
'Anchor[watcher::config::end]',
'Anchor[watcher::db::create_schema::begin]'
],
:notify => 'Anchor[watcher::db::create_schema::end]',
)
end
@ -26,6 +32,12 @@ describe 'watcher::db::create_schema' do
:path => '/usr/bin',
:user => 'watcher',
:refreshonly => 'true',
:subscribe => [
'Anchor[watcher::install::end]',
'Anchor[watcher::config::end]',
'Anchor[watcher::db::create_schema::begin]'
],
:notify => 'Anchor[watcher::db::create_schema::end]',
)
}
end

View File

@ -10,6 +10,13 @@ describe 'watcher::db::upgrade' do
:path => '/usr/bin',
:user => 'watcher',
:refreshonly => 'true',
:subscribe => [
'Anchor[watcher::install::end]',
'Anchor[watcher::config::end]',
'Anchor[watcher::db::create_schema::end]',
'Anchor[watcher::db::upgrade::begin]'
],
:notify => 'Anchor[watcher::db::upgrade::end]',
)
end
@ -26,6 +33,13 @@ describe 'watcher::db::upgrade' do
:path => '/usr/bin',
:user => 'watcher',
:refreshonly => 'true',
:subscribe => [
'Anchor[watcher::install::end]',
'Anchor[watcher::config::end]',
'Anchor[watcher::db::create_schema::end]',
'Anchor[watcher::db::upgrade::begin]'
],
:notify => 'Anchor[watcher::db::upgrade::end]',
)
}
end

View File

@ -26,6 +26,7 @@ describe 'watcher' do
end
it { is_expected.to contain_class('watcher::policy') }
it { is_expected.to contain_class('watcher::deps') }
it 'configures rabbit' do
is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('rabbit')