Skip to content

Commit

Permalink
[inspector] create a separate database configuration for ironic-inspe…
Browse files Browse the repository at this point in the history
…ctor

This service has a separate database that can be configured.
This patch is essentially a copy-paste from ironic::db.

Change-Id: Ib4d3548e76a9314592d8b66707df1987d7cfc5b9
  • Loading branch information
dtantsur committed Oct 4, 2016
1 parent c45455c commit ac03904
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 67 deletions.
21 changes: 4 additions & 17 deletions manifests/db/inspector_sync.pp
@@ -1,22 +1,9 @@
#
# Class to execute ironic-inspector dbsync
# Class to execute ironic-inspector dbsync (deprecated, use
# ironic::inspector::db::sync instead).
#
class ironic::db::inspector_sync {
warning('ironic::db::inspector_sync is deprecated, please use ironic::inspector::db::sync')

include ::ironic::deps
include ::ironic::params

exec { 'ironic-inspector-dbsync':
command => $::ironic::params::inspector_dbsync_command,
path => '/usr/bin',
user => 'ironic-inspector',
refreshonly => true,
logoutput => on_failure,
subscribe => [
Anchor['ironic-inspector::install::end'],
Anchor['ironic-inspector::config::end'],
Anchor['ironic-inspector::dbsync::begin']
],
notify => Anchor['ironic-inspector::dbsync::end'],
}
include ::ironic::inspector::db::sync
}
8 changes: 4 additions & 4 deletions manifests/inspector.pp
Expand Up @@ -53,7 +53,7 @@
#
# [*db_connection*]
# (optional) Location of the ironic-inspector node cache database
# Defaults to 'sqlite::////var/lib/ironic-inspector/inspector.sqlite'
# Defaults to undef
#
# [*ramdisk_logs_dir*]
# (optional) Location to store logs retrieved from the ramdisk
Expand Down Expand Up @@ -190,7 +190,7 @@
$debug = undef,
$auth_strategy = 'keystone',
$dnsmasq_interface = 'br-ctlplane',
$db_connection = 'sqlite:////var/lib/ironic-inspector/inspector.sqlite',
$db_connection = undef,
$ramdisk_logs_dir = '/var/log/ironic-inspector/ramdisk/',
$enable_setting_ipmi_credentials = false,
$keep_ports = 'all',
Expand Down Expand Up @@ -229,6 +229,7 @@
include ::ironic::params
include ::ironic::pxe::common
include ::ironic::inspector::logging
include ::ironic::inspector::db

if $admin_tenant_name {
warning("Parameter 'ironic::inspector::admin_tenant_name' is deprecated and will be removed in O release. \
Expand Down Expand Up @@ -317,7 +318,6 @@
'DEFAULT/listen_address': value => $listen_address;
'DEFAULT/auth_strategy': value => $auth_strategy;
'firewall/dnsmasq_interface': value => $dnsmasq_interface;
'database/connection': value => $db_connection;
'processing/ramdisk_logs_dir': value => $ramdisk_logs_dir;
'processing/enable_setting_ipmi_credentials': value => $enable_setting_ipmi_credentials;
'processing/keep_ports': value => $keep_ports;
Expand Down Expand Up @@ -349,7 +349,7 @@
}

if $sync_db {
include ::ironic::db::inspector_sync
include ::ironic::inspector::db::sync
}

if $enabled {
Expand Down
63 changes: 63 additions & 0 deletions manifests/inspector/db.pp
@@ -0,0 +1,63 @@
# == Class: ironic::inspector::db
#
# Configure the Ironic Inspector database
#
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to 'sqlite:////var/lib/ironic-inspector/inspector.sqlite'.
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_retries*]
# Maximum db connection retries during startup.
# Setting -1 implies an infinite retry count.
# (Optional) Defaults to $::os_service_default
#
# [*database_retry_interval*]
# Interval between retries of opening a sql connection.
# (Optional) Defaults to $::os_service_default
#
# [*database_min_pool_size*]
# Minimum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_pool_size*]
# Maximum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_overflow*]
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) Defaults to $::os_service_default
#
class ironic::inspector::db (
$database_connection = 'sqlite:////var/lib/ironic-inspector/inspector.sqlite',
$database_idle_timeout = $::os_service_default,
$database_max_retries = $::os_service_default,
$database_retry_interval = $::os_service_default,
$database_min_pool_size = $::os_service_default,
$database_max_pool_size = $::os_service_default,
$database_max_overflow = $::os_service_default,
) {

include ::ironic::params

$database_connection_real = pick($::ironic::inspector::db_connection, $database_connection)

validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')

oslo::db { 'ironic_inspector_config':
connection => $database_connection_real,
idle_timeout => $database_idle_timeout,
min_pool_size => $database_min_pool_size,
max_pool_size => $database_max_pool_size,
max_retries => $database_max_retries,
retry_interval => $database_retry_interval,
max_overflow => $database_max_overflow,
}

}
69 changes: 69 additions & 0 deletions manifests/inspector/db/mysql.pp
@@ -0,0 +1,69 @@
#
# Copyright (C) 2013 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.
#
# ironic::inspector::db::mysql
#
# [*password*]
# Password to use for the ironic-inspector user
#
# [*dbname*]
# (optional) The name of the database
# Defaults to 'ironic-inspector'
#
# [*user*]
# (optional) The mysql user to create
# Defaults to 'ironic-inspector'
#
# [*host*]
# (optional) The IP address of the mysql server
# Defaults to '127.0.0.1'
#
# [*charset*]
# (optional) The charset to use for the nova database
# Defaults to 'utf8'
#
# [*collate*]
# (optional) The collate to use for the nova database
# Defaults to 'utf8_general_ci'
#
# [*allowed_hosts*]
# (optional) Additional hosts that are allowed to access this DB
# Defaults to undef
#
class ironic::inspector::db::mysql (
$password,
$dbname = 'ironic-inspector',
$user = 'ironic-inspector',
$host = '127.0.0.1',
$allowed_hosts = undef,
$charset = 'utf8',
$collate = 'utf8_general_ci',
) {

::openstacklib::db::mysql { 'ironic-inspector':
user => $user,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
}

::Openstacklib::Db::Mysql['ironic-inspector'] ~> Exec<| title == 'ironic-inspector-dbsync' |>

}
47 changes: 47 additions & 0 deletions manifests/inspector/db/postgresql.pp
@@ -0,0 +1,47 @@
# == Class: ironic::db::postgresql
#
# Class that configures postgresql for ironic-inspector
# Requires the Puppetlabs postgresql module.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'ironic-inspector'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'ironic-inspector'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
class ironic::inspector::db::postgresql(
$password,
$dbname = 'ironic-inspector',
$user = 'ironic-inspector',
$encoding = undef,
$privileges = 'ALL',
) {

Class['ironic::inspector::db::postgresql'] -> Service<| title == 'ironic-inspector' |>

::openstacklib::db::postgresql { 'ironic-inspector':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}

::Openstacklib::Db::Postgresql['ironic-inspector'] ~> Exec<| title == 'ironic-inspector-dbsync' |>

}
22 changes: 22 additions & 0 deletions manifests/inspector/db/sync.pp
@@ -0,0 +1,22 @@
#
# Class to execute ironic-inspector dbsync
#
class ironic::inspector::db::sync {

include ::ironic::deps
include ::ironic::params

exec { 'ironic-inspector-dbsync':
command => $::ironic::params::inspector_dbsync_command,
path => '/usr/bin',
user => 'ironic-inspector',
refreshonly => true,
logoutput => on_failure,
subscribe => [
Anchor['ironic-inspector::install::end'],
Anchor['ironic-inspector::config::end'],
Anchor['ironic-inspector::dbsync::begin']
],
notify => Anchor['ironic-inspector::dbsync::end'],
}
}
7 changes: 7 additions & 0 deletions releasenotes/notes/inspector-db-ddfdc7d17628f969.yaml
@@ -0,0 +1,7 @@
---
features:
- New manifest "ironic::inspector::db" for configuring ironic-inspector
oslo.db parameters.
deprecations:
- Manifest "ironic::db::inspector_sync" is deprecated, use
"ironic::inspector::db::sync" instead.
4 changes: 4 additions & 0 deletions spec/acceptance/ironic_wsgi_apache_spec.rb
Expand Up @@ -67,13 +67,17 @@ class { '::ironic::drivers::ipmi': }
warning("Ironic inspector packaging is not ready on ${::osfamily}.")
}
'RedHat': {
class { '::ironic::inspector::db::mysql':
password => 'a_big_secret',
}
class { '::ironic::inspector':
auth_uri => "https://${::fqdn}:5000/v2.0",
identity_uri => "https://${::fqdn}:35357",
admin_password => 'a_big_secret',
ironic_password => 'a_big_secret',
ironic_auth_url => "https://${::fqdn}:5000/v2.0",
dnsmasq_interface => 'eth0',
db_connection => 'mysql+pymysql://ironic-inspector:a_big_secret@127.0.0.1/ironic-inspector?charset=utf8',
}
}
}
Expand Down
44 changes: 0 additions & 44 deletions spec/classes/inspector_db_sync_spec.rb

This file was deleted.

0 comments on commit ac03904

Please sign in to comment.