File openstack-masakari.spec of Package openstack-masakari

#
# spec file for package openstack-masakari
#
# 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
Name:           openstack-masakari
Version:        6.0.0
Release:        0
Summary:        Virtual Machine High Availability (VMHA) service for OpenStack
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://launchpad.net/masakari
Source0:        masakari-6.0.0.tar.gz
Source1:        masakari-api.service
Source2:        masakari-engine.service
Source3:        masakari.tmpfiles
BuildRequires:  openstack-macros
BuildRequires:  python-Sphinx
BuildRequires:  python-ddt
BuildRequires:  python-eventlet
BuildRequires:  python-keystoneauth1
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-microversion_parse
BuildRequires:  python-novaclient
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.middleware
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslo.service
BuildRequires:  python-oslo.versionedobjects
BuildRequires:  python-oslotest
BuildRequires:  python-python-subunit
BuildRequires:  python-reno
BuildRequires:  python-requests-mock
BuildRequires:  python-setuptools
BuildRequires:  python-taskflow
BuildRequires:  python-testrepository
BuildRequires:  python-testresources
BuildRequires:  python-testscenarios
BuildRequires:  python-testtools
Requires:       python-masakari = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%else
BuildRequires:  systemd
%endif

%description
Masakari is a service providing high availability for VMs in OpenStack.

System package - %{name}
Python package - python-%{sname}

%package        doc
Summary:        Documentation for OpenStack Masakari Service
Group:          Development/Languages/Python
BuildRequires:  openstack-tempest
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
Masakari is a service providing high availability for VMs in OpenStack.

This package contains the documentation.

%package -n     python-%{sname}
Summary:        Masakari Python libraries
Group:          Development/Languages/Python
Requires:       python-Babel
Requires:       python-iso8601
Requires:       python-jsonschema
Requires:       python-keystoneauth1
Requires:       python-keystonemiddleware
Requires:       python-microversion_parse
Requires:       python-novaclient
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.service
Requires:       python-oslo.utils
Requires:       python-oslo.versionedobjects
Requires:       python-pbr
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.

%package        api
Summary:        OpenStack Masakari API service
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description    api
OpenStack REST API to the Masakari api.

This package contains the REST API.

%package        engine
Summary:        OpenStack Masakari Engine service
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description    engine
OpenStack Masakari Engine service.

This package contains the masakari engine, which is one of core services of masakari.

%prep
%autosetup -n %{sname}-6.0.0
%py_req_cleanup

%build
%{py2_build}
export PYTHONPATH="."
# from tox.ini's testenv:genconfig
oslo-config-generator --config-file etc/masakari/masakari-config-generator.conf
oslopolicy-sample-generator --config-file etc/masakari/masakari-policy-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}/masakari/
mkdir -p %{buildroot}%{_localstatedir}/log/masakari
#systemd unitfiles
install -p -D -m 644 %SOURCE1 %{buildroot}%{_unitdir}/openstack-masakari-api.service
install -p -D -m 644 %SOURCE2 %{buildroot}%{_unitdir}/openstack-masakari-engine.service
install -p -D -m 644 %SOURCE3 %{buildroot}/%{_tmpfilesdir}/masakari.conf

install -p -D -m 640 etc/masakari/masakari.conf.sample %{buildroot}%{_sysconfdir}/masakari/masakari.conf
install -p -D -m 640 etc/masakari/api-paste.ini %{buildroot}%{_sysconfdir}/masakari/api-paste.ini
install -p -D -m 640 etc/masakari/policy.yaml.sample %{buildroot}%{_sysconfdir}/masakari/policy.yaml
chmod +x %{buildroot}%{_bindir}/masakari*

# remove usr/etc
rm -rf %{buildroot}%{_prefix}%{_sysconfdir}/

%pre
%openstack_pre_user_group_create masakari masakari

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

%check
testr init
testr list-tests > list
testr run --load-list=list

%post api
%systemd_post openstack-masakari-api.service

%preun api
%systemd_preun openstack-masakari-api.service

%postun api
%systemd_postun_with_restart openstack-masakari-api.service

%post engine
%systemd_post openstack-masakari-engine.service

%preun engine
%systemd_preun openstack-masakari-engine.service

%postun engine
%systemd_postun_with_restart openstack-masakari-engine.service

%files
%license LICENSE
%dir %{_sysconfdir}/masakari
%config(noreplace) %attr(0640, root, masakari) %{_sysconfdir}/masakari/*
%dir %attr(750, masakari, masakari) %{_localstatedir}/log/masakari
%_tmpfilesdir/masakari.conf

%files api
%{_bindir}/masakari-api
%{_bindir}/masakari-manage
%{_bindir}/masakari-wsgi
%{_unitdir}/openstack-masakari-api.service

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

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

%files -n python-%{sname}
%{python2_sitelib}/%{sname}*

%changelog
openSUSE Build Service is sponsored by