File openstack-sahara.spec of Package openstack-sahara

#
# spec file for package openstack-sahara
#
# 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/
#


%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           openstack-sahara
Version:        13.1.0~dev2
Release:        0
Summary:        OpenStack Data Processing (Sahara)
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/sahara
Source0:        sahara-master.tar.gz
Source1:        openstack-sahara.sudoers
Source2:        openstack-sahara.logrotate
Source3:        openstack-sahara.tmpfiles
Source4:        openstack-sahara.defaultconf
Source5:        openstack-sahara.README.config
# systemd service files
Source6:        openstack-sahara-api.service
Source7:        openstack-sahara-engine.service
BuildRequires:  openssh
BuildRequires:  openstack-macros
BuildRequires:  python3-Babel
BuildRequires:  python3-Flask
BuildRequires:  python3-Jinja2
BuildRequires:  python3-SQLAlchemy
BuildRequires:  python3-WebOb
BuildRequires:  python3-alembic
BuildRequires:  python3-botocore
BuildRequires:  python3-castellan
BuildRequires:  python3-cinderclient
BuildRequires:  python3-eventlet
BuildRequires:  python3-fixtures
BuildRequires:  python3-glanceclient
BuildRequires:  python3-heatclient
BuildRequires:  python3-iso8601
BuildRequires:  python3-jsonschema
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-keystoneclient
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-manilaclient
BuildRequires:  python3-microversion_parse
BuildRequires:  python3-mock
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-oslo.concurrency
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.context
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.i18n
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.messaging
BuildRequires:  python3-oslo.middleware
BuildRequires:  python3-oslo.policy
BuildRequires:  python3-oslo.rootwrap
BuildRequires:  python3-oslo.serialization
BuildRequires:  python3-oslo.service
BuildRequires:  python3-oslo.upgradecheck
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-oslo.versionedobjects
BuildRequires:  python3-oslotest
BuildRequires:  python3-paramiko
BuildRequires:  python3-pbr
BuildRequires:  python3-requests
BuildRequires:  python3-saharaclient
BuildRequires:  python3-six
BuildRequires:  python3-stestr
BuildRequires:  python3-stevedore
BuildRequires:  python3-swiftclient
BuildRequires:  python3-testtools
BuildRequires:  python3-tooz
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-sahara = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(pre):  shadow-utils
Requires(preun): systemd
%endif

%description
Sahara project aims to provide users with simple means to provision
a Hadoop cluster at OpenStack by specifying several parameters like
Hadoop version, cluster topology, nodes hardware details and a few more.

%package -n     python3-sahara
Summary:        OpenStack shared file system service (Sahara) - Python module
Group:          Development/Languages/Python
Requires:       python3-Flask
Requires:       python3-Jinja2
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-alembic
Requires:       python3-botocore
Requires:       python3-castellan
Requires:       python3-cinderclient
Requires:       python3-eventlet
Requires:       python3-glanceclient
Requires:       python3-heatclient
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystoneclient
Requires:       python3-keystonemiddleware
Requires:       python3-manilaclient
Requires:       python3-microversion_parse
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-oslo.concurrency
Requires:       python3-oslo.config
Requires:       python3-oslo.context
Requires:       python3-oslo.db
Requires:       python3-oslo.i18n
Requires:       python3-oslo.log
Requires:       python3-oslo.messaging
Requires:       python3-oslo.middleware
Requires:       python3-oslo.policy
Requires:       python3-oslo.rootwrap
Requires:       python3-oslo.serialization
Requires:       python3-oslo.service
Requires:       python3-oslo.upgradecheck
Requires:       python3-oslo.utils
Requires:       python3-oslo.versionedobjects
Requires:       python3-paramiko
Requires:       python3-pbr
Requires:       python3-requests
Requires:       python3-six
Requires:       python3-stevedore
Requires:       python3-swiftclient
Requires:       python3-tooz
Requires:       sudo

%description -n python3-sahara
This package contains the core Python module of OpenStack Sahara.

%package doc
Summary:        OpenStack Data Processing (Sahara) - Documentation
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinxcontrib-httpdomain

%description doc
OpenStack Data Processing service.
This package contains the documentation for OpenStack Sahara.

%package api
Summary:        OpenStack Data Processing (Sahara) - API
Group:          System/Management
Requires:       openstack-sahara = %{version}-%{release}

%description api
This package contains the OpenStack Sahara API.

%package engine
Summary:        OpenStack Data Processing (Sahara) - Engine
Group:          System/Management
Requires:       openstack-sahara = %{version}-%{release}

%description engine
This package contains the OpenStack Sahara Engine.

%prep
%autosetup -p1 -n sahara-13.1.0.dev2
%py_req_cleanup

%build
%{py3_build}
PYTHONPATH=. PBR_VERSION=13.1.0.dev2 %sphinx_build --keep-going -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

# config files
PYTHONPATH=. oslo-config-generator --config-file tools/config/config-generator.sahara.conf --output-file etc/sahara.conf.sample
PYTHONPATH=. oslopolicy-sample-generator --config-file=tools/config/sahara-policy-generator.conf --output etc/policy.json.sample

%install
%{py3_install}

### Setup directories
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log,cache}/sahara
install -d -m 755 %{buildroot}%{_sysconfdir}/sahara/sahara.conf.d/

### Install configuration files
install -D -m 644 %{SOURCE3} %{buildroot}/%_tmpfilesdir/sahara.conf
install -p -D -m 640 %{SOURCE4} %{buildroot}%{_sysconfdir}/sahara/sahara.conf.d/010-sahara.conf
mv %{buildroot}%{_prefix}%{_sysconfdir}/sahara/* %{buildroot}%{_sysconfdir}/sahara/
cp -a etc/sahara/rootwrap.d/ %{buildroot}%{_sysconfdir}/sahara/
install -p -D -m 640 %{SOURCE5} %{buildroot}%{_sysconfdir}/sahara/README.config

### Install systemd service files
install -p -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}-api.service
install -p -D -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-engine.service

### install symlinks on SUSE
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-engine
%endif

### sudoers configuration for sahara-rootwrap:
install -D -m 440 %{SOURCE1} %{buildroot}%{_sysconfdir}/sudoers.d/openstack-sahara

### Install logrotate
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-sahara

%check
# don't want to depend on hacking for package building
rm sahara/tests/unit/utils/test_hacking.py
# TODO: undo after https://storyboard.openstack.org/#!/story/2007450
rm -v sahara/tests/unit/service/health/test_verification_base.py

%{__python3} -m stestr.cli run

%pre
%openstack_pre_user_group_create sahara sahara /sbin/nologin
exit 0

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

%post api
%systemd_post %{name}-api.service

%preun api
%systemd_preun %{name}-api.service

%postun api
%systemd_postun_with_restart %{name}-api.service

%post engine
%systemd_post %{name}-engine.service

%preun engine
%systemd_preun %{name}-engine.service

%postun engine
%systemd_postun_with_restart %{name}-engine.service

%files
%doc README.rst
%license LICENSE
%dir %attr(0750, sahara, sahara) %{_localstatedir}/lib/sahara
%dir %attr(0750, sahara, sahara) %{_localstatedir}/cache/sahara
%dir %attr(0750, sahara, sahara) %{_localstatedir}/log/sahara
%_tmpfilesdir/sahara.conf
%dir %{_sysconfdir}/sahara
%dir %{_sysconfdir}/sahara/sahara.conf.d/
%{_sysconfdir}/sahara/README.config
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-sahara
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-sahara
%config(noreplace) %attr(0640, root, sahara) %{_sysconfdir}/sahara/sahara.conf.d/010-sahara.conf
%config %{_sysconfdir}/sahara/rootwrap.conf
%config %{_sysconfdir}/sahara/api-paste.ini
%dir %{_sysconfdir}/sahara/rootwrap.d
%config(noreplace) %{_sysconfdir}/sahara/rootwrap.d/sahara.filters
%{_bindir}/sahara-all
%{_bindir}/sahara-db-manage
%{_bindir}/_sahara-subprocess
%{_bindir}/sahara-rootwrap
%{_bindir}/sahara-status
%{_bindir}/sahara-image-pack
%{_bindir}/sahara-templates

%files -n python3-sahara
%license LICENSE
%{python3_sitelib}/sahara/
%{python3_sitelib}/sahara-*.egg-info

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

%files api
%license LICENSE
%{_unitdir}/%{name}-api.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-api
%endif
%{_bindir}/sahara-api
%{_bindir}/sahara-wsgi-api

%files engine
%license LICENSE
%{_unitdir}/%{name}-engine.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-engine
%endif
%{_bindir}/sahara-engine

%changelog