LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File openstack-monasca-notification.spec of Package openstack-monasca-notification (Project home:jgrassler:monasca)

#
# spec file for package openstack-monasca-notification
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#


%global sname   monasca-notification

%define username    monasca-notification
%define groupname   monasca

%define notification_conf_dir %{_sysconfdir}/%{sname}
%define notification_log_dir /var/log/%{sname}

Name:           openstack-monasca-notification
Version:        1.7.0
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:        https://pypi.io/packages/source/m/%{sname}/%{sname}-%{version}.tar.gz
Source1:        openstack-%{sname}.service
Source2:        %{sname}.yaml
BuildRequires:  openstack-macros
BuildRequires:  python-mock >= 2.0
BuildRequires:  python-monasca-common >= 1.4.0
BuildRequires:  python-monasca-statsd >= 1.1.0
BuildRequires:  python-os-testr >= 0.8.0
BuildRequires:  python-oslotest >= 1.10.0
BuildRequires:  python-pbr >= 1.8
BuildRequires:  python-requests >= 2.10.0
BuildRequires:  python-six >= 1.9.0
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(preun):    systemd
Requires(postun):   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-PyYAML >= 3.10.0
Requires:       python-monasca-common >= 1.4.0
Requires:       python-monasca-statsd >= 1.1.0
Requires:       python-requests >= 2.10.0
Requires:       python-six >= 1.9.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}-%{version}
%py_req_cleanup

%build
%py2_build

%install
%py2_install

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

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

## etc
%{__install} -d -m 755 %{buildroot}%{notification_conf_dir}
%{__install} -D -m 644 %{SOURCE2} %{buildroot}%{notification_conf_dir}/%{sname}.yaml.sample

## system stuff
%{__install} -p -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%check
export OS_TEST_PATH=./tests
find . -type f -name *.pyc -delete
PYTHONPATH=. %{__python2} setup.py testr

%pre
# create monasca group and monasca-notification user
%openstack_pre_user_group_create %{username} %{groupname} /sbin/nologin
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service
%restart_on_update %{name}.service

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

%files
%defattr(-, root, root)
%license LICENSE
%doc README.md
%{_bindir}/monasca-notification
%{_unitdir}/%{name}.service
%dir %{notification_conf_dir}
%dir %attr(750, %{username}, %{groupname}) %notification_log_dir
%config(noreplace) %attr(640, root, %{groupname}) %{notification_conf_dir}/%{sname}.yaml.sample
%{_sbindir}/rc%{name}

%files -n python-monasca-notification
%defattr(-, root, root)
%license LICENSE
%doc README.md
%{python2_sitelib}/monasca_notification
%{python2_sitelib}/*.egg-info

%changelog