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 %{component}
%define username %{component}

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

%define version_unconverted 2014.2.4.dev24

Name:           openstack-%{component}
Version:        2014.2.4.juno
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-juno.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
Source14:       openstack-ceilometer-expirer.cron
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-Babel
BuildRequires:  python-PasteDeploy
BuildRequires:  python-WSME
BuildRequires:  python-base
BuildRequires:  python-ceilometerclient
BuildRequires:  python-croniter
BuildRequires:  python-eventlet
BuildRequires:  python-glanceclient
BuildRequires:  python-happybase
BuildRequires:  python-jsonpath-rw
BuildRequires:  python-jsonschema
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-lxml
BuildRequires:  python-msgpack-python
BuildRequires:  python-neutronclient
BuildRequires:  python-novaclient
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.db >= 0.4.0
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.serialization
BuildRequires:  python-oslo.utils
BuildRequires:  python-oslo.vmware
BuildRequires:  python-pbr >= 0.6
BuildRequires:  python-pecan
BuildRequires:  python-posix_ipc
BuildRequires:  python-six
BuildRequires:  python-stevedore
BuildRequires:  python-swiftclient
BuildRequires:  python-tooz
%if 0%{?suse_version} > 1110
# to make orphaned-file-tests happy
BuildRequires:  polkit-default-privs
Requires:       polkit-default-privs
%else
BuildRequires:  python-ordereddict
%endif
# Documentation build requirements:
#BuildRequires:  python-Sphinx
Requires:       logrotate
Requires:       python >= 2.6.8
Requires:       python-ceilometer = %{version}
Requires:       python-pbr >= 0.6
%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif
Recommends:     cron
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-PasteDeploy >= 1.5.0
Requires:       python-PyYAML >= 3.1.0
Requires:       python-SQLAlchemy >= 0.8.4
Requires:       python-WSME >= 0.6
Requires:       python-WebOb >= 1.2.3
Requires:       python-alembic >= 0.6.4
Requires:       python-anyjson >= 0.3.3
Requires:       python-argparse
Requires:       python-ceilometerclient >= 1.0.6
Requires:       python-croniter >= 0.3.4
Requires:       python-eventlet >= 0.15.1
Requires:       python-glanceclient >= 0.14.0
Requires:       python-happybase >= 0.5
Requires:       python-iso8601 >= 0.1.9
Requires:       python-jsonpath-rw >= 1.2.0
Requires:       python-jsonschema >= 2.0.0
Requires:       python-keystoneclient >= 0.10.0
Requires:       python-keystonemiddleware >= 1.0.0
Requires:       python-lockfile >= 0.8
Requires:       python-lxml >= 2.3
Requires:       python-msgpack-python >= 0.4.0
Requires:       python-netaddr >= 0.7.12
Requires:       python-neutronclient >= 2.3.6
Requires:       python-novaclient >= 2.18.0
Requires:       python-oslo.config >= 1.4.0
Requires:       python-oslo.db >= 1.0.0
Requires:       python-oslo.messaging >= 1.4.0
Requires:       python-oslo.rootwrap >= 1.3.0
Requires:       python-oslo.serialization >= 1.0.0
Requires:       python-oslo.utils >= 1.4.0
Requires:       python-oslo.vmware >= 0.6.0
Requires:       python-pecan >= 0.5.0
Requires:       python-posix_ipc
Requires:       python-pymongo >= 2.5
Requires:       python-pysnmp >= 4.2.1
Requires:       python-pytz
Requires:       python-requests >= 2.1.0
Requires:       python-six >= 1.7.0
Requires:       python-sqlalchemy-migrate >= 0.9.1
Requires:       python-stevedore >= 1.0.0
Requires:       python-swiftclient >= 2.2.0
Requires:       python-tooz >= 0.3

%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} central agent.

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

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

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

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

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

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

%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-ceilometer-agent-central = %{version}
Requires:       openstack-ceilometer-agent-compute = %{version}
Requires:       openstack-ceilometer-agent-ipmi = %{version}
Requires:       openstack-ceilometer-api = %{version}
Requires:       openstack-ceilometer-collector = %{version}
Requires:       openstack-nova-test >= 2014.1
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-discover
%endif
Requires:       python-MySQL-python
Requires:       python-fixtures >= 0.3.14
Requires:       python-glance
Requires:       python-httplib2 >= 0.7.5
Requires:       python-mock >= 1.0
Requires:       python-mox >= 0.5.3
Requires:       python-nova
Requires:       python-oslotest >= 1.1.0
Requires:       python-python-subunit >= 0.0.18
Requires:       python-sphinxcontrib-docbookrestapi
Requires:       python-sphinxcontrib-httpdomain
Requires:       python-sphinxcontrib-pecanwsme >= 0.8
Requires:       python-swift
Requires:       python-testrepository >= 0.0.18
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 0.9.34

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

%prep
%setup -q -n %{component}-%{version_unconverted}
%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

bash tools/config/generate_sample.sh -b . -p ceilometer -o etc/ceilometer

%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}
%if 0%{?suse_version} > 1230
install -d -m 700 %{buildroot}/run/%{component}
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf
%else
install -d -m 700 %{buildroot}%{_rundir}/%{component}
%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/api_paste.ini %{buildroot}%{_sysconfdir}/%{component}/api_paste.ini
install -p -D -m 644 etc/ceilometer/{event_definitions.yaml,pipeline.yaml,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 agent-ipmi agent-notification 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

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

### 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}%{python_sitelib}/ceilometer/tests/{storage/test_impl_mongodb.py*,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 policy_file %{_sysconfdir}/%{component}/policy.json
crudini --set %{ceilometer_conf} DEFAULT lock_path %{_rundir}/%{component}
crudini --set %{ceilometer_conf} keystone_authtoken signing_dir /var/cache/%component/keystone-signing
crudini --set %{ceilometer_conf} database connection sqlite:////var/lib/ceilometer/ceilometer.db

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

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

%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

%preun agent-ipmi
%stop_on_removal openstack-ceilometer-agent-ipmi

%postun agent-ipmi
%restart_on_update openstack-ceilometer-agent-ipmi
%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

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

%preun agent-notification
%stop_on_removal openstack-ceilometer-agent-notification

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

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%{_bindir}/ceilometer-dbsync
%{_bindir}/ceilometer-send-sample
%{_bindir}/ceilometer-rootwrap
%dir %{_sysconfdir}/%{component}
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf
%config %{_sysconfdir}/%{component}/event_definitions.yaml
%config %{_sysconfdir}/%{component}/pipeline.yaml
%config %{_sysconfdir}/%{component}/policy.json
%config %{_sysconfdir}/%{component}/api_paste.ini
%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}) /run/%{component}
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_rundir}/%{component}
%endif

%files -n python-ceilometer
%defattr(-,root,root,-)
%doc LICENSE
%{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
%{_bindir}/%{component}-expirer
%config(noreplace) %{_sysconfdir}/cron.daily/openstack-ceilometer-expirer.cron

%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 agent-ipmi
%defattr(-,root,root,-)
%{_initddir}/%{name}-agent-ipmi
%{_sbindir}/rc%{name}-agent-ipmi
%{_bindir}/%{component}-agent-ipmi

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

%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