File openstack-monasca-ceilometer.spec of Package openstack-monasca-ceilometer
#
# spec file for package openstack-monasca-ceilometer
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/
#
%define component monasca-ceilometer
# ceilometer macros
%define ceilometer_name ceilometer
%define openstack_ceilometer_name openstack-%{ceilometer_name}
%define ceilometer_version 11.0.2.dev2
# ceilometer source base dir name
%define ceilometer_base %{ceilometer_name}-%{ceilometer_version}
# monasca-ceilometer macros
%define monasca_ceilometer_source_base_name monasca_ceilometer
# monasca-ceilometer source base dir name
%define monasca_ceilometer_base %{monasca_ceilometer_source_base_name}-1.8.2.dev3
# combined pkg macros
%global sname monasca-ceilometer
%define groupname %{ceilometer_name}
%define username %{ceilometer_name}
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%else
%global rdo 0
%endif
Name: openstack-monasca-ceilometer
Version: 1.8.2~dev3
Release: 0
Summary: OpenStack Ceilometer integrated with Monasca
License: Apache-2.0
Group: System/Management
URL: https://launchpad.net/monasca
Source0: monasca-ceilometer-stable-rocky.tar.gz
# ceilometer source tar
Source1: ceilometer-stable-rocky.tar.gz
Source2: %{openstack_ceilometer_name}.logrotate
Source4: %{openstack_ceilometer_name}.conf
Source5: %{openstack_ceilometer_name}-polkit.rules
# systemd service files
Source12: %{openstack_ceilometer_name}-polling.service
Source13: %{openstack_ceilometer_name}-agent-central.service
Source14: %{openstack_ceilometer_name}-agent-compute.service
Source15: %{openstack_ceilometer_name}-agent-ipmi.service
Source16: %{openstack_ceilometer_name}-agent-notification.service
Source50: monasca-ceilometer.README.config
BuildRequires: crudini
## ceilometer dependencies
BuildRequires: fdupes
BuildRequires: openstack-macros
# to make orphaned-file-tests happy
BuildRequires: polkit
BuildRequires: python-PasteDeploy
BuildRequires: python-WSME
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-jsonschema
BuildRequires: python-keystonemiddleware
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.db
BuildRequires: python-oslo.messaging
BuildRequires: python-oslo.policy
BuildRequires: python-oslo.reports
BuildRequires: python-oslo.serialization
BuildRequires: python-oslo.utils
BuildRequires: python-oslo.vmware
BuildRequires: python-pbr
BuildRequires: python-pecan
BuildRequires: python-six
BuildRequires: python-stevedore
BuildRequires: python-swiftclient
BuildRequires: python-tooz
Requires: logrotate
Requires: polkit
Requires: python >= 2.7
Requires: python-monasca-ceilometer >= %{version}
Requires: python-pbr
BuildArch: noarch
%if 0%{?suse_version}
BuildRequires: systemd-rpm-macros
Requires(pre): pwdutils
%{?systemd_requires}
%else
BuildRequires: systemd
Requires(post): systemd
Requires(postun): systemd
Requires(preun): systemd
%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.
Monasca Ceilometer (Ceilosca) is an add-on to Ceilometer which enables the
metering data to be stored in Monasca Datastore via publisher mechanism as
monasca metrics.
%package -n python-monasca-ceilometer
Summary: OpenStack Metering (Ceilometer) integrated with Monasca - Python module
Group: Development/Languages/Python
Requires: python >= 2.7
Requires: python-PasteDeploy
Requires: python-PyYAML
Requires: python-SQLAlchemy
Requires: python-WSME
Requires: python-WebOb
Requires: python-cinderclient
Requires: python-cotyledon
Requires: python-debtcollector
Requires: python-futures
Requires: python-futurist
Requires: python-glanceclient
Requires: python-jsonpath-rw
Requires: python-jsonpath-rw-ext
Requires: python-jsonschema
Requires: python-kafka-python
Requires: python-keystoneauth1
Requires: python-keystoneclient
Requires: python-keystonemiddleware
Requires: python-lxml
Requires: python-monotonic
Requires: python-msgpack
Requires: python-neutronclient
Requires: python-novaclient
Requires: python-os-xenapi
Requires: python-oslo.cache
Requires: python-oslo.concurrency
Requires: python-oslo.config
Requires: python-oslo.db
Requires: python-oslo.i18n
Requires: python-oslo.log
Requires: python-oslo.messaging
Requires: python-oslo.middleware
Requires: python-oslo.policy
Requires: python-oslo.reports
Requires: python-oslo.rootwrap
Requires: python-oslo.serialization
Requires: python-oslo.utils
Requires: python-oslo.vmware
Requires: python-pecan
Requires: python-pymongo
Requires: python-pysnmp
Requires: python-python-dateutil
Requires: python-requests
Requires: python-six
Requires: python-sqlalchemy-migrate
Requires: python-stevedore
Requires: python-swiftclient
Requires: python-tenacity
Requires: python-tooz
# python-monasca-ceilometer cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}
%if ! 0%{?rdo}
Requires: python-requests-aws
%endif
%description -n python-monasca-ceilometer
This package contains the core Python module of %{name}.
%package polling
Summary: OpenStack Metering (Ceilometer) - Polling
Group: Development/Languages/Python
Requires: %{name} = %{version}-%{release}
# openstack-monasca-ceilometer-polling cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}-polling
%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: %{name}-polling = %{version}
# openstack-monasca-ceilometer-agent-central cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}-agent-central
%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: %{name}-polling = %{version}-%{release}
# openstack-monasca-ceilometer-agent-compute cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}-agent-compute
%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}-%{release}
Requires: %{name}-polling = %{version}-%{release}
# openstack-monasca-ceilometer-agent-ipmi cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}-agent-ipmi
%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}-%{release}
Requires: ipmitool
# openstack-monasca-ceilometer-agent-notification cannot exist with openstack-ceilometer
Conflicts: %{openstack_ceilometer_name}-agent-notification
%description agent-notification
This package contains the %{name} notification agent.
%package test
Summary: OpenStack Metering (Ceilometer) - Testsuite
Group: Development/Languages/Python
Requires: %{name} = %{version}-%{release}
Requires: %{name}-agent-central = %{version}-%{release}
Requires: %{name}-agent-compute = %{version}-%{release}
Requires: %{name}-agent-ipmi = %{version}-%{release}
Requires: %{name}-polling = %{version}-%{release}
Requires: python-WebTest
Requires: python-fixtures
Requires: python-gabbi
Requires: python-mock
Requires: python-os-testr
Requires: python-os-win
Requires: python-oslotest
Requires: python-psycopg2
Requires: python-python-subunit
Requires: python-sphinxcontrib-httpdomain
Requires: python-sphinxcontrib-pecanwsme
Requires: python-swiftclient
Requires: python-testrepository
Requires: python-testscenarios
Requires: python-testtools
Conflicts: %{openstack_ceilometer_name}-test
# openstack-monasca-ceilometer-test cannot exist with openstack-ceilometer
%if 0%{?suse_version}
# FIXME: remove this conditional if and when SUSE's Nova spec is switched to
# the rpm-packaging one, which does not have a -test subpackage.
Requires: openstack-nova-test >= 12
%else
Requires: openstack-nova >= 12
%endif
%description test
This package contains testsuite files for %{name}.
%prep
# unpack monasca-ceilometer source
%autosetup -T -b 0 -n %{monasca_ceilometer_base}
%py_req_cleanup
# unpack ceilometer source
%autosetup -T -b 1 -n %{ceilometer_base}
%py_req_cleanup
# copy monasca-ceilometer source files
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/monasca_client.py ../%{ceilometer_name}*/%{ceilometer_name}/
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/monasca_opts.py ../%{ceilometer_name}*/%{ceilometer_name}/
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/opts.py ../%{ceilometer_name}*/%{ceilometer_name}/
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/service.py ../%{ceilometer_name}*/%{ceilometer_name}/
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/publisher/monasca_data_filter.py ../%{ceilometer_name}*/%{ceilometer_name}/publisher/
cp ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/publisher/monasca.py ../%{ceilometer_name}*/%{ceilometer_name}/publisher/
# copy tests
cp -r ../%{monasca_ceilometer_source_base_name}*/ceilosca/ceilometer/tests/ ../%{ceilometer_name}*/%{ceilometer_name}/
# modify setup.cfg, add monasca-ceilometer publisher
%define setup_cfg ../%{ceilometer_name}*/setup.cfg
# add monasca-ceilometer publisher to entry points
pub_list=`crudini --get %{setup_cfg} entry_points ceilometer.sample.publisher`
pub_list="$pub_list"$'\n'"monasca = ceilometer.publisher.monasca:MonascaPublisher"
crudini --set %{setup_cfg} entry_points ceilometer.sample.publisher $"$pub_list"
%build
#change to ceilometer directory
cd ../%{ceilometer_name}*/
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
#change to ceilometer directory
cd ../%{ceilometer_base}
python setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
### directories
install -d -m 755 %{buildroot}%{_localstatedir}/{lib,log}/%{ceilometer_name}
install -d -m 750 %{buildroot}%{_localstatedir}/{cache}/%{ceilometer_name}
install -d -m 700 %{buildroot}/run/%{ceilometer_name}
install -D -m 644 %{SOURCE4} %{buildroot}/%_tmpfilesdir/%{openstack_ceilometer_name}.conf
### configuration files
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{ceilometer_name}
cp %{buildroot}%{python_sitelib}/%{ceilometer_name}/pipeline/data/*.yaml %{buildroot}%{_sysconfdir}/%{ceilometer_name}
# default to using database publisher instead of gnocchi, which
# needs to be installed separately
sed -i 's/gnocchi:\/\//database:\/\//g' %{buildroot}%{_sysconfdir}/%{ceilometer_name}/pipeline.yaml
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/%{ceilometer_name}/README.config
# delete the ceilometer.conf - we generated out own with oslo-config-generator
rm %{buildroot}%{_prefix}%{_sysconfdir}/ceilometer/ceilometer.conf
rm %{buildroot}%{_prefix}%{_sysconfdir}/ceilometer/ceilometer-config-generator.conf
# for whatever reason, upstream installs config files into usr/etc/... (lint added _prefix)
mv %{buildroot}%{_prefix}/%{_sysconfdir}/%{ceilometer_name}/* %{buildroot}%{_sysconfdir}/%{ceilometer_name}/.
mv etc/ceilometer/ceilometer.conf %{buildroot}%{_sysconfdir}/%{ceilometer_name}/.
# TODO: where to put the config examples?
rm -rf %{buildroot}%{_sysconfdir}/%{ceilometer_name}/examples/
install -d -m 755 %{buildroot}%{_sysconfdir}/%{ceilometer_name}/%{ceilometer_name}.conf.d/
# bash-completion/logrotate/etc.
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{openstack_ceilometer_name}
# Install systemd unit services
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir}
install -p -D -m 444 %{SOURCE12} %{buildroot}%{_unitdir}/%{openstack_ceilometer_name}-polling.service
install -p -D -m 444 %{SOURCE13} %{buildroot}%{_unitdir}/%{openstack_ceilometer_name}-agent-central.service
install -p -D -m 444 %{SOURCE14} %{buildroot}%{_unitdir}/%{openstack_ceilometer_name}-agent-compute.service
install -p -D -m 444 %{SOURCE15} %{buildroot}%{_unitdir}/%{openstack_ceilometer_name}-agent-ipmi.service
install -p -D -m 444 %{SOURCE16} %{buildroot}%{_unitdir}/%{openstack_ceilometer_name}-agent-notification.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{openstack_ceilometer_name}-polling
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{openstack_ceilometer_name}-agent-central
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{openstack_ceilometer_name}-agent-compute
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{openstack_ceilometer_name}-agent-ipmi
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{openstack_ceilometer_name}-agent-notification
### policy kit
install -D -m 644 %{SOURCE5} %{buildroot}%{_datadir}/polkit-1/rules.d/11-%{openstack_ceilometer_name}.rules
### documentation
#install -d %%{buildroot}%%{_mandir}/man1
#install -m 644 doc/build/man/*.1 %%{buildroot}%%{_mandir}/man1
### test subpackage
#override openstack_test_package_buildroot_dir and component used by macro openstack_test_package_install
%define openstack_test_package_buildroot_dir %{buildroot}%{name}-%{version}/{_localstatedir}/lib/%{name}-test
%define component ceilometer
%openstack_test_package_install ceilometer
# reset component back to monasca-ceilometer
%define component monasca-ceilometer
### set default configuration
%define ceilometer_conf %{buildroot}%{_sysconfdir}/%{ceilometer_name}/%{ceilometer_name}.conf.d/010-%{ceilometer_name}.conf
crudini --set %{ceilometer_conf} DEFAULT log_dir %{_localstatedir}/log/%{ceilometer_name}
crudini --set %{ceilometer_conf} DEFAULT lock_path %{_rundir}/%{ceilometer_name}
# monasca-ceilometer configuration
# turn off workload partitioning
crudini --set %{ceilometer_conf} DEFAULT notifications workload_partitioning False
# Disable, otherwise Ceilosca won't process and store event data
crudini --set %{ceilometer_conf} DEFAULT notification disable_non_metric_meters False
### authentication cache dir
mkdir -p %{buildroot}%{_localstatedir}/cache/ceilometer
%pre
%openstack_pre_user_group_create %{username} %{groupname}
%post
%tmpfiles_create %{_tmpfilesdir}/%{openstack_ceilometer_name}.conf
%post polling
%systemd_post %{openstack_ceilometer_name}-polling.service
%preun polling
%systemd_preun %{openstack_ceilometer_name}-polling.service
%postun polling
%systemd_postun_with_restart %{openstack_ceilometer_name}-polling.service
%post agent-central
%systemd_post %{openstack_ceilometer_name}-agent-central.service
%preun agent-central
%systemd_preun %{openstack_ceilometer_name}-agent-central.service
%postun agent-central
%systemd_postun_with_restart %{openstack_ceilometer_name}-agent-central.service
%post agent-compute
%systemd_post %{openstack_ceilometer_name}-agent-compute.service
%preun agent-compute
%systemd_preun %{openstack_ceilometer_name}-agent-compute.service
%postun agent-compute
%systemd_postun_with_restart %{openstack_ceilometer_name}-agent-compute.service
%post agent-ipmi
%systemd_post %{openstack_ceilometer_name}-agent-ipmi.service
%preun agent-ipmi
%systemd_preun %{openstack_ceilometer_name}-agent-ipmi.service
%postun agent-ipmi
%systemd_postun_with_restart %{openstack_ceilometer_name}-agent-ipmi.service
%post agent-notification
%systemd_post %{openstack_ceilometer_name}-agent-notification.service
%preun agent-notification
%systemd_preun %{openstack_ceilometer_name}-agent-notification.service
%postun agent-notification
%systemd_postun_with_restart %{openstack_ceilometer_name}-agent-notification.service
%files
%defattr(-,root,root)
%license LICENSE
%doc README.rst
%{_bindir}/ceilometer-upgrade
%{_bindir}/ceilometer-send-sample
%{_bindir}/ceilometer-rootwrap
%dir %{_sysconfdir}/%{ceilometer_name}
%dir %{_sysconfdir}/%{ceilometer_name}/%{ceilometer_name}.conf.d/
%{_sysconfdir}/%{ceilometer_name}/README.config
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/%{ceilometer_name}.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/%{ceilometer_name}.conf.d/010-%{ceilometer_name}.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/polling.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/polling_all.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/pipeline.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/event_pipeline.yaml
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{ceilometer_name}/event_definitions.yaml
%config(noreplace) %{_sysconfdir}/logrotate.d/%{openstack_ceilometer_name}
%config %{_sysconfdir}/%{ceilometer_name}/rootwrap.conf
%dir %{_sysconfdir}/%{ceilometer_name}/rootwrap.d
%config %{_sysconfdir}/%{ceilometer_name}/rootwrap.d/ipmi.filters
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/lib/%{ceilometer_name}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{ceilometer_name}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{ceilometer_name}
%_tmpfilesdir/%{openstack_ceilometer_name}.conf
%files -n python-monasca-ceilometer
%defattr(-,root,root,-)
%{python_sitelib}/%{ceilometer_name}/
%{python_sitelib}/%{ceilometer_name}-*.egg-info
# Part of test subpackage (except the tempest tests)
%exclude %{python_sitelib}/%{ceilometer_name}/tests/unit/
%files polling
%defattr(-,root,root,-)
%{_unitdir}/%{openstack_ceilometer_name}-polling.service
%{_sbindir}/rc%{openstack_ceilometer_name}-polling
%{_bindir}/%{ceilometer_name}-polling
%files agent-central
%defattr(-,root,root,-)
%{_unitdir}/%{openstack_ceilometer_name}-agent-central.service
%{_sbindir}/rc%{openstack_ceilometer_name}-agent-central
%files agent-compute
%defattr(-,root,root,-)
%{_unitdir}/%{openstack_ceilometer_name}-agent-compute.service
%{_sbindir}/rc%{openstack_ceilometer_name}-agent-compute
%{_datadir}/polkit-1/rules.d/11-%{openstack_ceilometer_name}.rules
%files agent-ipmi
%defattr(-,root,root,-)
%{_unitdir}/%{openstack_ceilometer_name}-agent-ipmi.service
%{_sbindir}/rc%{openstack_ceilometer_name}-agent-ipmi
%files agent-notification
%defattr(-,root,root,-)
%{_unitdir}/%{openstack_ceilometer_name}-agent-notification.service
%{_sbindir}/rc%{openstack_ceilometer_name}-agent-notification
%{_bindir}/%{ceilometer_name}-agent-notification
%files test
%defattr(-,root,root)
%{python_sitelib}/%{ceilometer_name}/tests/unit/
%{_localstatedir}/lib/%{name}-test/
%changelog