Decouple Fault Management from stx-config

List of changes:
1.Remove all fault management (FM) database tables from sysinv DB
2.Remove all FM commands from sysinv REST API service
3.Remove all FM CLI commands from cgts client
4.Add FM user to config controller to support region config
5.Update backup restore to reference the new alarm database table
6.Update controller config test files and add the new FM user
7.Add a FM puppet module in order to manage configuration data and
  database; to configure user, service and endpoint in Keystone
8.Add a FM puppet operator to populate FM and SNMP configuration data
9.Update NFV puppet to support FM endpoint configuration
10.Update haproxy manifest to support active-active FM API service

Story: 2002828

Task: 22747

Change-Id: I96d22a18d5872c2e5398f2e9e26a7056fe9b4e82
Signed-off-by: Tao Liu <tao.liu@windriver.com>
This commit is contained in:
Tao Liu 2018-08-15 14:07:24 -04:00
parent 4340414bb5
commit 5421df7098
84 changed files with 1749 additions and 2595 deletions

View File

@ -17,3 +17,4 @@ puppet-modules-wrs/puppet-sysinv
puppet-modules-wrs/puppet-dcorch
puppet-modules-wrs/puppet-dcmanager
puppet-modules-wrs/puppet-smapi
puppet-modules-wrs/puppet-fm

View File

@ -42,7 +42,10 @@ EXPECTED_SERVICE_NAME_AND_TYPE = (
"PANKO_SERVICE_NAME": "panko",
"PANKO_SERVICE_TYPE": "event",
"GNOCCHI_SERVICE_NAME": "gnocchi",
"GNOCCHI_SERVICE_TYPE": "metric"})
"GNOCCHI_SERVICE_TYPE": "metric",
"FM_SERVICE_NAME": "fm",
"FM_SERVICE_TYPE": "faultmanagement",
})
def is_valid_vlan(vlan):

View File

@ -992,6 +992,13 @@ class ConfigValidator(object):
gnocchi_password = get_optional(self.conf, 'REGION_2_SERVICES',
'GNOCCHI_PASSWORD')
# validate fm service name and type
get_service(self.conf, 'REGION_2_SERVICES', 'FM_SERVICE_NAME')
get_service(self.conf, 'REGION_2_SERVICES', 'FM_SERVICE_TYPE')
fm_user_name = self.conf.get('REGION_2_SERVICES', 'FM_USER_NAME')
fm_password = get_optional(self.conf, 'REGION_2_SERVICES',
'FM_PASSWORD')
if self.conf.has_option('REGION_2_SERVICES', 'USER_DOMAIN_NAME'):
user_domain = self.conf.get('REGION_2_SERVICES',
'USER_DOMAIN_NAME')
@ -1100,6 +1107,8 @@ class ConfigValidator(object):
self.cgcs_conf.set('cREGION', 'GNOCCHI_USER_NAME',
gnocchi_user_name)
self.cgcs_conf.set('cREGION', 'GNOCCHI_PASSWORD', gnocchi_password)
self.cgcs_conf.set('cREGION', 'FM_USER_NAME', fm_user_name)
self.cgcs_conf.set('cREGION', 'FM_PASSWORD', fm_password)
self.cgcs_conf.set('cREGION', 'USER_DOMAIN_NAME',
user_domain)

View File

@ -727,6 +727,12 @@ class REG2SERVICESPage2(ConfigPage):
self.fields['GNOCCHI_PASSWORD'] = Field(
text="GNOCCHI user password",
type=TYPES.string, initial="")
self.fields['FM_USER_NAME'] = Field(
text="FM username",
type=TYPES.string, initial="fm")
self.fields['FM_PASSWORD'] = Field(
text="FM user password",
type=TYPES.string, initial="")
def validate_page(self):
self.prev.validate_page()

View File

@ -71,7 +71,7 @@ def get_backup_databases(cinder_config=False):
REGION_LOCAL_DATABASES = ('postgres', 'template1', 'nova', 'sysinv',
'neutron', 'heat', 'nova_api',
'aodh', 'murano', 'magnum', 'panko', 'ironic',
'nova_cell0', 'gnocchi')
'nova_cell0', 'gnocchi', 'fm')
REGION_SHARED_DATABASES = ('glance', 'keystone')
if cinder_config:
@ -79,7 +79,7 @@ def get_backup_databases(cinder_config=False):
# Indicates which tables have to be dropped for a certain database.
DB_TABLE_SKIP_MAPPING = {
'sysinv': ('i_alarm',),
'fm': ('alarm',),
'gnocchi': ('metric', 'resource'),
'dcorch': ('orch_job',
'orch_request',

View File

@ -506,6 +506,9 @@ class ConfigAssistant():
self.mtce_ks_password = ""
self.nfv_ks_user_name = ""
self.nfv_ks_password = ""
self.fm_ks_user_name = ""
self.fm_ks_password = ""
self.ldap_region_name = ""
self.ldap_service_name = ""
self.ldap_service_uri = ""
@ -2831,6 +2834,12 @@ class ConfigAssistant():
'cREGION', 'NFV_PASSWORD')
self.add_password_for_validation('NFV_PASSWORD',
self.nfv_ks_password)
self.fm_ks_user_name = config.get(
'cREGION', 'FM_USER_NAME')
self.panko_ks_password = config.get(
'cREGION', 'FM_PASSWORD')
self.add_password_for_validation('FM_PASSWORD',
self.fm_ks_password)
self.shared_services.append(self.keystone_service_type)
if self.glance_region_name == self.region_1_name:
@ -3403,6 +3412,10 @@ class ConfigAssistant():
self.mtce_ks_user_name)
f.write("MTCE_PASSWORD=%s\n" %
self.mtce_ks_password)
f.write("FM_USER_NAME=%s\n" %
self.fm_ks_user_name)
f.write("FM_PASSWORD=%s\n" %
self.fm_ks_password)
# Subcloud configuration
if self.subcloud_config():
@ -3749,6 +3762,14 @@ class ConfigAssistant():
'capabilities': capabilities}
client.sysinv.sm_service.service_create(**values)
# fm service config
capabilities = {'user_name': self.fm_ks_user_name}
values = {'name': "fm",
'enabled': True,
'region_name': self.region_2_name,
'capabilities': capabilities}
client.sysinv.sm_service.service_create(**values)
# possible shared services (glance)
capabilities = {'service_name': self.glance_service_name,
'service_type': self.glance_service_type,
@ -3955,6 +3976,9 @@ class ConfigAssistant():
keyring.set_password('vim', constants.DEFAULT_SERVICE_PROJECT_NAME,
self.nfv_ks_password)
keyring.set_password('fm', constants.DEFAULT_SERVICE_PROJECT_NAME,
self.fm_ks_password)
del os.environ["XDG_DATA_HOME"]
def _populate_network_config(self, client):

View File

@ -55,7 +55,8 @@ EXPECTED_USERS = [
('REGION_2_SERVICES', 'AODH', 'aodh'),
('REGION_2_SERVICES', 'MTCE', 'mtce'),
('REGION_2_SERVICES', 'PANKO', 'panko'),
('REGION_2_SERVICES', 'GNOCCHI', 'gnocchi')]
('REGION_2_SERVICES', 'GNOCCHI', 'gnocchi'),
('REGION_2_SERVICES', 'FM', 'fm')]
EXPECTED_SHARED_SERVICES_NEUTRON_USER = ('SHARED_SERVICES', 'NEUTRON',
'neutron')
@ -129,6 +130,11 @@ EXPECTED_REGION2_ENDPOINTS = [
'http://{}:8041',
'http://{}:8041',
'OpenStack Metric Service'),
('FM_SERVICE_NAME', 'FM_SERVICE_TYPE',
'http://{}:18002',
'http://{}:18002',
'http://{}:18002',
'Fault Management Service'),
]
EXPECTED_NEUTRON_ENDPOINT = (

View File

@ -123,6 +123,8 @@ PANKO_USER_NAME=pankoTWO
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchiTWO
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fmTWO
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -110,6 +110,8 @@ PANKO_USER_NAME = pankoTWO
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchiTWO
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fmTWO
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = service_domain
PROJECT_DOMAIN_NAME = service_domain
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -117,6 +117,8 @@ PANKO_USER_NAME=pankoTWO
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchiTWO
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fmTWO
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -108,6 +108,8 @@ PANKO_USER_NAME = pankoTWO
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchiTWO
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fmTWO
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = Default
PROJECT_DOMAIN_NAME = Default
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -129,6 +129,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
MTCE_USER_NAME=mtce
MTCE_PASSWORD=password2WO*

View File

@ -141,6 +141,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
MTCE_USER_NAME=mtce
MTCE_PASSWORD=password2WO*

View File

@ -113,6 +113,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -113,6 +113,8 @@ PANKO_USER_NAME = panko
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchi
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fm
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = Default
PROJECT_DOMAIN_NAME = Default
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -123,6 +123,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -103,6 +103,8 @@ PANKO_USER_NAME = panko
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchi
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fm
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = Default
PROJECT_DOMAIN_NAME = Default
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -119,6 +119,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -91,6 +91,8 @@ PANKO_USER_NAME = panko
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchi
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fm
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = Default
PROJECT_DOMAIN_NAME = Default
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -119,6 +119,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -120,6 +120,8 @@ PANKO_USER_NAME=panko
PANKO_PASSWORD=password2WO*
GNOCCHI_USER_NAME=gnocchi
GNOCCHI_PASSWORD=password2WO*
FM_USER_NAME=fm
FM_PASSWORD=password2WO*
[VERSION]
RELEASE = 18.04

View File

@ -91,6 +91,8 @@ PANKO_USER_NAME = panko
PANKO_PASSWORD = password2WO*
GNOCCHI_USER_NAME = gnocchi
GNOCCHI_PASSWORD = password2WO*
FM_USER_NAME = fm
FM_PASSWORD = password2WO*
USER_DOMAIN_NAME = Default
PROJECT_DOMAIN_NAME = Default
KEYSTONE_AUTH_URI = http://192.168.204.12:8081/keystone/main/v2.0

View File

@ -21,6 +21,7 @@ Requires: puppet-patching
Requires: puppet-sysinv
Requires: puppet-sshd
Requires: puppet-smapi
Requires: puppet-fm
# Openstack puppet modules
Requires: puppet-aodh

View File

@ -524,3 +524,13 @@ dcorch::debug: false
dcmanager::use_syslog: true
dcmanager::log_facility: 'local2'
dcmanager::debug: false
#FM
fm::use_syslog: true
fm::log_facility: 'local2'
fm::api::enable_proxy_headers_parsing: true
fm::db::sync::user: 'root'
fm::database_idle_timeout: 60
fm::database_max_overflow: 20
fm::database_max_pool_size: 1

View File

@ -62,6 +62,9 @@ include ::platform::influxdb
include ::platform::influxdb::logrotate
include ::platform::collectd
include ::platform::fm
include ::platform::fm::api
include ::openstack::client
include ::openstack::keystone
include ::openstack::keystone::api

View File

@ -325,6 +325,7 @@ class openstack::keystone::endpoint::runtime {
include ::sysinv::keystone::auth
include ::patching::keystone::auth
include ::nfv::keystone::auth
include ::fm::keystone::auth
include ::openstack::aodh::params
if $::openstack::aodh::params::service_enabled {

View File

@ -0,0 +1,101 @@
class platform::fm::params (
$api_port = 18002,
$api_host = undef,
$region_name = undef,
$system_name = undef,
$service_create = false,
$service_enabled = true,
$trap_destinations = [],
$sysinv_catalog_info = 'platform:sysinv:internalURL',
) { }
class platform::fm::config
inherits ::platform::fm::params {
$trap_dest_str = join($trap_destinations,',')
class { '::fm':
region_name => $region_name,
system_name => $system_name,
trap_destinations => $trap_dest_str,
sysinv_catalog_info => $sysinv_catalog_info,
}
}
class platform::fm
inherits ::platform::fm::params {
include ::fm::client
include ::fm::keystone::authtoken
include ::platform::fm::config
include ::platform::params
if $::platform::params::init_database {
include ::fm::db::postgresql
}
}
class platform::fm::firewall
inherits ::platform::fm::params {
platform::firewall::rule { 'fm-api':
service_name => 'fm',
ports => $api_port,
}
}
class platform::fm::haproxy
inherits ::platform::fm::params {
include ::platform::haproxy::params
platform::haproxy::proxy { 'fm-api-internal':
server_name => 's-fm-api-internal',
public_ip_address => $::platform::haproxy::params::private_ip_address,
public_port => $api_port,
private_ip_address => $api_host,
private_port => $api_port,
public_api => false,
}
platform::haproxy::proxy { 'fm-api-public':
server_name => 's-fm-api-public',
public_port => $api_port,
private_port => $api_port,
}
}
class platform::fm::api
inherits ::platform::fm::params {
include ::platform::params
if $service_enabled {
if ($::platform::fm::service_create and
$::platform::params::init_keystone) {
include ::fm::keystone::auth
}
include ::platform::params
class { '::fm::api':
host => $api_host,
workers => $::platform::params::eng_workers,
sync_db => $::platform::params::init_database,
}
include ::platform::fm::firewall
include ::platform::fm::haproxy
}
}
class platform::fm::runtime {
require ::platform::fm::config
exec { 'notify-fm-mgr':
command => "/usr/bin/pkill -HUP fmManager",
onlyif => "pgrep fmManager"
}
}

View File

@ -19,6 +19,7 @@ define platform::haproxy::proxy (
$client_timeout = undef,
$x_forwarded_proto = true,
$enable_https = undef,
$public_api = true,
) {
include ::platform::haproxy::params
@ -29,7 +30,7 @@ define platform::haproxy::proxy (
}
if $x_forwarded_proto {
if $https_enabled {
if $https_enabled and $public_api {
$ssl_option = 'ssl crt /etc/ssl/private/server-cert.pem'
$proto = 'X-Forwarded-Proto:\ https'
# The value of max-age matches lighttpd.conf, and should be
@ -135,6 +136,7 @@ class platform::haproxy::runtime {
include ::platform::sysinv::haproxy
include ::platform::nfv::haproxy
include ::platform::ceph::haproxy
include ::platform::fm::haproxy
if $::platform::params::distributed_cloud_role =='systemcontroller' {
include ::platform::dcmanager::haproxy
include ::platform::dcorch::haproxy

View File

@ -211,6 +211,7 @@ class platform::postgresql::upgrade
include ::sysinv::db::postgresql
include ::keystone::db::postgresql
include ::ironic::db::postgresql
include ::fm::db::postgresql
}

View File

@ -60,12 +60,6 @@ class platform::sysinv
'sysinv %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s';
}
$sysinv_db_connection = $::sysinv::database_connection
file { "/etc/fm.conf":
ensure => 'present',
content => template('platform/fm.conf.erb'),
}
if str2bool($::is_initial_config_primary) {
$software_version = $::platform::params::software_version

View File

@ -1,9 +0,0 @@
###################################################
#
# fm.conf
#
# The configuration file for the fmManager process.
#
###################################################
event_log_max_size=4000
sql_connection=<%= @sysinv_db_connection %>

View File

@ -0,0 +1,6 @@
[snmp]
<%- @trap_destinations.each do |destination| -%>
trap2sink=<%= destination %>
<%- end -%>

View File

@ -0,0 +1,2 @@
Name: puppet-fm
Version: 1.0.0

View File

@ -0,0 +1,3 @@
SRC_DIR="src"
COPY_LIST="$SRC_DIR/LICENSE"
TIS_PATCH_VER=1

View File

@ -0,0 +1,34 @@
%global module_dir fm
Name: puppet-%{module_dir}
Version: 1.0.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: Puppet FM module
License: Apache-2.0
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: %{name}-%{version}.tar.gz
Source1: LICENSE
BuildArch: noarch
BuildRequires: python2-devel
%description
A puppet module for Fault Management
%prep
%autosetup -c %{module_dir}
#
# The src for this puppet module needs to be staged to puppet/modules
#
%install
install -d -m 0755 %{buildroot}%{_datadir}/puppet/modules/%{module_dir}
cp -R %{name}-%{version}/%{module_dir} %{buildroot}%{_datadir}/puppet/modules
%files
%license %{name}-%{version}/LICENSE
%{_datadir}/puppet/modules/%{module_dir}

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@ -0,0 +1,27 @@
Puppet::Type.type(:fm_api_paste_ini).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def self.file_path
'/etc/fm/api-paste.ini'
end
# this needs to be removed. This has been replaced with the class method
def file_path
self.class.file_path
end
end

View File

@ -0,0 +1,10 @@
Puppet::Type.type(:fm_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def self.file_path
'/etc/fm/fm.conf'
end
end

View File

@ -0,0 +1,43 @@
Puppet::Type.newtype(:fm_api_paste_ini) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/fm/api_paste.ini'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
defaultto false
end
end

View File

@ -0,0 +1,51 @@
Puppet::Type.newtype(:fm_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from fm.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
newvalues(/^[\S ]*$/)
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
defaultto false
end
newparam(:ensure_absent_val) do
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'fm-rest-api'
end
end

View File

@ -0,0 +1,109 @@
# Installs & configure the fm api service
#
# == Parameters
#
# [*enabled*]
# (optional) Should the service be enabled.
# Defaults to true
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*host*]
# (optional) The fm api bind address.
# Defaults to 0.0.0.0
#
# [*port*]
# (optional) The fm api port.
# Defaults to 18002
#
# [*package_ensure*]
# (optional) ensure state for package.
# Defaults to 'present'
#
# [*service_name*]
# (optional) Name of the service that will be providing the
# server functionality of fm-api.
#
# [*sync_db*]
# (optional) Run gnocchi-upgrade db sync on api nodes after installing the package.
# Defaults to false
#
# [*auth_strategy*]
# (optional) Type of authentication to be used.
# Defaults to 'keystone'
#
# [*enable_proxy_headers_parsing*]
# (Optional) Enable paste middleware to handle SSL requests through
# HTTPProxyToWSGI middleware.
# Defaults to $::os_service_default.
#
# [*paste_config*]
# (Optional) Configuration file for WSGI definition of API
# Defaults to $::os_service_default.
#
class fm::api (
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$host = '0.0.0.0',
$port = '18002',
$workers = 1,
$service_name = $::fm::params::api_service,
$sync_db = false,
$auth_strategy = 'keystone',
$enable_proxy_headers_parsing = $::os_service_default,
$paste_config = '/etc/fm/api-paste.ini',
) inherits fm::params {
include ::fm::deps
include ::fm::params
if $auth_strategy == 'keystone' {
include ::fm::keystone::authtoken
}
package { 'fm-api':
ensure => $package_ensure,
name => $::fm::params::api_package,
tag => 'fm-package',
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
if $sync_db {
include ::fm::db::sync
}
if $service_name == $::fm::params::api_service {
service { 'fm-api':
ensure => $service_ensure,
name => $::fm::params::api_service,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'fm-service',
}
} else {
fail("Invalid service_name. fm-api for running as a standalone service")
}
fm_config {
'api/bind_host': value => $host;
'api/bind_port': value => $port;
'api/api_workers': value => $workers;
'api/api_paste_config': value => $paste_config;
}
oslo::middleware { 'fm_config':
enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
}
}

View File

@ -0,0 +1,22 @@
#
# Installs the fm python client.
#
# == parameters
# [*ensure*]
# (optional) Ensure state of the package.
# Defaults to 'present'.
#
class fm::client (
$ensure = 'present'
) {
include ::fm::deps
include ::fm::params
package { 'fmclient':
ensure => $ensure,
name => $::fm::params::client_package,
tag => 'fmclient',
}
}

View File

@ -0,0 +1,78 @@
# == Class: fm::db
#
# Configure the fm database
#
# === Parameters
#
# [*database_db_max_retries*]
# (optional) Maximum retries in case of connection error or deadlock error
# before error is raised. Set to -1 to specify an infinite retry count.
# Defaults to $::os_service_default
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to "sqlite:////var/lib/fm/fm.sqlite".
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (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_retries*]
# Maximum number of database 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 database connection.
# (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 fm::db (
$database_db_max_retries = $::os_service_default,
$database_connection = 'sqlite:////var/lib/fm/fm.sqlite',
$database_idle_timeout = $::os_service_default,
$database_min_pool_size = $::os_service_default,
$database_max_pool_size = $::os_service_default,
$database_max_retries = $::os_service_default,
$database_retry_interval = $::os_service_default,
$database_max_overflow = $::os_service_default,
) {
include ::fm::deps
$database_connection_real = pick($::fm::database_connection, $database_connection)
$database_idle_timeout_real = pick($::fm::database_idle_timeout, $database_idle_timeout)
$database_min_pool_size_real = pick($::fm::database_min_pool_size, $database_min_pool_size)
$database_max_pool_size_real = pick($::fm::database_max_pool_size, $database_max_pool_size)
$database_max_retries_real = pick($::fm::database_max_retries, $database_max_retries)
$database_retry_interval_real = pick($::fm::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::fm::database_max_overflow, $database_max_overflow)
oslo::db { 'fm_config':
db_max_retries => $database_db_max_retries,
connection => $database_connection_real,
idle_timeout => $database_idle_timeout_real,
min_pool_size => $database_min_pool_size_real,
max_pool_size => $database_max_pool_size_real,
max_retries => $database_max_retries_real,
retry_interval => $database_retry_interval_real,
max_overflow => $database_max_overflow_real,
}
# set up the connection string for FM Manager
$sql_connection = regsubst($database_connection_real,'^postgresql+psycopg2:','postgresql:')
fm_config {
'DEFAULT/sql_connection': value => $sql_connection;
}
}

View File

@ -0,0 +1,75 @@
# The fm::db::mysql class implements mysql backend for fm
#
# This class can be used to create tables, users and grant
# privileges for a mysql fm database.
#
# == parameters
#
# [*password*]
# (Mandatory) Password to connect to the database.
# Defaults to 'false'.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'fm'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'fm'.
#
# [*host*]
# (Optional) The default source host user is allowed to connect from.
# Defaults to '127.0.0.1'
#
# [*allowed_hosts*]
# (Optional) Other hosts the user is allowed to connect from.
# Defaults to 'undef'.
#
# [*charset*]
# (Optional) The database charset.
# Defaults to 'utf8'
#
# [*collate*]
# (Optional) The database collate.
# Only used with mysql modules >= 2.2.
# Defaults to 'utf8_general_ci'
#
# == Dependencies
# Class['mysql::server']
#
# == Examples
#
# == Authors
#
# == Copyright
#
class fm::db::mysql(
$password,
$dbname = 'fm',
$user = 'fm',
$host = '127.0.0.1',
$charset = 'utf8',
$collate = 'utf8_general_ci',
$allowed_hosts = undef
) {
#include ::fm::deps
validate_string($password)
::openstacklib::db::mysql { 'fm':
user => $user,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
}
Anchor['fm::db::begin']
~> Class['fm::db::mysql']
~> Anchor['fm::db::end']
}

View File

@ -0,0 +1,57 @@
# == Class: fm::db::postgresql
#
# Class that configures postgresql for fm
# Requires the Puppetlabs postgresql module.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'fm'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'fm'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
# == Dependencies
#
# == Examples
#
# == Authors
#
# == Copyright
#
class fm::db::postgresql(
$password,
$dbname = 'fm',
$user = 'fm',
$encoding = undef,
$privileges = 'ALL',
) {
include ::fm::deps
::openstacklib::db::postgresql { 'fm':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
Anchor['fm::db::begin']
~> Class['fm::db::postgresql']
~> Anchor['fm::db::end']
}

View File

@ -0,0 +1,30 @@
#
# Class to execute "fm-dbsync"
#
# [*user*]
# (optional) User to run dbsync command.
# Defaults to 'fm'
#
class fm::db::sync (
$user = 'fm',
){
include ::fm::deps
exec { 'fm-db-sync':
command => 'fm-dbsync --config-file /etc/fm/fm.conf',
path => '/usr/bin',