File openstack-aodh.spec of Package openstack-aodh

#
# spec file for package openstack-aodh
#
# Copyright (c) 2016 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/
#


%define component aodh
%define groupname %{component}
%define username %{component}

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif

%define version_unconverted 1.1.2

Name:           openstack-%{component}
Version:        1.1.2
Release:        0
Summary:        Alarm engine of the Ceilometer project
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/aodh
Source:         http://tarballs.openstack.org/aodh/aodh-%{version}.tar.gz
Source1:        %{name}.init
Source2:        %{name}.logrotate
Source3:        %{name}-expirer.cron
%if 0%{?suse_version} > 1230
Source10:       %name.conf
BuildRequires:  systemd
%endif
Source99:       systemd-override.conf
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  openstack-suse-sudo
BuildRequires:  python-PasteDeploy
BuildRequires:  python-SQLAlchemy
BuildRequires:  python-WSME
BuildRequires:  python-WebOb
BuildRequires:  python-Werkzeug
BuildRequires:  python-alembic
BuildRequires:  python-ceilometerclient
BuildRequires:  python-croniter
BuildRequires:  python-eventlet
BuildRequires:  python-jsonschema
BuildRequires:  python-keystoneclient
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-lxml
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.context
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.i18n
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.middleware
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslo.serialization
BuildRequires:  python-oslo.service
BuildRequires:  python-oslo.utils
BuildRequires:  python-pbr
BuildRequires:  python-pecan
BuildRequires:  python-pytz
BuildRequires:  python-requests
BuildRequires:  python-retrying
BuildRequires:  python-six
BuildRequires:  python-stevedore
BuildRequires:  python-tooz
Requires:       logrotate
Requires:       openstack-suse-sudo
Requires:       python-%{component} = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
Aodh is the alarm engine of the Ceilometer project.

%package -n python-aodh
Summary:        Alarm engine of the Ceilometer project - Python module
Group:          Development/Languages/Python
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-SQLAlchemy >= 0.9.7
Requires:       python-WSME >= 0.8
Requires:       python-WebOb >= 1.2.3
Requires:       python-Werkzeug >= 0.7
Requires:       python-alembic >= 0.7.2
Requires:       python-ceilometerclient >= 1.5.0
Requires:       python-croniter >= 0.3.4
Requires:       python-eventlet >= 0.17.4
Requires:       python-jsonschema >= 2.0.0
Requires:       python-keystoneclient >= 1.6.0
Requires:       python-keystonemiddleware >= 2.2.0
Requires:       python-lxml >= 2.3
Requires:       python-oslo.config >= 1.15.0
Requires:       python-oslo.context >= 0.2.0
Requires:       python-oslo.db >= 1.12.0
Requires:       python-oslo.i18n >= 1.5.0
Requires:       python-oslo.log >= 1.2.0
Requires:       python-oslo.messaging >= 1.17.1
Requires:       python-oslo.middleware >= 1.2.0
Requires:       python-oslo.policy >= 0.5.0
Requires:       python-oslo.serialization >= 1.4.0
Requires:       python-oslo.service >= 0.1.0
Requires:       python-oslo.utils >= 1.9.0
Requires:       python-pbr >= 0.11
Requires:       python-pecan >= 0.8.0
Requires:       python-pytz >= 2013.6
Requires:       python-requests >= 2.5.2
Requires:       python-retrying >= 1.2.3
Requires:       python-six >= 1.9.0
Requires:       python-stevedore >= 1.5.0
Requires:       python-tooz >= 0.16.0

%description -n python-aodh
Aodh is the alarm engine of the Ceilometer project.

This package contains the core Python module of Aodh.

%package api
Summary:        Alarm engine of the Ceilometer project - API
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description api
Aodh is the alarm engine of the Ceilometer project.

This package contains the OpenStack Aodh API.

%package evaluator
Summary:        Alarm engine of the Ceilometer project - Evaluator
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description evaluator
Aodh is the alarm engine of the Ceilometer project.

This package contains the OpenStack Aodh Evaluator.

%package notifier
Summary:        Alarm engine of the Ceilometer project - Notifier
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description notifier
Aodh is the alarm engine of the Ceilometer project.

This package contains the OpenStack Aodh Notifier.

%package listener
Summary:        Alarm engine of the Ceilometer project - Listener
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description listener
Aodh is the alarm engine of the Ceilometer project.

This package contains the OpenStack Aodh Listener.

%package expirer
Summary:        Alarm engine of the Ceilometer project - Expirer
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description expirer
Aodh is the alarm engine of the Ceilometer project.

This package contains the OpenStack Aodh Expirer.

%package test
Summary:        Alarm engine of the Ceilometer project - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-Babel >= 1.3
Requires:       python-PyMySQL >= 0.6.2
Requires:       python-eventlet >= 0.17.4
Requires:       python-fixtures >= 1.3.1
Requires:       python-gabbi >= 0.12.0
Requires:       python-happybase >= 0.5
Requires:       python-mock >= 1.0
Requires:       python-oslotest >= 1.5.1
Requires:       python-psycopg2
Requires:       python-pymongo >= 3.0.2
Requires:       python-python-subunit >= 0.0.18
Requires:       python-reno >= 0.1.1
Requires:       python-sphinxcontrib-docbookrestapi
Requires:       python-sphinxcontrib-httpdomain
Requires:       python-sphinxcontrib-pecanwsme >= 0.8
Requires:       python-tempest-lib >= 0.6.1
Requires:       python-testrepository >= 0.0.18
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 1.4.0

%description test
The Aodh testsuite. It is used to verify the functionality of Aodh.

%prep
%setup -q -n aodh-%{version_unconverted}
%openstack_cleanup_prep

%build
python setup.py build
# python setup.py build_sphinx

%install
python setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}

### directories
install -d -m 755 %{buildroot}%{_localstatedir}/{lib,log}/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/cache/%{component}
install -d -m 700 %{buildroot}%{_rundir}/%{component}
%if 0%{?suse_version} > 1230
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf
%endif
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}

### configuration files
PYTHONPATH=. oslo-config-generator --namespace aodh \
                                   --namespace oslo.db \
                                   --namespace oslo.log \
                                   --namespace oslo.messaging \
				   --namespace oslo.policy \
				   --namespace oslo.service.service \
				   --namespace keystonemiddleware.auth_token \
				   --output-file %{_tmppath}/aodh.conf.sample
install -p -D -m 644 %{_tmppath}/aodh.conf.sample %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
install -p -D -m 644 etc/aodh/{api_paste.ini,policy.json} %{buildroot}%{_sysconfdir}/%{component}/

# bash-completion/logrotate/etc.
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

### init scripts
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_initddir}
for i in api evaluator notifier listener ; do
    install -m 755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}-$i
    sed -i -e "s/__NAME__/$i/g" %{buildroot}%{_initddir}/%{name}-$i
    ln -s ../..%{_initddir}/%{name}-$i %{buildroot}%{_sbindir}/rc%{name}-$i
    # systemd overrides
    install -D -m 644 %{SOURCE99} %{buildroot}%{_unitdir}/%{name}-$i.service.d/custom.conf
done

### cron jobs
mkdir -p %{buildroot}%{_sysconfdir}/cron.daily
install -p -m 755 %{SOURCE3} %{buildroot}%{_sysconfdir}/cron.daily

### documentation
# TODO(aplanas): patch to launch postgresql
# install -d %{buildroot}%{_mandir}/man1
# install -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1

### test subpackage
%openstack_test_package_install
%fdupes %{buildroot}%{_localstatedir}/lib/%{name}-test

### misc
%fdupes %{buildroot}%{python_sitelib}/%{component}

### set default configuration (mostly applies to package-only setups
### and quickstart, i.e. not generally crowbar)
%define aodh_conf %{buildroot}%{_sysconfdir}/aodh/aodh.conf
crudini --set %{aodh_conf} DEFAULT verbose true
crudini --set %{aodh_conf} DEFAULT log_dir /var/log/aodh

%pre
%openstack_pre_user_group_create %{username} %{groupname}

%post api
%{fillup_and_insserv -f %{name}-api}

%preun api
%stop_on_removal %{name}-api

%postun api
%restart_on_update %{name}-api
%insserv_cleanup

%post evaluator
%{fillup_and_insserv -f %{name}-evaluator}

%preun evaluator
%stop_on_removal %{name}-evaluator

%postun evaluator
%restart_on_update %{name}-evaluator
%insserv_cleanup

%post notifier
%{fillup_and_insserv -f %{name}-notifier}

%preun notifier
%stop_on_removal %{name}-notifier

%postun notifier
%restart_on_update %{name}-notifier
%insserv_cleanup

%post listener
%{fillup_and_insserv -f %{name}-listener}

%preun listener
%stop_on_removal %{name}-listener

%postun listener
%restart_on_update %{name}-listener
%insserv_cleanup

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/lib/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%if 0%{?suse_version} > 1230
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_rundir}/%{component}
%endif
%dir %{_sysconfdir}/%{component}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/api_paste.ini
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf
%config %{_sysconfdir}/%{component}/policy.json

%files -n python-%{component}
%defattr(-,root,root,-)
%doc LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info
%exclude %{python_sitelib}/%{component}/test*

%files api
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-api
%{_sbindir}/rc%{name}-api
%dir %{_unitdir}/%{name}-api.service.d/
%{_unitdir}/%{name}-api.service.d/custom.conf
%{_bindir}/%{component}-dbsync
%{_bindir}/%{component}-api

%files evaluator
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-evaluator
%{_sbindir}/rc%{name}-evaluator
%dir %{_unitdir}/%{name}-evaluator.service.d/
%{_unitdir}/%{name}-evaluator.service.d/custom.conf
%{_bindir}/%{component}-evaluator

%files notifier
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-notifier
%{_sbindir}/rc%{name}-notifier
%dir %{_unitdir}/%{name}-notifier.service.d/
%{_unitdir}/%{name}-notifier.service.d/custom.conf
%{_bindir}/%{component}-notifier

%files listener
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-listener
%{_sbindir}/rc%{name}-listener
%dir %{_unitdir}/%{name}-listener.service.d/
%{_unitdir}/%{name}-listener.service.d/custom.conf
%{_bindir}/%{component}-listener

%files expirer
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/%{component}-expirer
%config(noreplace) %{_sysconfdir}/cron.daily/%{name}-expirer.cron

%files test
%defattr(-,root,root)
%{_localstatedir}/lib/%{name}-test/
%{python_sitelib}/%{component}/test*

%changelog
openSUSE Build Service is sponsored by