File openstack-ceilometer.spec of Package openstack-ceilometer

#
# spec file for package openstack-ceilometer
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2011 B1 Systems GmbH, Vohburg, 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 ceilometer
%define groupname openstack-%{component}
%define username openstack-%{component}

Name:           openstack-%{component}
Version:        2013.2.4.dev24.g292b4aa
Release:        0
Summary:        OpenStack Metering (Ceilometer)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/ceilometer
Source:         http://tarballs.openstack.org/ceilometer/ceilometer-stable-havana.tar.gz
Source1:        %{name}.init
Source2:        %{name}.logrotate
Source9:        org.openstack.ceilometer.pkla
%if 0%{?suse_version} > 1230
Source10:       %name.conf
BuildRequires:  systemd
%endif
Source13:       openstack-ceilometer-polkit.rules
# PATCH-FIX-SUSE: Skip testing against DB2 and Mongodb
Patch0:         0001-Skip-tests-against-real-DB.patch
Patch1:         0001-enable-sql-metadata-query.patch
# https://review.openstack.org/#q,I1818d90c135b248a28b35dc0b9f6106cf89496ab,n,z
Patch2:         reconnect-to-mongodb-on-failure.patch
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-base
BuildRequires:  python-distribute
BuildRequires:  python-happybase >= 0.4
BuildRequires:  python-pbr
%if 0%{?suse_version} > 1110
# to make orphaned-file-tests happy
BuildRequires:  polkit-default-privs
Requires:       polkit-default-privs
%endif
# Documentation build requirements:
#BuildRequires:  python-Sphinx
Requires:       logrotate
Requires:       python >= 2.6.8
Requires:       python-ceilometer = %{version}
Requires:       python-pbr >= 0.5.21
%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif
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
Ceilometer aims to deliver a unique point of contact for billing systems to
aquire all counters they need to establish customer billing, accross all
current and future OpenStack components. The delivery of counters must be
tracable and auditable, the counters must be easily extensible to support new
projects, and agents doing data collections should be independent of the
overall system.

%package -n python-ceilometer
Summary:        OpenStack Metering (Ceilometer) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.6.8
Requires:       python-Babel >= 1.3
Requires:       python-Flask >= 0.10
Requires:       python-PyYAML >= 3.1.0
Requires:       python-SQLAlchemy >= 0.7.8
Requires:       python-WSME >= 0.5b5
Requires:       python-WebOb >= 1.2.3
Requires:       python-alembic >= 0.4.1
Requires:       python-anyjson >= 0.3.3
Requires:       python-argparse
Requires:       python-ceilometerclient >= 1.0.5
Requires:       python-eventlet >= 0.13.0
Requires:       python-glanceclient >= 0.9.0
Requires:       python-happybase >= 0.4
Requires:       python-iso8601 >= 0.1.8
Requires:       python-keystoneclient >= 0.3.2
Requires:       python-kombu >= 2.4.8
Requires:       python-lxml >= 2.3
Requires:       python-msgpack-python
Requires:       python-netaddr
Requires:       python-novaclient >= 2.15.0
Requires:       python-oslo.config >= 1.2.0
Requires:       python-pecan >= 0.2.0
Requires:       python-pymongo >= 2.4
Requires:       python-requests >= 1.1
Requires:       python-six >= 1.4.1
Requires:       python-sqlalchemy-migrate >= 0.7.2
Requires:       python-stevedore >= 0.10
Requires:       python-swiftclient >= 1.5

%description -n python-ceilometer
This package contains the core Python module of %{name}.

%package api
Summary:        OpenStack Metering (Ceilometer) - API
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description api
This package contains the %{name} API server.

%package collector
Summary:        OpenStack Metering (Ceilometer) - Collector
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description collector
This package contains the %{name} collector.

%package agent-central
Summary:        OpenStack Metering (Ceilometer) - Agent Central
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description agent-central
This package contains the %{name} agent central.

%package agent-compute
Summary:        OpenStack Metering (Ceilometer) - Agent Compute
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description agent-compute
This package contains the %{name} agent compute.

%package alarm-evaluator
Summary:        OpenStack Metering (Ceilometer) - Alarm Evaluator
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description alarm-evaluator
This package contains the %{name} alarm evalutor.

%package alarm-notifier
Summary:        OpenStack Metering (Ceilometer) - Alarm Evaluator
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description alarm-notifier
This package contains the %{name} alarm evalutor.

%package test
Summary:        OpenStack Metering (Ceilometer) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       openstack-nova-test
Requires:       python-coverage >= 3.6
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-discover
%endif
Requires:       python-fixtures >= 0.3.14
Requires:       python-flake8 >= 2.0
Requires:       python-glance
Requires:       python-hacking >= 0.5.6
Requires:       python-httplib2
Requires:       python-mock >= 1.0
Requires:       python-mox >= 0.5.3
Requires:       python-nova
Requires:       python-pep8 >= 1.4.5
Requires:       python-pyflakes >= 0.7.2
Requires:       python-python-subunit
Requires:       python-sphinxcontrib-pecanwsme >= 0.5
Requires:       python-swift
Requires:       python-testrepository >= 0.0.17
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 0.9.32

%description test
This package contains testsuite files for %{name}.

%prep
%setup -q -n %{component}-%{version}
%patch0 -p1
## Currently broken, see http://lists.openstack.org/pipermail/openstack-dev/2014-February/028213.html
#%%patch1 -p1
%patch2 -p1
%openstack_cleanup_prep

%build
python setup.py build
# Currently there exists only a general man-page with the same content as the
# HTML documenation. Thus we shouldn't build it:
#python setup.py build_sphinx -b man -s doc/source

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

### directories
#TODO: Check what we need:
install -d -m 755 %{buildroot}%{_localstatedir}/{lib,log}/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/cache/%{component}
install -d -m 700 %{buildroot}%{_localstatedir}/run/%{component}
%if 0%{?suse_version} > 1230
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf
%endif

### configuration files
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{component}
install -p -D -m 644 etc/ceilometer/ceilometer.conf.sample %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
install -p -D -m 644 etc/ceilometer/{pipeline.yaml,sources.json,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}%{_initddir}
mkdir -p %{buildroot}%{_sbindir}
for i in api collector collector-udp agent-central agent-compute alarm-evaluator alarm-notifier ; do
    tmp=$(mktemp)
    cat %{SOURCE1} | sed "s/__NAME__/$i/g" > $tmp
    install -m 755 $tmp %{buildroot}%{_initddir}/%{name}-$i
    ln -s ../..%{_initddir}/%{name}-$i %{buildroot}%{_sbindir}/rc%{name}-$i
done

%if 0%{?suse_version} > 1110 && 0%{?suse_version} < 1230
  mkdir -p %{buildroot}%{_localstatedir}/lib/polkit-1/localauthority/10-vendor.d/
  cp -a %{SOURCE9} %{buildroot}%{_localstatedir}/lib/polkit-1/localauthority/10-vendor.d/
%endif

%if 0%{?suse_version} >= 1230
  install -D -m 644 %{SOURCE13} %{buildroot}%{_datadir}/polkit-1/rules.d/11-openstack-ceilometer.rules
%endif

### documentation
#install -d %%{buildroot}%%{_mandir}/man1
#install -m 644 doc/build/man/*.1 %%{buildroot}%%{_mandir}/man1

### test subpackage
%openstack_test_package_install
# Skip functional tests that require mongodb
rm %{buildroot}/var/lib/openstack-%{component}-test/tests/storage/test_impl_mongodb.py \
   %{buildroot}/var/lib/openstack-%{component}-test/tests/api/v2/test_statistics_scenarios.py

### set default configuration (mostly applies to package-only setups and quickstart, i.e. not generally crowbar)
%define ceilometer_conf %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
crudini --set %{ceilometer_conf} DEFAULT verbose True
#NOTE(saschpe): Don't set 'log_file', each ceilometer deamon will create it's own if only 'log_dir' is set:
crudini --set %{ceilometer_conf} DEFAULT log_dir %{_localstatedir}/log/%{component}
crudini --set %{ceilometer_conf} DEFAULT lock_path %{_localstatedir}/run/%{component}
crudini --set %{ceilometer_conf} keystone_authtoken signing_dir /var/cache/%component/keystone-signing
crudini --set %{ceilometer_conf} DEFAULT policy_file %{_sysconfdir}/%{component}/policy.json

### authentication cache dir
mkdir -p %{buildroot}%{_localstatedir}/cache/ceilometer

%pre
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || useradd -r -g %{groupname} -d %{_localstatedir}/lib/%{component} -s /sbin/nologin -c "OpenStack Ceilometer Daemons" %{username}
exit 0

%post api
%{fillup_and_insserv -f openstack-ceilometer-api}

%preun api
%stop_on_removal openstack-ceilometer-api

%postun api
%restart_on_update openstack-ceilometer-api
%insserv_cleanup

%post collector
%{fillup_and_insserv -f openstack-ceilometer-collector}

%preun collector
%stop_on_removal openstack-ceilometer-collector

%postun collector
%restart_on_update openstack-ceilometer-collector
%insserv_cleanup

%post agent-central
%{fillup_and_insserv -f openstack-ceilometer-agent-central}

%preun agent-central
%stop_on_removal openstack-ceilometer-agent-central

%postun agent-central
%restart_on_update openstack-ceilometer-agent-central
%insserv_cleanup

%post agent-compute
polkit-auth --grant org.libvirt.unix.monitor --user %{username} 2>/dev/null || true
%{fillup_and_insserv -f openstack-ceilometer-agent-compute}

%preun agent-compute
%stop_on_removal openstack-ceilometer-agent-compute

%postun agent-compute
%restart_on_update openstack-ceilometer-agent-compute
%insserv_cleanup

%post alarm-evaluator
%{fillup_and_insserv -f openstack-ceilometer-alarm-evaluator}

%preun alarm-evaluator
%stop_on_removal openstack-ceilometer-alarm-evaluator

%postun alarm-evaluator
%restart_on_update openstack-ceilometer-alarm-evaluator
%insserv_cleanup

%post alarm-notifier
%{fillup_and_insserv -f openstack-ceilometer-alarm-notifier}

%preun alarm-notifier
%stop_on_removal openstack-ceilometer-alarm-notifier

%postun alarm-notifier
%restart_on_update openstack-ceilometer-alarm-notifier
%insserv_cleanup

%files
%defattr(-,root,root)
%doc README.rst
%{_bindir}/ceilometer-dbsync
%dir %{_sysconfdir}/%{component}
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf
%config %{_sysconfdir}/%{component}/pipeline.yaml
%config %{_sysconfdir}/%{component}/sources.json
%config %{_sysconfdir}/%{component}/policy.json
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%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
%ghost %dir %attr(700,%{username},%{groupname}) %{_localstatedir}/run/%{component}
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_localstatedir}/run/%{component}
%endif

%files -n python-ceilometer
%defattr(-,root,root,-)
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info
# Part of test subpackage
%exclude %{python_sitelib}/%{component}/tests/

%files api
%defattr(-,root,root,-)
%{_initddir}/%{name}-api
%{_sbindir}/rc%{name}-api
%{_bindir}/%{component}-api

%files collector
%defattr(-,root,root,-)
%{_initddir}/%{name}-collector
%{_initddir}/%{name}-collector-udp
%{_sbindir}/rc%{name}-collector
%{_sbindir}/rc%{name}-collector-udp
%{_bindir}/%{component}-collector
%{_bindir}/%{component}-collector-udp
%{_bindir}/%{component}-expirer

%files agent-central
%defattr(-,root,root,-)
%{_initddir}/%{name}-agent-central
%{_sbindir}/rc%{name}-agent-central
%{_bindir}/%{component}-agent-central

%files agent-compute
%defattr(-,root,root,-)
%{_initddir}/%{name}-agent-compute
%{_sbindir}/rc%{name}-agent-compute
%{_bindir}/%{component}-agent-compute
%if 0%{?suse_version} > 1110 && 0%{?suse_version} < 1230
%{_localstatedir}/lib/polkit-1/localauthority/10-vendor.d/org.openstack.ceilometer.pkla
%endif
%if 0%{?suse_version} >= 1230
%{_datadir}/polkit-1/rules.d/11-openstack-ceilometer.rules
%endif

%files alarm-evaluator
%defattr(-,root,root,-)
%{_initddir}/%{name}-alarm-evaluator
%{_sbindir}/rc%{name}-alarm-evaluator
%{_bindir}/%{component}-alarm-evaluator

%files alarm-notifier
%defattr(-,root,root,-)
%{_initddir}/%{name}-alarm-notifier
%{_sbindir}/rc%{name}-alarm-notifier
%{_bindir}/%{component}-alarm-notifier

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

%changelog
openSUSE Build Service is sponsored by