File openstack-sahara.spec of Package openstack-sahara

#
# spec file for package openstack-sahara
#
# 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 sahara
%define groupname %{component}
%define username %{component}

%define version_unconverted 9.0.2.dev9

Name:           openstack-%{component}
Version:        9.0.2~dev9
Release:        0
Summary:        OpenStack Data Processing (Sahara)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/sahara
Source:         http://tarballs.openstack.org/sahara/sahara-stable-rocky.tar.gz
Source2:        %{name}.logrotate
Source3:        sahara-sudoers
Source4:        %name.conf
# systemd service files
Source10:       %{name}-api.service
Source11:       %{name}-all.service
Source12:       %{name}-engine.service
Source50:       README.config
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-devel
BuildRequires:  python-pbr
# Documentation requirements:
BuildRequires:  python-Babel >= 1.3
BuildRequires:  python-Sphinx
BuildRequires:  python-botocore
BuildRequires:  python-castellan
BuildRequires:  python-cinderclient
BuildRequires:  python-glanceclient
BuildRequires:  python-heatclient
BuildRequires:  python-keystoneclient
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-manilaclient
BuildRequires:  python-neutronclient
BuildRequires:  python-novaclient
BuildRequires:  python-openstackdocstheme
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslosphinx
BuildRequires:  python-paramiko
BuildRequires:  python-sphinxcontrib-httpdomain
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
BuildRequires:  python-swiftclient
BuildRequires:  python-tooz
Requires:       logrotate
Requires:       python >= 2.7
Requires:       python-sahara = %{version}
Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%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 python-sahara
Summary:        OpenStack Data Processing (Sahara) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.7
Requires:       python-Babel >= 2.3.4
Requires:       python-Flask >= 1.0.2
Requires:       python-Jinja2 >= 2.10
Requires:       python-SQLAlchemy >= 1.0.10
Requires:       python-WebOb >= 1.7.1
Requires:       python-alembic >= 0.8.10
Requires:       python-botocore >= 1.5.1
Requires:       python-castellan >= 0.16.0
Requires:       python-cinderclient >= 3.3.0
Requires:       python-eventlet >= 0.18.2
Requires:       python-glanceclient >= 2.8.0
Requires:       python-heatclient >= 1.10.0
Requires:       python-iso8601 >= 0.1.11
Requires:       python-jsonschema >= 2.6.0
Requires:       python-keystoneauth1 >= 3.4.0
Requires:       python-keystoneclient >= 3.8.0
Requires:       python-keystonemiddleware >= 4.17.0
Requires:       python-manilaclient >= 1.16.0
Requires:       python-neutronclient >= 6.7.0
Requires:       python-novaclient >= 9.1.0
Requires:       python-oslo.concurrency >= 3.26.0
Requires:       python-oslo.config >= 5.2.0
Requires:       python-oslo.context >= 2.19.2
Requires:       python-oslo.db >= 4.27.0
Requires:       python-oslo.i18n >= 3.15.3
Requires:       python-oslo.log >= 3.36.0
Requires:       python-oslo.messaging >= 5.29.0
Requires:       python-oslo.middleware >= 3.31.0
Requires:       python-oslo.policy >= 1.30.0
Requires:       python-oslo.rootwrap >= 5.8.0
Requires:       python-oslo.serialization >= 2.18.0
Requires:       python-oslo.service >= 1.24.0
Requires:       python-oslo.utils >= 3.33.0
Requires:       python-paramiko >= 2.0.0
Requires:       python-pbr >= 2.0.0
Requires:       python-requests >= 2.14.2
Requires:       python-saharaclient >= 1.4.0
Requires:       python-six >= 1.10.0
Requires:       python-stevedore >= 1.20.0
Requires:       python-swiftclient >= 3.2.0
Requires:       python-tooz >= 1.58.0

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

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

%description api
This package contains the OpenStack Sahara API.

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

%description engine
This package contains the OpenStack Sahara Engine.


%package test
Summary:        OpenStack Data Processing (Sahara) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-fixtures >= 3.0.0
Requires:       python-mock >= 2.0.0
Requires:       python-oslotest >= 3.2.0
Requires:       python-paramiko >= 2.0.0
Requires:       python-sphinxcontrib-httpdomain >= 1.3.0
Requires:       python-testresources >= 2.0.0
Requires:       python-testscenarios >= 0.4
Requires:       python-testtools >= 2.2.0

%description test
This package contains testsuite files for %{name}.

%prep
%setup -q -n %{component}-%{version_unconverted}
%openstack_cleanup_prep
#NOTE(saschpe): Kill sahara Sphinx extension, we're only building manpages:
sed -i -e "s|'sahara.doc.resources'||" -e "s|'ext.resources'||" doc/source/conf.py
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg

%build
python setup.py build
export PYTHONPATH="$( pwd ):$PYTHONPATH"
PBR_VERSION=%{version} sphinx-build -b man doc/source doc/build/man

# 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
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

### directories
install -d -m 700 %{buildroot}%{_localstatedir}/run/%{component}
install -D -m 644 %{SOURCE4} %{buildroot}/%_tmpfilesdir/%name.conf
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log}/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/cache/%{component}

### configuration files
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/
mv %{buildroot}/usr/etc/sahara/* %{buildroot}%{_sysconfdir}/%{component}/
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/%{component}/README.config
install -p -D -m 644 etc/%{component}.conf.sample %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf
install -p -D -m 644 etc/policy.json.sample %{buildroot}%{_sysconfdir}/%{component}/policy.json
install -p -m 644 etc/sahara/*.conf %{buildroot}%{_sysconfdir}/%{component}/
install -p -m 644 etc/sahara/api-paste.ini %{buildroot}%{_sysconfdir}/%{component}/
install -d %{buildroot}%{_sysconfdir}/%{component}/rootwrap.d/
install -p -m 644 etc/sahara/rootwrap.d/sahara.filters %{buildroot}%{_sysconfdir}/%{component}/rootwrap.d/sahara.filters

### set default configuration
%define sahara_conf %{buildroot}%{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
crudini --set %{sahara_conf} DEFAULT log_dir /var/log/sahara

### bash-completion/logrotate/etc.
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# Install systemd unit services
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir}
install -p -D -m 444 %{SOURCE10} %{buildroot}%{_unitdir}/%{name}-api.service
install -p -D -m 444 %{SOURCE11} %{buildroot}%{_unitdir}/%{name}-all.service
install -p -D -m 444 %{SOURCE12} %{buildroot}%{_unitdir}/%{name}-engine.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-all
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-engine

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

### documentation
install -d %{buildroot}%{_mandir}/man1
install -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1

### test subpackage
%openstack_test_package_install
%fdupes %{buildroot}%{_localstatedir}/lib/%{name}-test

### misc
%fdupes %{buildroot}%{python_sitelib}/%{component}

%pre
%openstack_pre_user_group_create %{username} %{groupname}
%service_add_pre %{name}-all.service

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post %{name}-all.service

%preun
%stop_on_removal %{name}-all.service
%service_del_preun %{name}-all.service

%postun
%restart_on_update %{name}-all.service
%service_del_postun %{name}-all.service

%pre api
%service_add_pre %{name}-api.service

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

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

%postun api
%restart_on_update %{name}-api.service
%service_del_postun %{name}-api.service

%pre engine
%service_add_pre %{name}-engine.service

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

%preun engine
%stop_on_removal %{name}-engine.service
%service_del_preun %{name}-engine.service

%postun engine
%restart_on_update %{name}-engine.service
%service_del_postun %{name}-engine.service

%files
%defattr(-,root,root)
%license LICENSE
%doc README.rst
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/lib/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%_tmpfilesdir/%name.conf
%dir %{_sysconfdir}/%{component}
%dir %{_sysconfdir}/%{component}/%{component}.conf.d/
%{_sysconfdir}/%{component}/README.config
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/sahara.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/%{component}.conf.d/010-%{component}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %{_sysconfdir}/sudoers.d/
%config %{_sysconfdir}/sudoers.d/%{name}
%config %{_sysconfdir}/%{component}/rootwrap.conf
%config %{_sysconfdir}/%{component}/policy.json
%config %{_sysconfdir}/%{component}/api-paste.ini
%dir %{_sysconfdir}/%{component}/rootwrap.d/
%config %{_sysconfdir}/%{component}/rootwrap.d/sahara.filters
%{_bindir}/%{component}-all
%{_unitdir}/%{name}-all.service
%{_sbindir}/rc%{name}-all
%{_bindir}/%{component}-db-manage
%{_bindir}/_%{component}-subprocess
%{_bindir}/%{component}-rootwrap
%{_bindir}/%{component}-image-pack
%{_bindir}/%{component}-templates
%{_mandir}/man1/%{component}.1%{?ext_man}

%files -n python-%{component}
%defattr(-,root,root,-)
%license LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info

%files api
%defattr(-,root,root,-)
%license LICENSE
%{_unitdir}/%{name}-api.service
%{_sbindir}/rc%{name}-api
%{_bindir}/%{component}-api
%{_bindir}/%{component}-wsgi-api

%files engine
%defattr(-,root,root,-)
%license LICENSE
%{_unitdir}/%{name}-engine.service
%{_sbindir}/rc%{name}-engine
%{_bindir}/%{component}-engine

%files test
%defattr(-,root,root)
%{_localstatedir}/lib/%{name}-test/

%changelog
openSUSE Build Service is sponsored by