Skip to content

Commit

Permalink
Move deps & external hooks into a standalone class
Browse files Browse the repository at this point in the history
Previously the anchors and dependencies that allow external hooks were
all in the main ::heat class.  However, if you wanted to include just
::heat::db::mysql, then it would fail, since it assumed the main heat
class was included.  This moves all of those resources and relationships
into a new class, ::heat::deps.  All of the classes will now include
this class so that the anchors and deps are always evaluated even if
only a portion of the classes are used, and even if ::heat isn't pulled
in.

Change-Id: I4297df160a7afae2b66c1ac76e37de313fa4fb09
Closes-Bug: #1507934
  • Loading branch information
claytono committed Oct 20, 2015
1 parent 3b9cdd0 commit dca9fe9
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 25 deletions.
1 change: 1 addition & 0 deletions manifests/api.pp
Expand Up @@ -59,6 +59,7 @@
) {

include ::heat
include ::heat::deps
include ::heat::params
include ::heat::policy

Expand Down
1 change: 1 addition & 0 deletions manifests/api_cfn.pp
Expand Up @@ -62,6 +62,7 @@
) {

include ::heat
include ::heat::deps
include ::heat::params
include ::heat::policy

Expand Down
1 change: 1 addition & 0 deletions manifests/api_cloudwatch.pp
Expand Up @@ -61,6 +61,7 @@
) {

include ::heat
include ::heat::deps
include ::heat::params
include ::heat::policy

Expand Down
1 change: 1 addition & 0 deletions manifests/client.pp
Expand Up @@ -11,6 +11,7 @@
$ensure = 'present'
) {

include ::heat::deps
include ::heat::params

package { 'python-heatclient':
Expand Down
2 changes: 2 additions & 0 deletions manifests/config.pp
Expand Up @@ -24,6 +24,8 @@
$heat_config = {},
) {

include ::heat::deps

validate_hash($heat_config)

create_resources('heat_config', $heat_config)
Expand Down
2 changes: 2 additions & 0 deletions manifests/db.pp
Expand Up @@ -48,6 +48,8 @@
$sync_db = true,
) {

include ::heat::deps

# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use heat::<myparam> if heat::db::<myparam> isn't specified.
$database_connection_real = pick($::heat::database_connection, $database_connection)
Expand Down
2 changes: 2 additions & 0 deletions manifests/db/mysql.pp
Expand Up @@ -50,6 +50,8 @@
$mysql_module = undef
) {

include ::heat::deps

if $mysql_module {
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
}
Expand Down
2 changes: 2 additions & 0 deletions manifests/db/postgresql.pp
Expand Up @@ -32,6 +32,8 @@
$privileges = 'ALL',
) {

include ::heat::deps

::openstacklib::db::postgresql { 'heat':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
Expand Down
1 change: 1 addition & 0 deletions manifests/db/sync.pp
Expand Up @@ -3,6 +3,7 @@
#
class heat::db::sync {

include ::heat::deps
include ::heat::params

exec { 'heat-dbsync':
Expand Down
30 changes: 30 additions & 0 deletions manifests/deps.pp
@@ -0,0 +1,30 @@
# == Class: heat::deps
#
# Heat anchors and dependency management
#
class heat::deps {
# Setup anchors for install, config and service phases of the module. These
# anchors allow external modules to hook the begin and end of any of these
# phases. Package or service management can also be replaced by ensuring the
# package is absent or turning off service management and having the
# replacement depend on the appropriate anchors. When applicable, end tags
# should be notified so that subscribers can determine if installation,
# config or service state changed and act on that if needed.
anchor { 'heat::install::begin': }
-> Package<| tag == 'heat-package'|>
~> anchor { 'heat::install::end': }
-> anchor { 'heat::config::begin': }
-> Heat_config<||>
~> anchor { 'heat::config::end': }
-> anchor { 'heat::db::begin': }
-> anchor { 'heat::db::end': }
~> anchor { 'heat::dbsync::begin': }
-> anchor { 'heat::dbsync::end': }
~> anchor { 'heat::service::begin': }
~> Service<| tag == 'heat-service' |>
~> anchor { 'heat::service::end': }

# Installation or config changes will always restart services.
Anchor['heat::install::end'] ~> Anchor['heat::service::begin']
Anchor['heat::config::end'] ~> Anchor['heat::service::begin']
}
2 changes: 2 additions & 0 deletions manifests/engine.pp
Expand Up @@ -93,6 +93,8 @@
$trusts_delegated_roles = ['heat_stack_owner'],
) {

include ::heat::deps

# Validate Heat Engine AES key
# must be either 16, 24, or 32 bytes long
# https://bugs.launchpad.net/heat/+bug/1415887
Expand Down
26 changes: 1 addition & 25 deletions manifests/init.pp
Expand Up @@ -299,6 +299,7 @@

include ::heat::logging
include ::heat::db
include ::heat::deps
include ::heat::params

if $kombu_ssl_ca_certs and !$rabbit_use_ssl {
Expand Down Expand Up @@ -544,29 +545,4 @@
} else {
heat_config { 'DEFAULT/enable_stack_abandon': ensure => absent; }
}

# Setup anchors for install, config and service phases of the module. These
# anchors allow external modules to hook the begin and end of any of these
# phases. Package or service management can also be replaced by ensuring the
# package is absent or turning off service management and having the
# replacement depend on the appropriate anchors. When applicable, end tags
# should be notified so that subscribers can determine if installation,
# config or service state changed and act on that if needed.
anchor { 'heat::install::begin': }
-> Package<| tag == 'heat-package'|>
~> anchor { 'heat::install::end': }
-> anchor { 'heat::config::begin': }
-> Heat_config<||>
~> anchor { 'heat::config::end': }
-> anchor { 'heat::db::begin': }
-> anchor { 'heat::db::end': }
~> anchor { 'heat::dbsync::begin': }
-> anchor { 'heat::dbsync::end': }
~> anchor { 'heat::service::begin': }
~> Service<| tag == 'heat-service' |>
~> anchor { 'heat::service::end': }

# Installation or config changes will always restart services.
Anchor['heat::install::end'] ~> Anchor['heat::service::begin']
Anchor['heat::config::end'] ~> Anchor['heat::service::begin']
}
2 changes: 2 additions & 0 deletions manifests/keystone/auth.pp
Expand Up @@ -168,6 +168,8 @@
$admin_address = undef,
) {

include ::heat::deps

validate_string($password)

if $version {
Expand Down
2 changes: 2 additions & 0 deletions manifests/keystone/auth_cfn.pp
Expand Up @@ -137,6 +137,8 @@
$admin_address = undef,
) {

include ::heat::deps

validate_string($password)

if $version {
Expand Down
1 change: 1 addition & 0 deletions manifests/keystone/domain.pp
Expand Up @@ -49,6 +49,7 @@
$keystone_tenant = undef,
) {

include ::heat::deps
include ::heat::params

if $auth_url {
Expand Down
2 changes: 2 additions & 0 deletions manifests/logging.pp
Expand Up @@ -110,6 +110,8 @@
$log_date_format = undef,
) {

include ::heat::deps

# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use heat::<myparam> first then heat::logging::<myparam>.
$use_syslog_real = pick($::heat::use_syslog,$use_syslog)
Expand Down
2 changes: 2 additions & 0 deletions manifests/policy.pp
Expand Up @@ -23,6 +23,8 @@
$policy_path = '/etc/heat/policy.json',
) {

include ::heat::deps

validate_hash($policies)

Openstacklib::Policy::Base {
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/heat_deps_spec.rb
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'heat::deps' do

it 'set up the anchors' do
is_expected.to contain_anchor('heat::install::begin')
is_expected.to contain_anchor('heat::install::end')
is_expected.to contain_anchor('heat::config::begin')
is_expected.to contain_anchor('heat::config::end')
is_expected.to contain_anchor('heat::db::begin')
is_expected.to contain_anchor('heat::db::end')
is_expected.to contain_anchor('heat::dbsync::begin')
is_expected.to contain_anchor('heat::dbsync::end')
is_expected.to contain_anchor('heat::service::begin')
is_expected.to contain_anchor('heat::service::end')
end
end

0 comments on commit dca9fe9

Please sign in to comment.