File openstack-monasca-persister-java.spec of Package openstack-monasca-persister-java
#
# spec file for package openstack-monasca-persister-java
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright 2017 Fujitsu LIMITED
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define username monasca-persister
%define groupname monasca
%define persister_name monasca-persister
%define persister_jar_dir %{_datadir}/%{persister_name}
%define persister_cfg_dir %{_sysconfdir}/%{persister_name}
%define persister_log_dir /var/log/%{persister_name}
%define service_name openstack-monasca-persister
%define sname monasca-persister-java
%define version_unconverted 1.7.1.dev2
Name: openstack-%{sname}
Version: 1.7.1~a0~dev2
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: https://github.com/openstack/monasca-persister
Summary: Consumes metrics and alarm state transitions from message queue
License: Apache-2.0
Group: Monitoring/Tools
Source0: https://tarballs.openstack.org/monasca-persister/monasca-persister-stable-pike.tar.gz
Source1: %{name}.changes
Source2: %{service_name}.service
Source3: %{sname}.yaml
Source4: build.sh
Patch1: maven-repo-from-environment.patch
Patch2: upgrade-to-influxdb-1.1.patch
Patch3: fix-for-influxdb-1.1.patch
# https://github.com/FujitsuEnablingSoftwareTechnologyGmbH/monasca-persister/commit/23d046761425897772e866ceb1e40c5c91e5b464
Patch4: 0001-Bugfix-Parse-value_meta-information.patch
Patch5: cassandra.patch
Patch6: java-persister-defaults.patch
# https://review.opendev.org/667447
Patch7: 0001-Update-all-columns-in-metrics-on-an-update-to-refres.patch
BuildRequires: git-core
BuildRequires: java-1_8_0-openjdk
BuildRequires: java-1_8_0-openjdk-devel
BuildRequires: java-monasca-common
BuildRequires: openstack-macros
BuildRequires: openstack-monasca-persister-java-kit
Requires: java-1_8_0-openjdk
Provides: %{sname}
BuildArch: noarch
Requires(pre): pwdutils
%description
Consumes metrics and alarm state transitions from
message queue and stores them in database. Data is read from Kafka queue and
saved either in InfluxDB or Cassandra
%prep
%setup -q -n monasca-persister-%{version_unconverted}
%patch1 -p 1
%patch2 -p 1
%patch3 -p 1
%patch4 -p 1
%patch5 -p 1
%patch6 -p 1
%patch7 -p 1
cp -Rf %{_datadir}/tetra ../kit
# run_maven.sh tries to determine a git revision and for that this needs
# to run in a git repository, so make one...
git init .
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git add .
git commit -am 'Dummy commit'
%build
export PROJECT_PREFIX=$(readlink -e ..)
sh -xe %{SOURCE4} 2>&1
%install
## usr
%{__install} -d -m 755 %{buildroot}%{_sbindir}
%{__install} -d -m 755 %{buildroot}%{_unitdir}
## etc
%{__install} -d -m 755 %{buildroot}%{persister_cfg_dir}
%{__install} -D -m 644 %{S:3} %{buildroot}%{persister_cfg_dir}/%{persister_name}.yaml
## system stuff
%{__install} -p -D -m 444 %{S:2} %{buildroot}%{_unitdir}/%{service_name}.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{service_name}
## jar stuff
%{__install} -d -m 755 %{buildroot}%{persister_jar_dir}
%{__install} -D -m 644 java/target/monasca-persister-*-SNAPSHOT-shaded.jar %{buildroot}%{persister_jar_dir}/%{persister_name}.jar
## log dir
%{__install} -d -m 750 %{buildroot}%{persister_log_dir}
## sed me
sed -e "
s|__PERSISTER_USER__|%{username}|g;
s|__PERSISTER_GROUP__|%{groupname}|g;
s|__PERSISTER_JAR__|%{persister_jar_dir}/%{persister_name}.jar|g;
s|__PERSISTER_CONFIG__|%{persister_cfg_dir}/%{persister_name}.yaml|g;
s|__PERSISTER_LOGDIR__|%{persister_log_dir}|g;
" -i %{buildroot}%{_unitdir}/%{service_name}.service
sed -e "
s|__PERSISTER_LOGDIR__|%{persister_log_dir}|g;
" -i %{buildroot}%{persister_cfg_dir}/%{persister_name}.yaml
%pre
%openstack_pre_user_group_create %{username} %{groupname}
%service_add_pre %{service_name}.service
exit 0
%post
%service_add_post %{service_name}.service
cat <<EOF
Configuration:
================================================================================
Following configuration bits need to be provided prior to running monasca-persister:
- Zookeeper host&port
- Kafka host&port
- TimeBased-DB host&port
================================================================================
Dependencies:
================================================================================
monasca-persister depends on:
- Zookeeper
- Kafka
- InfluxDB or Vertica
however these dependencies does not need to be installed on the same
hosts.
================================================================================
EOF
%preun
%service_del_preun %{service_name}.service
%postun
%service_del_postun %{service_name}.service
if [ $1 -eq 0 ] ; then
getent passwd %{username} > /dev/null
if [ "$?" == "0" ] ; then
userdel %{username}
fi
fi
%files
%defattr(-, root, root)
%{_unitdir}/%{service_name}.service
%{_sbindir}/rc%{service_name}
%dir %{persister_cfg_dir}
%dir %{persister_jar_dir}
%{persister_jar_dir}/%{persister_name}.jar
%attr(0750, %{username}, %{groupname}) %dir %{persister_log_dir}
%attr(0640, root, %{groupname}) %%config(noreplace) %{persister_cfg_dir}/%{persister_name}.yaml
%changelog