File openstack-ceilometer.spec of Package openstack-ceilometer

#
# spec file for package openstack-ceilometer
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#


%define component ceilometer
%define groupname %{component}
%define username %{component}

%define version_unconverted 11.0.2.dev17

Name:           openstack-%{component}
Version:        11.0.2~dev17
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-rocky.tar.gz
Source2:        %{name}.logrotate
Source4:        %name.conf
Source5:        openstack-ceilometer-polkit.rules
# systemd service files
Source12:       %{name}-polling.service
Source13:       %{name}-agent-central.service
Source14:       %{name}-agent-compute.service
Source15:       %{name}-agent-ipmi.service
Source16:       %{name}-agent-notification.service
Source50:       README.config
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-base
BuildRequires:  python-cachetools
BuildRequires:  python-cinderclient
BuildRequires:  python-cotyledon
BuildRequires:  python-glanceclient
BuildRequires:  python-gnocchiclient
BuildRequires:  python-jsonpath-rw
BuildRequires:  python-jsonpath-rw-ext
BuildRequires:  python-lxml
BuildRequires:  python-msgpack
BuildRequires:  python-neutronclient
BuildRequires:  python-novaclient
BuildRequires:  python-openstackdocstheme
BuildRequires:  python-os-xenapi
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.reports
BuildRequires:  python-oslo.utils
BuildRequires:  python-oslo.vmware
BuildRequires:  python-pbr >= 0.6
BuildRequires:  python-six
BuildRequires:  python-stevedore
BuildRequires:  python-swiftclient
BuildRequires:  python-tooz
# to make orphaned-file-tests happy
BuildRequires:  polkit-default-privs
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
Requires:       polkit-default-privs
# Documentation build requirements:
#BuildRequires:  python-Sphinx
Requires:       logrotate
Requires:       python >= 2.7
Requires:       python-ceilometer = %{version}
Requires:       python-pbr >= 1.6
Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%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.7
Requires:       python-PyYAML >= 3.1.0
Requires:       python-cinderclient >= 1.6.0
Requires:       python-cotyledon >= 1.3.0
Requires:       python-debtcollector >= 1.2.0
Requires:       python-futures >= 3.0
Requires:       python-futurist >= 0.11.0
Requires:       python-glanceclient >= 2.0.0
Requires:       python-jsonpath-rw
Requires:       python-jsonpath-rw-ext
Requires:       python-kafka-python >= 1.3.2
Requires:       python-keystoneauth1 >= 2.1.0
Requires:       python-keystoneclient >= 1.6.0
Requires:       python-lxml >= 2.3
Requires:       python-monotonic
Requires:       python-msgpack >= 0.4.0
Requires:       python-neutronclient >= 4.2.0
Requires:       python-novaclient >= 2.29.0
Requires:       python-os-xenapi >= 0.1.1
Requires:       python-oslo.cache >= 1.5.0
Requires:       python-oslo.concurrency >= 3.5.0
Requires:       python-oslo.config >= 3.22.0
Requires:       python-oslo.i18n >= 2.1.0
Requires:       python-oslo.log >= 1.14.0
Requires:       python-oslo.messaging >= 5.12.0
Requires:       python-oslo.reports >= 0.6.0
Requires:       python-oslo.rootwrap >= 2.0.0
Requires:       python-oslo.utils >= 3.5.0
Requires:       python-oslo.vmware >= 1.16.0
Requires:       python-pysnmp >= 4.2.3
Requires:       python-requests >= 2.8.1
Requires:       python-requests-aws >= 0.1.4
Requires:       python-six >= 1.9.0
Requires:       python-stevedore >= 1.9.0
Requires:       python-swiftclient >= 2.2.0
Requires:       python-tenacity >= 3.2.1
Requires:       python-tooz >= 1.47.0

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

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

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

%package agent-central
Summary:        OpenStack Metering (Ceilometer) - Agent Central
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       openstack-ceilometer-polling = %{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}
Requires:       openstack-ceilometer-polling = %{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}
Requires:       openstack-ceilometer-polling = %{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 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-polling = %{version}
Requires:       openstack-nova-test >= 12
Requires:       python-fixtures >= 1.3.1
Requires:       python-gabbi >= 1.30.0
Requires:       python-mock >= 1.2
Requires:       python-os-testr >= 0.4.1
Requires:       python-os-win >= 0.2.3
Requires:       python-oslotest >= 2.15.0
Requires:       python-swift
Requires:       python-testrepository >= 0.0.18
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 1.4.0

%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

PYTHONPATH=. oslo-config-generator --config-file etc/ceilometer/ceilometer-config-generator.conf > etc/ceilometer/ceilometer.conf

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

### directories
#TODO: Check what we need:
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log}/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/{cache}/%{component}
install -d -m 700 %{buildroot}/run/%{component}
install -D -m 644 %{SOURCE4} %{buildroot}/%_tmpfilesdir/%name.conf

### configuration files
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{component}
cp %{buildroot}%{python_sitelib}/%{component}/pipeline/data/*.yaml %{buildroot}%{_sysconfdir}/%{component}
# default to using database publisher instead of gnocchi, which
# needs to be installed separately
sed -i 's/gnocchi:\/\//database:\/\//g' %{buildroot}%{_sysconfdir}/%{component}/pipeline.yaml
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/%{component}/README.config
# delete the ceilometer.conf - we generated out own with oslo-config-generator
rm %{buildroot}/usr/etc/ceilometer/ceilometer.conf
rm %{buildroot}/usr/etc/ceilometer/ceilometer-config-generator.conf
# for whatever reason, upstream installs config files into usr/etc/...
mv %{buildroot}/usr/%{_sysconfdir}/%{component}/* %{buildroot}%{_sysconfdir}/%{component}/.
mv etc/ceilometer/ceilometer.conf %{buildroot}%{_sysconfdir}/%{component}/.
# TODO: where to put the config examples?
rm -rf %{buildroot}%{_sysconfdir}/%{component}/examples/
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/

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

# Install systemd unit services
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir}
install -p -D -m 444 %{SOURCE12} %{buildroot}%{_unitdir}/%{name}-polling.service
install -p -D -m 444 %{SOURCE13} %{buildroot}%{_unitdir}/%{name}-agent-central.service
install -p -D -m 444 %{SOURCE14} %{buildroot}%{_unitdir}/%{name}-agent-compute.service
install -p -D -m 444 %{SOURCE15} %{buildroot}%{_unitdir}/%{name}-agent-ipmi.service
install -p -D -m 444 %{SOURCE16} %{buildroot}%{_unitdir}/%{name}-agent-notification.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-polling
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-agent-central
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-agent-compute
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-agent-ipmi
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-agent-notification

### policy kit
install -D -m 644 %{SOURCE5} %{buildroot}%{_datadir}/polkit-1/rules.d/11-openstack-ceilometer.rules

### 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
%define ceilometer_conf %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
crudini --set %{ceilometer_conf} DEFAULT log_dir %{_localstatedir}/log/%{component}
crudini --set %{ceilometer_conf} DEFAULT lock_path %{_rundir}/%{component}

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

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

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf

%pre polling
%service_add_pre %{name}-polling.service

%post polling
%service_add_post %{name}-polling.service

%preun polling
%service_del_preun %{name}-polling.service

%postun polling
%restart_on_update %{name}-polling.service
%service_del_postun %{name}-polling.service

%pre agent-central
%service_add_pre %{name}-agent-central.service

%post agent-central
%service_add_post %{name}-agent-central.service

%preun agent-central
%service_del_preun %{name}-agent-central.service

%postun agent-central
%restart_on_update %{name}-agent-central.service
%service_del_postun %{name}-agent-central.service

%pre agent-compute
%service_add_pre %{name}-agent-compute.service

%post agent-compute
%service_add_post %{name}-agent-compute.service

%preun agent-compute
%service_del_preun %{name}-agent-compute.service

%postun agent-compute
%restart_on_update %{name}-agent-compute.service
%service_del_postun %{name}-agent-compute.service

%pre agent-ipmi
%service_add_pre %{name}-agent-ipmi.service

%post agent-ipmi
%service_add_post %{name}-agent-ipmi.service

%preun agent-ipmi
%service_del_preun %{name}-agent-ipmi.service

%postun agent-ipmi
%restart_on_update %{name}-agent-ipmi.service
%service_del_postun %{name}-agent-ipmi.service

%pre agent-notification
%service_add_pre %{name}-agent-notification.service

%post agent-notification
%service_add_post %{name}-agent-notification.service

%preun agent-notification
%service_del_preun %{name}-agent-notification.service

%postun agent-notification
%restart_on_update %{name}-agent-notification.service
%service_del_postun %{name}-agent-notification.service

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%{_bindir}/ceilometer-upgrade
%{_bindir}/ceilometer-send-sample
%{_bindir}/ceilometer-rootwrap
%dir %{_sysconfdir}/%{component}
%dir %{_sysconfdir}/%{component}/%{component}.conf.d/
%{_sysconfdir}/%{component}/README.config
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/polling.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/polling_all.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/pipeline.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/event_pipeline.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/event_definitions.yaml
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config %{_sysconfdir}/%{component}/rootwrap.conf
%dir %{_sysconfdir}/%{component}/rootwrap.d
%config %{_sysconfdir}/%{component}/rootwrap.d/ipmi.filters
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/lib/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%_tmpfilesdir/%name.conf

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

%files polling
%defattr(-,root,root,-)
%{_unitdir}/%{name}-polling.service
%{_sbindir}/rc%{name}-polling
%{_bindir}/%{component}-polling

%files agent-central
%defattr(-,root,root,-)
%{_unitdir}/%{name}-agent-central.service
%{_sbindir}/rc%{name}-agent-central

%files agent-compute
%defattr(-,root,root,-)
%{_unitdir}/%{name}-agent-compute.service
%{_sbindir}/rc%{name}-agent-compute
%{_datadir}/polkit-1/rules.d/11-openstack-ceilometer.rules

%files agent-ipmi
%defattr(-,root,root,-)
%{_unitdir}/%{name}-agent-ipmi.service
%{_sbindir}/rc%{name}-agent-ipmi

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

%files test
%defattr(-,root,root)
%{python_sitelib}/%{component}/tests/unit/

%{_localstatedir}/lib/%{name}-test/

%changelog
openSUSE Build Service is sponsored by