File openstack-masakari-monitors.spec of Package openstack-masakari-monitors

#
# spec file for package openstack-masakari-monitors
#
# Copyright (c) 2020 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/
#


%global sname masakari-monitors
%global python_pkg python-%{sname}
Name:           openstack-masakari-monitors
Version:        6.0.1~dev4
Release:        0
Summary:        Monitors for Virtual Machine High Availability (VMHA) service in OpenStack
License:        Apache-2.0
Group:          Development/Libraries
URL:            https://launchpad.net/masakari-monitors
# basename filter prevents OBS from downloading the source itself which would
# fetch from a stale cache hashed by non-changing URL.
Source0:        masakari-monitors-stable-rocky.tar.gz
Source1:        masakari-hostmonitor.service
Source2:        masakari-instancemonitor.service
Source3:        masakari-processmonitor.service
Source4:        masakari-monitors.tmpfiles
Source5:        masakari-introspectiveinstancemonitor.service
BuildRequires:  openstack-macros
BuildRequires:  python-ddt
BuildRequires:  python-eventlet
BuildRequires:  python-keystoneauth1
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-libvirt-python
BuildRequires:  python-masakariclient
BuildRequires:  python-microversion_parse
BuildRequires:  python-novaclient
BuildRequires:  python-openstackclient
BuildRequires:  python-openstacksdk
BuildRequires:  python-oslo.concurrency
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.i18n
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.middleware
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslo.privsep
BuildRequires:  python-oslo.service
BuildRequires:  python-oslo.versionedobjects
BuildRequires:  python-oslotest
BuildRequires:  python-python-subunit
BuildRequires:  python-reno
BuildRequires:  python-requests-mock
BuildRequires:  python-taskflow
BuildRequires:  python-testrepository
BuildRequires:  python-testresources
BuildRequires:  python-testscenarios
BuildRequires:  python-testtools
Requires:       python-masakari-monitors = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%else
BuildRequires:  systemd
%endif

%description
Monitors for the Masakari service for Virtual Machine
High Availability (VMHA) service in OpenStack.

System package - %{name}
Python package - %{python_pkg}

%package        doc
Summary:        Documentation for OpenStack Masakari Service
Group:          Development/Libraries
BuildRequires:  git
BuildRequires:  openstack-tempest
BuildRequires:  python-Sphinx
BuildRequires:  python-WSME
BuildRequires:  python-jsonschema
BuildRequires:  python-networkx
BuildRequires:  python-oslosphinx
BuildRequires:  python-paramiko
BuildRequires:  python-pecan
BuildRequires:  python-pep8
BuildRequires:  python-sphinxcontrib-httpdomain
BuildRequires:  python-sphinxcontrib-pecanwsme
BuildRequires:  python-yaql

%description    doc
Monitors for the Masakari service for Virtual Machine
High Availability (VMHA) service in OpenStack.

This package contains the documentation.

%package -n     %{python_pkg}
Summary:        masakari-monitors Python libraries
Group:          Development/Libraries
Requires:       python-Babel
Requires:       python-iso8601
Requires:       python-jsonschema
Requires:       python-keystoneauth1
Requires:       python-keystonemiddleware
Requires:       python-masakariclient
Requires:       python-microversion_parse
Requires:       python-novaclient
Requires:       python-openstacksdk
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.privsep
Requires:       python-oslo.service
Requires:       python-oslo.utils
Requires:       python-oslo.versionedobjects
Requires:       python-pbr
Requires:       python-setuptools
Requires:       python-six
Requires:       python-stevedore
Requires:       python-taskflow

%description -n python-%{sname}
Masakari is a service providing high availability for VMs in OpenStack.

This package contains the Python libraries for the monitoring components.

%package -n openstack-masakari-hostmonitor
Summary:        Host monitoring component of OpenStack Masakari service
Group:          Development/Libraries
Requires:       %{name} = %{version}

%description -n openstack-masakari-hostmonitor
This component of the Masakari service for VM HA in OpenStack is
responsible for monitoring the health of nova-compute hypervisors.

%package -n openstack-masakari-instancemonitor
Summary:        Instance monitoring component of OpenStack Masakari service
Group:          Development/Libraries
Requires:       %{name} = %{version}

%description -n openstack-masakari-instancemonitor
This component of the Masakari service for VM HA in OpenStack is
responsible for monitoring the health of individual VM instances.

%package -n openstack-masakari-introspectiveinstancemonitor
Summary:        Instance monitoring component of OpenStack Masakari service
Group:          Development/Libraries
Requires:       %{name} = %{version}

%description -n openstack-masakari-introspectiveinstancemonitor
This component of the Masakari service for VM HA in OpenStack is
responsible for monitoring the health of individual VM instances.

%package -n openstack-masakari-processmonitor
Summary:        Process monitoring component of OpenStack Masakari service
Group:          Development/Libraries
Requires:       %{name} = %{version}

%description -n openstack-masakari-processmonitor
This component of the Masakari service for VM HA in OpenStack is
responsible for monitoring the health of processes which need to stay
running in order for the compute plane to be functional and highly
available.

%prep
%autosetup -n %{sname}-6.0.1.dev4
%py_req_cleanup

%build
%{py2_build}
export PYTHONPATH="."
# from tox.ini's testenv:genconfig
oslo-config-generator --config-file etc/masakarimonitors/masakarimonitors-config-generator.conf

%{__python2} setup.py build_sphinx
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py2_install}

mkdir -p %{buildroot}%{_sysconfdir}/masakarimonitors/
mkdir -p %{buildroot}%{_localstatedir}/log/masakari-monitors

# These are broken (hard-coded references to /usr/local/lib/python2.7)
# and provide nothing which can't be handled better by systemd,
# so we'll use systemd services instead.
rm %{buildroot}%{_bindir}/masakari-{host,process}monitor.sh*

#systemd unitfiles
install -p -D -m 644 %SOURCE1 %{buildroot}%{_unitdir}/openstack-masakari-hostmonitor.service
install -p -D -m 644 %SOURCE2 %{buildroot}%{_unitdir}/openstack-masakari-instancemonitor.service
install -p -D -m 644 %SOURCE3 %{buildroot}%{_unitdir}/openstack-masakari-processmonitor.service
install -p -D -m 644 %SOURCE5 %{buildroot}%{_unitdir}/openstack-masakari-introspectiveinstancemonitor.service

install -p -D -m 644 %SOURCE4 %{buildroot}/%{_tmpfilesdir}/masakari-monitors.conf

install -p -D -m 640 etc/masakarimonitors/masakarimonitors.conf.sample %{buildroot}%{_sysconfdir}/masakarimonitors/masakarimonitors.conf
install -p -D -m 640 etc/masakarimonitors/hostmonitor.conf.sample %{buildroot}%{_sysconfdir}/masakarimonitors/hostmonitor.conf
install -p -D -m 640 etc/masakarimonitors/processmonitor.conf.sample %{buildroot}%{_sysconfdir}/masakarimonitors/processmonitor.conf
install -p -D -m 640 etc/masakarimonitors/process_list.yaml.sample %{buildroot}%{_sysconfdir}/masakarimonitors/process_list.yaml
install -p -D -m 640 etc/masakarimonitors/proc.list.sample %{buildroot}%{_sysconfdir}/masakarimonitors/proc.list
chmod +x %{buildroot}%{_bindir}/masakari-*

%pre
%openstack_pre_user_group_create masakari masakari

%post
%tmpfiles_create %{_tmpfilesdir}/masakari-monitors.conf

%check
# TESTS do not work atm
exit 0
testr init
testr run

%post -n openstack-masakari-hostmonitor
%systemd_post openstack-masakari-hostmonitor.service

%preun -n openstack-masakari-hostmonitor
%systemd_preun openstack-masakari-hostmonitor.service

%postun -n openstack-masakari-hostmonitor
%systemd_postun_with_restart openstack-masakari-hostmonitor.service

%post -n openstack-masakari-instancemonitor
%systemd_post openstack-masakari-instancemonitor.service

%preun -n openstack-masakari-instancemonitor
%systemd_preun openstack-masakari-instancemonitor.service

%postun -n openstack-masakari-instancemonitor
%systemd_postun_with_restart openstack-masakari-instancemonitor.service

%post -n openstack-masakari-processmonitor
%systemd_post openstack-masakari-processmonitor.service

%preun -n openstack-masakari-processmonitor
%systemd_preun openstack-masakari-processmonitor.service

%postun -n openstack-masakari-processmonitor
%systemd_postun_with_restart openstack-masakari-processmonitor.service

%files
%license LICENSE
%dir %{_sysconfdir}/masakarimonitors
%config(noreplace) %attr(-, masakari, masakari) %{_sysconfdir}/masakarimonitors/masakarimonitors.conf
%dir %attr(750, masakari, masakari) %{_localstatedir}/log/masakari-monitors
%_tmpfilesdir/masakari-monitors.conf

%files -n openstack-masakari-hostmonitor
%config(noreplace) %attr(-, masakari, masakari) %{_sysconfdir}/masakarimonitors/hostmonitor.conf
%{_bindir}/masakari-hostmonitor
%{_unitdir}/openstack-masakari-hostmonitor.service

%files -n openstack-masakari-instancemonitor
%{_bindir}/masakari-instancemonitor
%{_unitdir}/openstack-masakari-instancemonitor.service

%files -n openstack-masakari-introspectiveinstancemonitor
%{_bindir}/masakari-introspectiveinstancemonitor
%{_unitdir}/openstack-masakari-introspectiveinstancemonitor.service

%files -n openstack-masakari-processmonitor
%{_bindir}/masakari-processmonitor
%{_unitdir}/openstack-masakari-processmonitor.service
%config(noreplace) %attr(-, masakari, masakari) %{_sysconfdir}/masakarimonitors/processmonitor.conf
%config(noreplace) %attr(-, masakari, masakari) %{_sysconfdir}/masakarimonitors/process_list.yaml
%config(noreplace) %attr(-, masakari, masakari) %{_sysconfdir}/masakarimonitors/proc.list

%files doc
%license LICENSE
%doc doc/build/html

%files -n %{python_pkg}
%license LICENSE
%{python2_sitelib}/masakari*

%changelog
openSUSE Build Service is sponsored by