Add spec for sahara

This change adds the spec for sahara for rpm-packaging

Change-Id: Ia4382aed6c345e516d6c7dc460ad45032ddee728
This commit is contained in:
matthew-fuller 2019-09-10 11:43:22 -07:00
parent edab0cb5d4
commit ccc87850c1
8 changed files with 374 additions and 0 deletions

View File

@ -0,0 +1,16 @@
[Unit]
Description=OpenStack Sahara API service
After=syslog.target network.target
[Service]
Type=notify
User=sahara
Group=sahara
WorkingDirectory=/var/lib/sahara
PrivateTmp=yes
ExecStartPre=-/usr/bin/sahara-db-manage upgrade head
ExecStart=/usr/bin/sahara-api
Restart=on-failure
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,15 @@
[Unit]
Description=OpenStack Sahara engine service
After=syslog.target network.target
[Service]
Type=notify
User=sahara
Group=sahara
WorkingDirectory=/var/lib/sahara
PrivateTmp=yes
ExecStart=/usr/bin/sahara-engine
Restart=on-failure
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,30 @@
The main service configuration (/etc/$project/$project.conf) can still be used
for configuration but the preferred way is to add config file snippets into
/etc/$project/$project.conf.d/ instead.
As part of the packaging, the package itself installs a config snippet at
/etc/$project/$project.conf.d/010-$project.conf with basic configuration. This
file should not be modified. In case there is a need to overwrite or add
settings, a XXX-$project.conf (XXX being a 3 digit number) should be created
instead.
Config directory file snippet naming should follow these conventions:
- snippets should start with "XXX-" where "X" is a number
- snippets must end with ".conf"
- config management systems (Crowbar, Salt, ...) should use numbers
between 100 and 499
- users should use numbers starting from 500
Configuring just a single $program (eg for Nova, $project is "nova" and
$program is "nova-api", "nova-compute", "nova-scheduler", ...) can be done
in a similar way. The config snippets should be placed in
/etc/$project/$program.conf.d/ . The same snippets rules apply here, too.
$program reads the configuration files in the following order:
- /etc/$project/$project.conf
- /etc/$project/$project.conf.d/*.conf (lexically sorted)
- /etc/$project/$program.conf.d/*.conf (lexically sorted)
The last configured key overwrites all previous ones. In particular, settings
in /etc/$project/$project.conf are overwritten by config values from any file
in /etc/$project/$project.conf.d/XXX-$project.conf .

View File

@ -0,0 +1,2 @@
[DEFAULT]
log_dir=/var/log/shara

View File

@ -0,0 +1,10 @@
/var/log/sahara/*.log {
compress
rotate 15
size 1M
dateext
missingok
notifempty
su sahara sahara
sharedscripts
}

View File

@ -0,0 +1,2 @@
Defaults:sahara syslog_goodpri=none, !pam_session
sahara ALL = (root) NOPASSWD: /usr/bin/sahara-rootwrap /etc/sahara/rootwrap.conf *

View File

@ -0,0 +1 @@
d /run/sahara 0700 sahara sahara -

View File

@ -0,0 +1,298 @@
{% set pypi_name = 'sahara' %}
{% set source = fetch_source('https://tarballs.openstack.org/sahara/sahara-master.tar.gz') %}
{% set upstream_version = upstream_version() %}
{% set rpm_release = '1' %}
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name: {{ py2name() }}
Epoch: {{ epoch('sahara') }}
Version: {{ py2rpmversion() }}
Release: {{ py2rpmrelease() }}
Summary: OpenStack Data Processing (Sahara)
License: {{ license('Apache-2.0') }}
URL: https://launchpad.net/sahara
Source0: {{ source|basename }}
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: {{ py3('Babel') }}
BuildRequires: {{ py3('Flask') }}
BuildRequires: {{ py3('Jinja2') }}
BuildRequires: {{ py3('SQLAlchemy') }}
BuildRequires: {{ py3('WebOb') }}
BuildRequires: {{ py3('alembic') }}
BuildRequires: {{ py3('botocore') }}
BuildRequires: {{ py3('castellan') }}
BuildRequires: {{ py3('python-cinderclient') }}
BuildRequires: {{ py3('eventlet') }}
BuildRequires: {{ py3('fixtures') }}
BuildRequires: {{ py3('python-glanceclient') }}
BuildRequires: {{ py3('python-heatclient') }}
BuildRequires: {{ py3('iso8601') }}
BuildRequires: {{ py3('jsonschema') }}
BuildRequires: {{ py3('keystoneauth1') }}
BuildRequires: {{ py3('python-keystoneclient') }}
BuildRequires: {{ py3('keystonemiddleware') }}
BuildRequires: {{ py3('python-manilaclient') }}
BuildRequires: {{ py3('microversion_parse') }}
BuildRequires: {{ py3('mock') }}
BuildRequires: {{ py3('python-neutronclient') }}
BuildRequires: {{ py3('python-novaclient') }}
BuildRequires: {{ py3('oslo.concurrency') }}
BuildRequires: {{ py3('oslo.config') }}
BuildRequires: {{ py3('oslo.context') }}
BuildRequires: {{ py3('oslo.db') }}
BuildRequires: {{ py3('oslo.i18n') }}
BuildRequires: {{ py3('oslo.log') }}
BuildRequires: {{ py3('oslo.messaging') }}
BuildRequires: {{ py3('oslo.middleware') }}
BuildRequires: {{ py3('oslo.policy') }}
BuildRequires: {{ py3('oslo.rootwrap') }}
BuildRequires: {{ py3('oslo.serialization') }}
BuildRequires: {{ py3('oslo.service') }}
BuildRequires: {{ py3('oslo.upgradecheck') }}
BuildRequires: {{ py3('oslo.utils') }}
BuildRequires: {{ py3('oslo.versionedobjects') }}
BuildRequires: {{ py3('oslotest') }}
BuildRequires: {{ py3('paramiko') }}
BuildRequires: {{ py3('pbr') }}
BuildRequires: {{ py3('requests') }}
BuildRequires: {{ py3('python-saharaclient') }}
BuildRequires: {{ py3('six') }}
BuildRequires: {{ py3('stestr') }}
BuildRequires: {{ py3('stevedore') }}
BuildRequires: {{ py3('python-swiftclient') }}
BuildRequires: {{ py3('testtools') }}
BuildRequires: {{ py3('tooz') }}
BuildRequires: sudo
Requires: logrotate
Requires: python3-{{ pypi_name }} = %{epoch}:%{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-{{ pypi_name }}
Summary: OpenStack shared file system service (Sahara) - Python module
Group: Development/Languages/Python
Requires: {{ py3('Flask') }}
Requires: {{ py3('Jinja2') }}
Requires: {{ py3('SQLAlchemy') }}
Requires: {{ py3('WebOb') }}
Requires: {{ py3('alembic') }}
Requires: {{ py3('botocore') }}
Requires: {{ py3('castellan') }}
Requires: {{ py3('python-cinderclient') }}
Requires: {{ py3('eventlet') }}
Requires: {{ py3('python-glanceclient') }}
Requires: {{ py3('python-heatclient') }}
Requires: {{ py3('jsonschema') }}
Requires: {{ py3('keystoneauth1') }}
Requires: {{ py3('python-keystoneclient') }}
Requires: {{ py3('keystonemiddleware') }}
Requires: {{ py3('python-manilaclient') }}
Requires: {{ py3('microversion_parse') }}
Requires: {{ py3('python-neutronclient') }}
Requires: {{ py3('python-novaclient') }}
Requires: {{ py3('oslo.concurrency') }}
Requires: {{ py3('oslo.config') }}
Requires: {{ py3('oslo.context') }}
Requires: {{ py3('oslo.db') }}
Requires: {{ py3('oslo.i18n') }}
Requires: {{ py3('oslo.log') }}
Requires: {{ py3('oslo.messaging') }}
Requires: {{ py3('oslo.middleware') }}
Requires: {{ py3('oslo.policy') }}
Requires: {{ py3('oslo.rootwrap') }}
Requires: {{ py3('oslo.serialization') }}
Requires: {{ py3('oslo.service') }}
Requires: {{ py3('oslo.upgradecheck') }}
Requires: {{ py3('oslo.utils') }}
Requires: {{ py3('oslo.versionedobjects') }}
Requires: {{ py3('paramiko') }}
Requires: {{ py3('pbr') }}
Requires: {{ py3('requests') }}
Requires: {{ py3('six') }}
Requires: {{ py3('stevedore') }}
Requires: {{ py3('python-swiftclient') }}
Requires: {{ py3('tooz') }}
Requires: sudo
%description -n python3-{{ pypi_name }}
This package contains the core Python module of OpenStack Sahara.
%package doc
Summary: OpenStack Data Processing (Sahara) - Documentation
Group: Documentation/HTML
BuildRequires: {{ py3('Sphinx') }}
BuildRequires: {{ py3('openstackdocstheme') }}
BuildRequires: {{ py3('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-{{ pypi_name }} = %{epoch}:%{version}-%{release}
%description api
This package contains the OpenStack Sahara API.
%package engine
Summary: OpenStack Data Processing (Sahara) - Engine
Group: System/Management
Requires: openstack-{{ pypi_name }} = %{epoch}:%{version}-%{release}
%description engine
This package contains the OpenStack Sahara Engine.
%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup
%build
%{py3_build}
PYTHONPATH=. PBR_VERSION={{ upstream_version }} %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
%{__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