File openstack-cinder.spec of Package openstack-cinder

#
# spec file for package openstack-cinder
#
# 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 with_doc 1
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
%global service cinder
Name:           openstack-cinder
Version:        13.0.10~dev20
Release:        0
Summary:        OpenStack Block Storage (Cinder)
License:        Apache-2.0
Group:          Applications/System
URL:            https://launchpad.net/cinder
Source0:        cinder-stable-rocky.tar.gz
Source1:        openstack-cinder.logrotate
Source2:        openstack-cinder-api.service
Source3:        openstack-cinder-scheduler.service
Source4:        openstack-cinder-volume.service
Source5:        openstack-cinder-backup.service
Source6:        %{service}-sudoers
BuildRequires:  openstack-macros
BuildRequires:  python-PyMySQL
BuildRequires:  python-SQLAlchemy
BuildRequires:  python-barbicanclient
BuildRequires:  python-castellan
BuildRequires:  python-cryptography
BuildRequires:  python-cursive
BuildRequires:  python-ddt
BuildRequires:  python-decorator
BuildRequires:  python-defusedxml
BuildRequires:  python-fixtures
BuildRequires:  python-glanceclient
BuildRequires:  python-google-api-python-client
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-lxml
BuildRequires:  python-mock
BuildRequires:  python-novaclient
BuildRequires:  python-os-brick
BuildRequires:  python-os-testr
BuildRequires:  python-os-win
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.i18n
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.policy
BuildRequires:  python-oslo.reports
BuildRequires:  python-oslo.utils
BuildRequires:  python-oslo.versionedobjects
BuildRequires:  python-oslo.vmware
BuildRequires:  python-oslotest
BuildRequires:  python-osprofiler
BuildRequires:  python-paramiko
BuildRequires:  python-psycopg2
BuildRequires:  python-pyparsing
BuildRequires:  python-requests
BuildRequires:  python-retrying
BuildRequires:  python-rtslib-fb
BuildRequires:  python-setuptools
BuildRequires:  python-sqlalchemy-migrate
BuildRequires:  python-suds-jurko
BuildRequires:  python-swiftclient
BuildRequires:  python-taskflow
BuildRequires:  python-testresources
BuildRequires:  python-testscenarios
BuildRequires:  python-testtools
BuildRequires:  python-tooz
BuildRequires:  sudo
Requires:       logrotate
Requires:       python-cinder = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(preun): systemd
%endif
%if 0%{?suse_version}
Requires(pre):  pwdutils
%endif
%if 0%{?rdo}
Requires(pre):  shadow-utils
%endif

%description
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

%package -n     python-cinder
Summary:        OpenStack Volume Python libraries
Group:          Applications/System
Requires:       python-Paste
Requires:       python-PasteDeploy
Requires:       python-PrettyTable
Requires:       python-Routes
Requires:       python-SQLAlchemy
Requires:       python-WebOb
Requires:       python-barbicanclient
Requires:       python-castellan
Requires:       python-cryptography
Requires:       python-cursive
Requires:       python-decorator
Requires:       python-defusedxml
Requires:       python-enum34
Requires:       python-eventlet
Requires:       python-glanceclient
Requires:       python-google-api-python-client
Requires:       python-httplib2
Requires:       python-ipaddress
Requires:       python-iso8601
Requires:       python-jsonschema
Requires:       python-keystoneauth1
Requires:       python-keystoneclient
Requires:       python-keystonemiddleware
Requires:       python-lxml
Requires:       python-novaclient
Requires:       python-oauth2client
Requires:       python-os-brick
Requires:       python-os-win
Requires:       python-oslo.concurrency
Requires:       python-oslo.config
Requires:       python-oslo.context
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.reports
Requires:       python-oslo.rootwrap
Requires:       python-oslo.serialization
Requires:       python-oslo.service
Requires:       python-oslo.utils
Requires:       python-oslo.versionedobjects
Requires:       python-oslo.vmware
Requires:       python-osprofiler
Requires:       python-paramiko
Requires:       python-psutil
Requires:       python-pyparsing
Requires:       python-pytz
Requires:       python-requests
Requires:       python-retrying
Requires:       python-rtslib-fb
Requires:       python-simplejson
Requires:       python-six
Requires:       python-sqlalchemy-migrate
Requires:       python-stevedore
Requires:       python-suds-jurko
Requires:       python-swiftclient
Requires:       python-taskflow
Requires:       python-tooz
Requires:       sudo

%description -n python-cinder
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the Cinder Python library.

%if 0%{?with_doc}
%package doc
Summary:        Documentation for OpenStack Volume Service
Group:          Documentation
BuildRequires:  python-Sphinx
BuildRequires:  python-openstackdocstheme
BuildRequires:  python-sphinx-feature-classification
BuildRequires:  python-sphinxcontrib-apidoc

%description doc
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the documentation.
%endif

%package api
Summary:        OpenStack Volume service (Cinder) - API
Group:          Development/Languages/Python
Requires:       python-cinder = %{version}-%{release}

%description api
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the %{name} API server.

%package scheduler
Summary:        OpenStack Volume service (Cinder) - Scheduler
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description scheduler
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the %{name} scheduler server.

%package volume
Summary:        OpenStack Volume service (Cinder) - Vlume
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description volume
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the %{name} volume server.

%package backup
Summary:        OpenStack Volume service (Cinder) - Backup
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description backup
OpenStack Volume (codename Cinder) provides services to manage and
access block storage volumes for use by Virtual Machine instances.

This package contains the %{name} backup server.

%prep
%autosetup -n cinder-13.0.10.dev20
%py_req_cleanup
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg

# We do not want to depend on hacking for unit tests
rm -f cinder/tests/unit/test_hacking.py

%build
%{py2_build}
# build documentation
%if 0%{?with_doc}
export PYTHONPATH="$( pwd ):$PYTHONPATH"
PBR_VERSION=13.0.10.dev20 sphinx-build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif
# generate the sample config files
PYTHONPATH=. oslo-config-generator --config-file tools/config/cinder-config-generator.conf

%install
%{py2_install}

# Setup directories
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{service}
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{service}/tmp
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{service}

# Install config files
install -d -m 755 %{buildroot}%{_sysconfdir}/%{service}
install -d -m 755 %{buildroot}%{_sysconfdir}/%{service}/volumes
install -p -D -m 640 etc/%{service}/rootwrap.conf %{buildroot}%{_sysconfdir}/%{service}/rootwrap.conf
install -p -D -m 640 etc/%{service}/api-paste.ini %{buildroot}%{_sysconfdir}/%{service}/api-paste.ini
install -p -D -m 640 etc/%{service}/%{service}.conf.sample %{buildroot}%{_sysconfdir}/%{service}/%{service}.conf

# Install initscripts for services
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/openstack-%{service}-api.service
install -p -D -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/openstack-%{service}-scheduler.service
install -p -D -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/openstack-%{service}-volume.service
install -p -D -m 644 %{SOURCE5} %{buildroot}%{_unitdir}/openstack-%{service}-backup.service

# Install sudoers
install -p -D -m 440 %{SOURCE6} %{buildroot}%{_sysconfdir}/sudoers.d/%{service}

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

# Install pid directory
install -d -m 755 %{buildroot}%{_rundir}/%{service}

# Install rootwrap files in /usr/share/cinder/rootwrap
mkdir -p %{buildroot}%{_datarootdir}/%{service}/rootwrap/
install -p -D -m 644 etc/%{service}/rootwrap.d/* %{buildroot}%{_datarootdir}/%{service}/rootwrap/

# Symlinks to rootwrap config files
mkdir -p %{buildroot}%{_sysconfdir}/%{service}/rootwrap.d
for filter in %{_sysconfdir}/rootwrap.d/os-brick.filters; do
ln -s $filter %{buildroot}%{_sysconfdir}/%{service}/rootwrap.d/
done

# Remove duplicate config files under /usr/etc/
rm -rf %{buildroot}%{_prefix}/%{_sysconfdir}

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

%check
# OS_TEST_PATH=./cinder/tests/unit PYTHONPATH=. ostestr

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

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

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

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

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

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

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

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

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

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

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

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

%files
%license LICENSE
%dir %attr(0750, root, cinder) %{_sysconfdir}/cinder
%config(noreplace) %attr(-, root, %{service}) %{_sysconfdir}/%{service}/%{service}.conf
%config(noreplace) %attr(-, root, %{service}) %{_sysconfdir}/%{service}/api-paste.ini
%config(noreplace) %attr(-, root, %{service}) %{_sysconfdir}/%{service}/rootwrap.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-%{service}
%config(noreplace) %{_sysconfdir}/sudoers.d/%{service}
%{_sysconfdir}/%{service}/rootwrap.d/
%dir %attr(0750, %{service}, root) %{_localstatedir}/log/%{service}
%dir %attr(0755, %{service}, root) %{_rundir}/%{service}
%dir %attr(0755, %{service}, root) %{_sysconfdir}/%{service}/volumes
%{_datarootdir}/%{service}
%defattr(-, %{service}, %{service}, -)
%dir %{_localstatedir}/lib/%{service}
%dir %{_localstatedir}/lib//%{service}/tmp
%{_bindir}/cinder-manage
%{_bindir}/cinder-rootwrap
%{_bindir}/cinder-rtstool
%{_bindir}/cinder-volume-usage-audit

%files -n python-cinder
%defattr(-,root,root,-)
%license LICENSE
%{python_sitelib}/cinder*

%if 0%{?with_doc}
%files doc
%license LICENSE
%doc doc/build/html
%endif

%files api
%defattr(-,root,root,-)
%{_unitdir}/openstack-cinder-api.service
%{_bindir}/cinder-api
%{_bindir}/cinder-wsgi

%files scheduler
%defattr(-,root,root,-)
%{_unitdir}/openstack-cinder-scheduler.service
%{_bindir}/cinder-scheduler

%files volume
%defattr(-,root,root,-)
%{_unitdir}/openstack-cinder-volume.service
%{_bindir}/cinder-volume

%files backup
%defattr(-,root,root,-)
%{_unitdir}/openstack-cinder-backup.service
%{_bindir}/cinder-backup

%changelog
openSUSE Build Service is sponsored by