File openstack-monasca-agent.spec of Package openstack-monasca-agent
#
# spec file for package openstack-monasca-agent
#
# Copyright (c) 2023 SUSE LLC
#
# 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 username monasca-agent
%define groupname monasca
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name: openstack-monasca-agent
Version: 7.0.0.0~xrc2~dev2
Release: 0
Summary: OpenStack Monasca metrics agent
License: Apache-2.0
Group: Development/Languages/Python
URL: https://wiki.openstack.org/wiki/Monasca
Source0: monasca-agent-stable-yoga.tar.gz
Source1: %{name}.sudoers
Source2: %{name}.target
Source3: %{name}.tmpfiles
Source4: %{name}.polkit
Source5: %{name}-collector.service
Source6: %{name}-forwarder.service
Source7: %{name}-statsd.service
BuildRequires: fdupes
BuildRequires: openstack-macros
BuildRequires: python3-keystoneclient
BuildRequires: python3-monascaclient
BuildRequires: python39-PyYAML
BuildRequires: python39-eventlet
BuildRequires: python39-freezegun
BuildRequires: python39-httplib2
BuildRequires: python39-mock
BuildRequires: python39-monasca-common
BuildRequires: python39-netaddr
BuildRequires: python39-ntplib
BuildRequires: python39-oslo.concurrency
BuildRequires: python39-oslo.config
BuildRequires: python39-oslo.i18n
BuildRequires: python39-oslo.middleware
BuildRequires: python39-oslo.utils
BuildRequires: python39-oslo.vmware
BuildRequires: python39-oslotest
BuildRequires: python39-psutil
BuildRequires: python39-pymongo
BuildRequires: python39-python-memcached
BuildRequires: python39-redis
BuildRequires: python39-requests
BuildRequires: python39-stevedore
BuildRequires: python39-testrepository
BuildRequires: python39-tornado
BuildRequires: sudo
Requires: python3-monasca-agent = %{version}-%{release}
BuildArch: noarch
%if 0%{?suse_version}
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires: systemd
Requires(post): systemd
Requires(postun):systemd
Requires(preun):systemd
%endif
%description
The Monasca Agent is a modern Python monitoring agent for gathering metrics and
sending them to the Monasca API.
%package -n python3-monasca-agent
Summary: Python module for monasca-agent
Group: Development/Languages/Python
Requires: python3-keystoneclient
Requires: python3-monascaclient
Requires: python3-neutronclient
Requires: python3-novaclient
Requires: python39-PyYAML
Requires: python39-eventlet
Requires: python39-httplib2
Requires: python39-keystoneauth1
Requires: python39-monasca-common
Requires: python39-netaddr
Requires: python39-ntplib
Requires: python39-oslo.concurrency
Requires: python39-oslo.config
Requires: python39-oslo.i18n
Requires: python39-oslo.utils
Requires: python39-oslo.vmware
Requires: python39-psutil
Requires: python39-pymongo
Requires: python39-python-memcached
Requires: python39-redis
Requires: python39-requests
Requires: python39-six
Requires: python39-stevedore
# FIXME(jpena): Remove this conditional once python-toml is available in RDO
%if 0%{?rdo}
Requires: python39-tornado
%else
Requires: python39-toml
Requires: python39-tornado
%endif
%description -n python3-monasca-agent
The Monasca Agent is a modern Python monitoring agent for gathering metrics and
sending them to the Monasca API.
This package contains monasca-agent Python module.
%prep
%autosetup -p1 -n monasca-agent-7.0.0.0rc2.dev2
%py_req_cleanup
# contains various binary files etc that we don't need
rm -rf packaging/monasca-agent{,-deb}
%build
%{py3_build}
%install
%{py3_install}
# /etc
install -d -m 755 %{buildroot}%{_sysconfdir}/monasca
install -d -m 750 %{buildroot}%{_sysconfdir}/monasca/agent/conf.d
# /usr/lib
install -d -m 755 %{buildroot}%{_prefix}/lib/monasca/agent/custom_checks.d
install -d -m 755 %{buildroot}%{_prefix}/lib/monasca/agent/custom_detect.d
# /var
install -d -m 750 %{buildroot}%{_localstatedir}/log/monasca-agent
# sudoers configuration
install -D -m 440 %{SOURCE1} %{buildroot}%{_sysconfdir}/sudoers.d/%{name}
# systemd unit file
install -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.target
install -D -m 644 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}-collector.service
install -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}-forwarder.service
install -D -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-statsd.service
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -sr %{buildroot}%{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif
# systemd tmpfile
install -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/openstack-monasca-agent.conf
# polkit permissions
install -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/polkit-1/rules.d/49-monasca-agent.rules
%fdupes %{buildroot}%{python3_sitelib}
%pre
# create user and groups
%openstack_pre_user_group_create %{username} %{groupname}
%post
%tmpfiles_create %{_tmpfilesdir}/openstack-monasca-agent.conf
%systemd_post %{name}.target
%systemd_post %{name}-collector.service
%systemd_post %{name}-forwarder.service
%systemd_post %{name}-statsd.service
%preun
%systemd_preun %{name}.target
%systemd_preun %{name}-collector.service
%systemd_preun %{name}-forwarder.service
%systemd_preun %{name}-statsd.service
%postun
%systemd_postun %{name}.target
%systemd_postun %{name}-collector.service
%systemd_postun %{name}-forwarder.service
%systemd_postun %{name}-statsd.service
%check
find . -type f -name *.pyc -delete
find . -type f -name '*test_service_plugin.py' -delete
python3 -m stestr.cli run
%files
%dir %attr(-, root, monasca) %{_sysconfdir}/monasca
%dir %attr(0750, %{username}, %{groupname}) %{_sysconfdir}/monasca/agent
%dir %attr(0750, %{username}, %{groupname}) %{_sysconfdir}/monasca/agent/conf.d
%dir %attr(0755, root, root) %{_prefix}/lib/monasca/agent/custom_checks.d
%dir %attr(0755, root, root) %{_prefix}/lib/monasca/agent/custom_detect.d
%_tmpfilesdir/openstack-monasca-agent.conf
%config %{_sysconfdir}/monasca/agent
%config %{_sysconfdir}/sudoers.d/%{name}
%dir %{_prefix}/lib/monasca
%{_prefix}/lib/monasca/agent
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/monasca-agent
%{_unitdir}/%{name}.target
%{_unitdir}/%{name}-collector.service
%{_unitdir}/%{name}-forwarder.service
%{_unitdir}/%{name}-statsd.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif
%{_sysconfdir}/polkit-1/
%{_sysconfdir}/polkit-1/rules.d/
%{_sysconfdir}/polkit-1/rules.d/49-monasca-agent.rules
%files -n python3-monasca-agent
%doc README.rst
%license LICENSE
%{_bindir}/monasca-collector
%{_bindir}/monasca-forwarder
%{_bindir}/monasca-setup
%{_bindir}/monasca-statsd
%{python3_sitelib}/monasca_agent
%{python3_sitelib}/monasca_agent-*.egg-info
%{python3_sitelib}/monasca_setup
%dir %{_datadir}/monasca
%{_datadir}/monasca/agent
%changelog