File openstack-ceilometer.spec of Package openstack-ceilometer

#
# spec file for package openstack-ceilometer
#
# Copyright (c) 2014 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.1.5.a5.g4eff9a5
Release:        0
Summary:        OpenStack Metering (Ceilometer)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/ceilometer
Source:         ceilometer-stable-grizzly.tar.gz
Source1:        %{name}.init
Source2:        %{name}.logrotate
Source9:        org.openstack.ceilometer.pkla
Source13:       openstack-ceilometer-polkit.rules
Patch1:         0001-Ceilometer-may-generate-wrong-format-swift-url-in-so.patch
# PATCH-FIX-UPSTREAM speilicke@suse.com -- https://review.openstack.org/#/c/56619/
Patch2:         0001-Accept-accept-timeout-in-FakeMemcache.set.patch
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  openstack-utils
BuildRequires:  python-base
BuildRequires:  python-distribute
BuildRequires:  python-happybase >= 0.4
%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}
%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-Flask >= 0.9
Requires:       python-PyYAML
Requires:       python-SQLAlchemy >= 0.7
Requires:       python-WSME >= 0.5b1
Requires:       python-WebOb >= 1.2
Requires:       python-anyjson >= 0.2.4
Requires:       python-argparse
Requires:       python-eventlet
Requires:       python-extras
Requires:       python-glanceclient
Requires:       python-happybase >= 0.4
Requires:       python-iso8601
Requires:       python-keystoneclient >= 0.2.3
Requires:       python-kombu
Requires:       python-lockfile
Requires:       python-lxml
Requires:       python-netaddr
Requires:       python-novaclient >= 2.6.10
Requires:       python-oslo.config >= 1.1.0
Requires:       python-pecan >= 0.2.0
Requires:       python-pymongo >= 2.2
Requires:       python-requests >= 1.1
Requires:       python-sqlalchemy >= 0.7
Requires:       python-sqlalchemy-migrate >= 0.7.2
Requires:       python-stevedore >= 0.7
Requires:       python-swiftclient

%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 test
Summary:        OpenStack Metering (Ceilometer) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       mongodb
Requires:       openstack-nova-test
Requires:       python-FormEncode
Requires:       python-Ming
Requires:       python-WSME >= 0.5b1
Requires:       python-coverage
Requires:       python-glance
Requires:       python-mock
Requires:       python-mox
Requires:       python-netifaces
Requires:       python-nose
Requires:       python-nova
Requires:       python-pecan >= 0.2.0
Requires:       python-pep8 >= 1.0
Requires:       python-python-spidermonkey
Requires:       python-swift
Requires:       python-unittest2

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

%prep
%setup -q -n ceilometer-2013.1.5.a5.g4eff9a5
%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/%{component}
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{component}
install -d -m 755 %{buildroot}%{_localstatedir}/run/%{component}

### 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 agent-central agent-compute ; 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

### set default configuration (mostly applies to package-only setups and quickstart, i.e. not generally crowbar)
%define ceilometer_conf %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
openstack-config --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:
openstack-config --set %{ceilometer_conf} DEFAULT log_dir %{_localstatedir}/log/%{component}
openstack-config --set %{ceilometer_conf} DEFAULT policy_file %{_sysconfdir}/%{component}/policy.json
openstack-config --set %{ceilometer_conf} DEFAULT database_connection mongodb://localhost:27017/%{component}

### 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

%files
%defattr(-,root,root)
%doc README.md
%{_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}, %{username}) %{_localstatedir}/lib/%{component}
%dir %attr(0750, %{username}, %{username}) %{_localstatedir}/log/%{component}
%dir %attr(0700, %{username}, %{username}) %{_localstatedir}/cache/ceilometer
%ghost %dir %attr(0755, %{username}, root) %{_localstatedir}/run/%{component}

%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
%{_sbindir}/rc%{name}-collector
%{_bindir}/%{component}-collector

%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 test
%defattr(-,root,root)
%{python_sitelib}/%{component}/tests/
%{_localstatedir}/lib/%{name}-test/

%changelog
openSUSE Build Service is sponsored by