File openstack-gnocchi.spec of Package openstack-gnocchi
#
# spec file for package openstack-gnocchi
#
# 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 gnocchi
%define groupname %{component}
%define username %{component}
%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif
%define version_unconverted 2.0.2
Name: openstack-%{component}
Version: 2.0.2
Release: 0
Summary: HTTP REST service to store metrics and index resources
License: Apache-2.0
Group: System/Management
Url: https://launchpad.net/gnocchi
Source: http://tarballs.openstack.org/gnocchi/gnocchi-%{version}.tar.gz
Source1: %{name}.init
Source2: %{name}.logrotate
%if 0%{?suse_version} > 1230
Source10: %name.conf
BuildRequires: systemd
%endif
BuildRequires: fdupes
BuildRequires: openstack-suse-macros
BuildRequires: openstack-suse-sudo
BuildRequires: python-SQLAlchemy
BuildRequires: python-base
BuildRequires: python-futures
BuildRequires: python-lz4
BuildRequires: python-numpy
BuildRequires: python-oslo.config
BuildRequires: python-oslo.db
BuildRequires: python-oslo.log
BuildRequires: python-oslo.middleware
BuildRequires: python-oslo.policy
BuildRequires: python-oslo.serialization
BuildRequires: python-oslo.utils
BuildRequires: python-oslosphinx
BuildRequires: python-pandas
BuildRequires: python-pbr
BuildRequires: python-pecan
BuildRequires: python-pytimeparse
BuildRequires: python-requests
BuildRequires: python-setuptools
BuildRequires: python-six
BuildRequires: python-swiftclient
# BuildRequires: python-SQLAlchemy-Utils
BuildRequires: python-stevedore
BuildRequires: python-tooz
# BuildRequires: python-voluptuous
BuildRequires: python-Jinja2
BuildRequires: python-PyYAML
BuildRequires: python-WebOb
BuildRequires: python-alembic
BuildRequires: python-msgpack-python
BuildRequires: python-psycopg2
BuildRequires: python-retrying
BuildRequires: python-trollius
BuildRequires: python-werkzeug
# BuildRequires: python-PyMySQL
BuildRequires: python-PasteDeploy
BuildRequires: python-keystonemiddleware
# BuildRequires: python-sphinx_bootstrap_theme
BuildRequires: python-prettytable
# Documentation build requirements:
BuildRequires: crudini
BuildRequires: python-Sphinx
Requires: logrotate
Requires: openstack-suse-sudo
Requires: python-%{component} = %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch: noarch
%endif
%description
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
%package -n python-gnocchi
Summary: HTTP REST service to store metrics and index resources - Python module
Group: Development/Languages/Python
Requires: python-Jinja2
Requires: python-PasteDeploy
Requires: python-PyMySQL
Requires: python-PyYAML
Requires: python-alembic >= 0.7.6
Requires: python-futures
Recommends: python-influxdb >= 2.4
Requires: python-keystonemiddleware >= 4.0.0
Requires: python-lz4
Requires: python-msgpack-python
Requires: python-numpy
Requires: python-oslo.config >= 2.6.0
Requires: python-oslo.db >= 1.8.0
Requires: python-oslo.log >= 1.0.0
Requires: python-oslo.middleware
Requires: python-oslo.policy >= 0.3.0
Requires: python-oslo.serialization >= 1.4.0
Requires: python-oslo.utils >= 1.6.0
Requires: python-pandas >= 0.17.0
Requires: python-pecan >= 0.9
Requires: python-prettytable
Requires: python-psycopg2
Requires: python-pytimeparse >= 1.1.5
Requires: python-requests
Requires: python-retrying
Requires: python-six
# *Requires: python-sphinx_bootstrap_theme
Requires: python-SQLAlchemy
Requires: python-SQLAlchemy-Utils
Requires: python-WebOb >= 1.4.1
Requires: python-stevedore
Requires: python-swiftclient >= 2.5.0
Requires: python-tooz >= 1.30
Requires: python-trollius
Requires: python-voluptuous
Requires: python-werkzeug
%description -n python-gnocchi
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the core Python module of Gnocchi.
%package api
Summary: HTTP REST service to store metrics and index resources - API
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description api
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the Gnocchi API.
%package carbonara
Summary: HTTP REST service to store metrics and index resources - Carbonara
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description carbonara
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the core Carbonara backend of Gnocchi.
%package indexer-sqlalchemy
Summary: HTTP REST service to store metrics and index resources - Indexer
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description indexer-sqlalchemy
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the indexer module of Gnocchi.
%package metricd
Summary: HTTP REST service to store metrics and index resources - Metricd
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description metricd
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the metricd module of Gnocchi.
%package statsd
Summary: HTTP REST service to store metrics and index resources - Statsd
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description statsd
Gnocchi is providing an HTTP REST service to store metrics and index
resources.
This package contains the statsd module of Gnocchi.
%package test
Summary: OpenStack Block Storage (Gnocchi) - Testsuite
Group: Development/Languages/Python
Requires: %{name} = %{version}
Requires: git-core
# Requires: python-MySQL-python
Requires: python-PyMySQL
Requires: python-WebTest >= 2.0.16
Requires: python-fixtures
Requires: python-gabbi >= 0.101.2
Requires: python-mock
Requires: python-oslotest
Requires: python-overtest >= 0.8.0
Requires: python-psycopg2
Requires: python-python-subunit >= 0.0.18
Requires: python-tempest-lib >= 0.2.0
Requires: python-testrepository
Requires: python-testscenarios
Requires: python-testtools >= 0.9.38
%description test
The Gnocchi testsuite. It is used to verify the functionality of
Gnocchi.
%prep
%setup -q -n gnocchi-%{version_unconverted}
%openstack_cleanup_prep
%build
python setup.py build
# TODO(aplanas): patch to launch postgresql
# ./setup-postgresql-tests.sh 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}
# for whatever reason, upstream installs config files into usr/etc/...
mv %{buildroot}/usr/%{_sysconfdir}/%{component}/* %{buildroot}%{_sysconfdir}/%{component}/.
### configuration files
PYTHONPATH=. oslo-config-generator --config-file %{_builddir}/%{component}-%{version_unconverted}/gnocchi-config-generator.conf --output-file %{_tmppath}/gnocchi.conf.sample
install -p -D -m 644 %{_tmppath}/gnocchi.conf.sample %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
install -p -D -m 644 etc/gnocchi/{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 metricd statsd ; 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
done
### 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 gnocchi_conf %{buildroot}%{_sysconfdir}/gnocchi/gnocchi.conf
crudini --set %{gnocchi_conf} DEFAULT verbose true
crudini --set %{gnocchi_conf} DEFAULT log_dir /var/log/gnocchi
# crudini --set %{gnocchi_conf} DEFAULT auth_strategy keystone
# crudini --set %{gnocchi_conf} DEFAULT rootwrap_config /etc/gnocchi/rootwrap.conf
# crudini --set %{gnocchi_conf} DEFAULT state_path /var/lib/gnocchi
# crudini --set %{gnocchi_conf} database connection sqlite:////var/lib/gnocchi/gnocchi.db
# #NOTE(saschpe): Can't hurt to set the default volume_group, only the LVM driver has a it otherwise:
# crudini --set %{gnocchi_conf} DEFAULT volume_group gnocchi-volumes
# crudini --set %{gnocchi_conf} DEFAULT lvm_type thin
# crudini --set %{gnocchi_conf} keystone_authtoken signing_dir /var/cache/%component/keystone-signing
# crudini --set %{gnocchi_conf} DEFAULT lock_path /var/run/%component
%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 metricd
%{fillup_and_insserv -f %{name}-metricd}
%preun metricd
%stop_on_removal %{name}-metricd
%postun metricd
%restart_on_update %{name}-metricd
%insserv_cleanup
%post statsd
%{fillup_and_insserv -f %{name}-statsd}
%preun statsd
%stop_on_removal %{name}-statsd
%postun statsd
%restart_on_update %{name}-statsd
%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
%{_bindir}/%{component}-api
%files carbonara
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/carbonara-dump
%files indexer-sqlalchemy
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/%{component}-upgrade
%files metricd
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-metricd
%{_sbindir}/rc%{name}-metricd
%{_bindir}/%{component}-metricd
%files statsd
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-statsd
%{_sbindir}/rc%{name}-statsd
%{_bindir}/%{component}-statsd
%files test
%defattr(-,root,root)
%{_localstatedir}/lib/%{name}-test/
%{python_sitelib}/%{component}/test*
%changelog