File openstack-monasca-thresh.spec of Package openstack-monasca-thresh
#
# spec file for package openstack-monasca-thresh
#
# Copyright (c) 2017 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 http://bugs.opensuse.org/
#
%define tarball_version 1.3.0
%define jar_version %{version}-SNAPSHOT
%define username %{sname}
%define groupname storm
%define thresh_bin_dir %{_datadir}/%{sname}
%define thresh_cfg_dir %{_sysconfdir}/%{sname}
%define thresh_topology thresh-cluster
%define sname monasca-thresh
Name: openstack-%{sname}
Version: 2.1.1
Release: 0
Summary: Thresholding Engine of monasca based on Storm
License: Apache-2.0
Group: Monitoring/Tools
Url: https://github.com/openstack/monasca-thresh
Patch0: maven-repo-from-environment.patch
Source0: https://github.com/openstack/monasca-thresh/archive/%{tarball_version}.tar.gz
Source1: monasca-thresh-wrapper
Source2: %{name}.changes
Source3: %{name}.service
Source4: monasca-thresh.yaml
Source5: build.sh
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: %{name}-kit == %{version}
BuildRequires: java-1_8_0-openjdk-devel
BuildRequires: java-monasca-common
BuildRequires: storm-nimbus
BuildRequires: systemd-rpm-macros
BuildRequires: xz
Provides: %{sname}
Requires: java-1_8_0-openjdk
Requires: storm-nimbus
%systemd_requires
BuildArch: noarch
%description
Computes thresholds on metrics and publishes alarms to Kafka when exceeded.
The current state is also saved in the database.
Based on Apache Storm, a free and open distributed real-time computation system.
Also uses Apache Kafka, a high-throughput distributed messaging system.
%prep
%setup -q -c -n src
%patch0 -p 2
cp -f %{SOURCE1} .
cp -f %{SOURCE2} .
cp -f %{SOURCE3} .
cp -f %{SOURCE4} .
cp -f %{SOURCE5} .
cp -Rf %{_datadir}/tetra ../kit
%build
export TARBALL_VERSION=%{tarball_version}
sh build.sh
%install
## usr
%{__install} -d -m 755 %{buildroot}%{_sbindir}
%{__install} -d -m 755 %{buildroot}%{_unitdir}
## etc
%{__install} -d -m 755 %{buildroot}%{thresh_cfg_dir}
%{__install} -D -m 644 %{S:4} %{buildroot}%{thresh_cfg_dir}/thresh.yaml
## system stuff
%{__install} -p -D -m 444 %{S:3} %{buildroot}%{_unitdir}/%{name}.service
%{__install} -p -D -m 444 %{S:1} %{buildroot}%{_sbindir}/%{sname}-wrapper
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
chmod +x %{buildroot}%{_sbindir}/%{sname}-wrapper
## jar stuff
export NO_BRP_CHECK_BYTECODE_VERSION=true
%{__install} -d -m 755 %{buildroot}%{thresh_bin_dir}
cp -a %{sname}-%{tarball_version}/thresh/target/%{sname}-%{jar_version}-shaded.jar %{buildroot}%{thresh_bin_dir}/%{sname}-%{jar_version}-shaded.jar
# Create symlink to the shaded jar so we won't have to update the wrapper for each version increase
ln -sr %{buildroot}%{thresh_bin_dir}/%{sname}-%{jar_version}-shaded.jar %{buildroot}%{thresh_bin_dir}/thresh.jar
## sed values into wrapper
sed -e "
s|__THRESH_USER__|%{username}|g;
s|__THRESH_DIR__|%{thresh_bin_dir}|g;
s|__THRESH_CONFIG_DIR__|%{thresh_cfg_dir}|g;
s|__THRESH_TOPOLOGY__|%{thresh_topology}|g;
" -i %{buildroot}%{_sbindir}/%{sname}-wrapper
sed -e "
s|__THRESH_WRAPPER__|%{_sbindir}/%{sname}-wrapper|g
" -i %{buildroot}%{_unitdir}/%{name}.service
%pre
groupadd --system %{groupname} 2> /dev/null || :
useradd -r -g %{groupname} \
-d %{_localstatedir}/lib/%{name} \
-s /sbin/nologin \
-c "user for %{name} service" %{username} \
2> /dev/null || :
%service_add_pre %{name}.service
exit 0
%post
%service_add_post %{name}.service
cat <<EOF
================================================================================
monasca-thresh depends on:
- zookeeper
- kafka
- statsd
- MySQL or PostgreSQL
however these dependencies does not need to be installed on the same
hosts.
================================================================================
EOF
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
if [ $1 -eq 0 ] ; then
getent passwd %{username} > /dev/null
if [ "$?" == "0" ] ; then
userdel %{username}
fi
fi
%files
%defattr(-,root,root)
%{_unitdir}/%{name}.service
%{_sbindir}/%{sname}-wrapper
%{_sbindir}/rc%{name}
%attr(0750, root, %{groupname}) %dir %{thresh_cfg_dir}
%dir %{thresh_bin_dir}
%attr(0640, root, %{groupname}) %config(noreplace) %{thresh_cfg_dir}/thresh.yaml
%{thresh_bin_dir}/%{sname}-%{jar_version}-shaded.jar
%{thresh_bin_dir}/thresh.jar
%changelog