File openstack-monasca-notification.spec of Package openstack-monasca-notification

#
# spec file for package openstack-monasca-notification
#
# Copyright (c) 2023 SUSE LLC
#
# 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/
#


%global sname   monasca-notification
%define username    monasca-notification
%define groupname   monasca
%define notification_conf_dir %{_sysconfdir}/monasca/
%define notification_log_dir %{_localstatedir}/log/%{sname}
Name:           openstack-monasca-notification
Version:        1.14.2~dev1
Release:        0
Summary:        Notification engine sends notifications based on alarm transitions
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://wiki.openstack.org/wiki/Monasca
Source0:        monasca-notification-stable-rocky.tar.gz
Source1:        openstack-%{sname}.service
Source3:        openstack-monasca-notification.logrotate
BuildRequires:  fdupes
BuildRequires:  openstack-macros
BuildRequires:  python-Jinja2
BuildRequires:  python-SQLAlchemy
BuildRequires:  python-keystoneauth1 >= 3.4.0
BuildRequires:  python-mock
BuildRequires:  python-monasca-common >= 2.7.0
BuildRequires:  python-monasca-statsd >= 1.4.0
BuildRequires:  python-os-testr
BuildRequires:  python-oslo.config >= 5.2.0
BuildRequires:  python-oslo.log >= 3.36.0
BuildRequires:  python-oslotest
BuildRequires:  python-pbr >= 2.0.0
BuildRequires:  python-requests >= 2.14.2
BuildRequires:  python-six >= 1.10.0
Requires:       logrotate
Requires:       python-%{sname} = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
Requires(pre):  pwdutils
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun):systemd
Requires(preun):systemd
%endif

%description
This engine reads alarms from Kafka and then notifies the customer using
their configured notification method.
Multiple notification and retry engines can run in
parallel up to one per available Kafka partition. Zookeeper
is used to negotiate access to the Kafka partitions
whenever a new process joins or leaves the working set.

%package -n python-%{sname}
Summary:        Python core module for monasca-notification
Group:          Development/Languages/Python
Requires:       python-Jinja2
Requires:       python-PyYAML >= 3.12
Requires:       python-SQLAlchemy
Requires:       python-debtcollector >= 1.2.0
Requires:       python-keystoneauth1 >= 3.4.0
Requires:       python-monasca-common >= 2.7.0
Requires:       python-monasca-statsd >= 1.4.0
Requires:       python-oslo.config >= 5.2.0
Requires:       python-oslo.log >= 3.36.0
Requires:       python-requests >= 2.14.2
Requires:       python-six >= 1.10.0

%description -n python-%{sname}
This engine reads alarms from Kafka and then notifies the customer using
their configured notification method.
Multiple notification and retry engines can run in
parallel up to one per available Kafka partition. Zookeeper
is used to negotiate access to the Kafka partitions
whenever a new process joins or leaves the working set.

This package contains the core Python module of Monasca-notification

%prep
%autosetup -n %{sname}-1.14.2.dev1
%py_req_cleanup

%build
%py2_build
PYTHONPATH=. oslo-config-generator \
  --config-file config-generator/notification.conf \
  --output-file etc/monasca/notification.conf.sample

%install
%py2_install

## usr
install -d -m 755 %{buildroot}%{_sbindir}

## log dir
install -d -m 750 %{buildroot}%{notification_log_dir}

## logrotate
install -p -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-monasca-notification.logrotate

## etc
install -d -m 755 %{buildroot}%{notification_conf_dir}
install -D -m 644 etc/monasca/notification.conf.sample %{buildroot}%{notification_conf_dir}/notification.conf

## system stuff
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%if 0%{?suse_version}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif

%fdupes %{buildroot}%{python2_sitelib}

%check
export OS_TEST_PATH=./tests
find . -type f -name *.pyc -delete
# we dont have the jira module currently
rm tests/test_jira_notification.py
export PYTHONPATH=.
# test_overriding needs jira
ostestr --black-regex '^tests.test_config.TestYamlOverriding.test_overriding'

%pre
# create monasca group and monasca-notification user
%openstack_pre_user_group_create %{username} %{groupname}

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun %{name}.service

if [ $1 -eq 0 ] ; then
  getent passwd %{username} > /dev/null
  if [ "$?" == "0" ] ; then
      userdel %{username}
  fi
fi

%files
%license LICENSE
%doc README.rst
%{_bindir}/monasca-notification
%{_unitdir}/%{name}.service
%dir %attr(-, root, %{groupname}) %{notification_conf_dir}
%config(noreplace) %attr(640, root, %{groupname}) %{notification_conf_dir}/notification.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-monasca-notification.logrotate
%dir %attr(750, %{username}, %{groupname}) %notification_log_dir
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif

%files -n python-monasca-notification
%license LICENSE
%{python2_sitelib}/monasca_notification
%{python2_sitelib}/*.egg-info

%changelog
openSUSE Build Service is sponsored by