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:        17.0.0.0~xrc2~dev10
Release:        0
Summary:        OpenStack Block Storage (Cinder)
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://launchpad.net/cinder
Source0:        cinder-stable-victoria.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:        openstack-cinder.sudoers
Source7:        openstack-cinder.tmpfiles
Source8:        openstack-cinder.defaultconf
Source50:       openstack-cinder.README.config
BuildRequires:  openstack-macros
BuildRequires:  python3-PyMySQL
BuildRequires:  python3-SQLAlchemy
BuildRequires:  python3-SQLAlchemy-Utils
BuildRequires:  python3-barbicanclient
BuildRequires:  python3-castellan
BuildRequires:  python3-cryptography
BuildRequires:  python3-cursive
BuildRequires:  python3-ddt
BuildRequires:  python3-decorator
BuildRequires:  python3-defusedxml
BuildRequires:  python3-fixtures
BuildRequires:  python3-glanceclient
BuildRequires:  python3-google-api-python-client
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-lxml
BuildRequires:  python3-mock
BuildRequires:  python3-novaclient
BuildRequires:  python3-oauth2client
BuildRequires:  python3-os-brick
BuildRequires:  python3-os-win
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.i18n
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.policy
BuildRequires:  python3-oslo.reports
BuildRequires:  python3-oslo.upgradecheck
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-oslo.versionedobjects
BuildRequires:  python3-oslo.vmware
BuildRequires:  python3-oslotest
BuildRequires:  python3-osprofiler
BuildRequires:  python3-paramiko
BuildRequires:  python3-psycopg2
BuildRequires:  python3-pyparsing
BuildRequires:  python3-requests
BuildRequires:  python3-retrying
BuildRequires:  python3-rtslib-fb
BuildRequires:  python3-setuptools
BuildRequires:  python3-sqlalchemy-migrate
BuildRequires:  python3-suds-jurko
BuildRequires:  python3-swiftclient
BuildRequires:  python3-tabulate
BuildRequires:  python3-taskflow
BuildRequires:  python3-testresources
BuildRequires:  python3-testscenarios
BuildRequires:  python3-testtools
BuildRequires:  python3-tooz
BuildRequires:  python3-zstd
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-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 python3-cinder
Summary:        OpenStack Volume Python libraries
Group:          Development/Languages/Python
Requires:       python3-Paste
Requires:       python3-PasteDeploy
Requires:       python3-Routes
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-barbicanclient
Requires:       python3-castellan
Requires:       python3-cryptography
Requires:       python3-cursive
Requires:       python3-decorator
Requires:       python3-defusedxml
Requires:       python3-eventlet
Requires:       python3-glanceclient
Requires:       python3-google-api-python-client
Requires:       python3-httplib2
Requires:       python3-iso8601
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystoneclient
Requires:       python3-keystonemiddleware
Requires:       python3-lxml
Requires:       python3-novaclient
Requires:       python3-oauth2client
Requires:       python3-os-brick
Requires:       python3-os-win
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.privsep
Requires:       python3-oslo.reports
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-oslo.vmware
Requires:       python3-osprofiler
Requires:       python3-paramiko
Requires:       python3-psutil
Requires:       python3-pyparsing
Requires:       python3-pytz
Requires:       python3-requests
Requires:       python3-retrying
Requires:       python3-rtslib-fb
Requires:       python3-simplejson
Requires:       python3-six
Requires:       python3-sqlalchemy-migrate
Requires:       python3-stevedore
Requires:       python3-suds-jurko
Requires:       python3-swiftclient
Requires:       python3-tabulate
Requires:       python3-taskflow
Requires:       python3-tooz
Requires:       python3-zstd
Requires:       sudo

%description -n python3-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/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-eventlet
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinx-feature-classification
BuildRequires:  python3-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:       python3-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) - Volume
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}
%if 0%{?suse_version}
Requires:       nfs-client
%else
Requires:       nfs-utils
%endif

%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 -p1 -n cinder-17.0.0.0rc2.dev10
%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
%{py3_build}
# build documentation
%if 0%{?with_doc}
export PYTHONPATH="$( pwd ):$PYTHONPATH"
PBR_VERSION=17.0.0.0rc2.dev10 %sphinx_build --keep-going -b html doc/source doc/build/html || :
PBR_VERSION=17.0.0.0rc2.dev10 %sphinx_build --keep-going -b man doc/source doc/build/man || :
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 --output-file etc/cinder/cinder.conf
# generate the sample policy
PYTHONPATH=. oslopolicy-sample-generator --config-file=tools/config/cinder-policy-generator.conf --output etc/cinder/policy.json

%install
%{py3_install}

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

# install tmpfiles
install -D -m 644 %{SOURCE7} %{buildroot}/%_tmpfilesdir/%name.conf

# install config files
install -d -m 755 %{buildroot}%{_sysconfdir}/%{service}
install -p -D -m 644 etc/%{service}/{cinder.conf,api-paste.ini,policy.json,resource_filters.json,rootwrap.conf} %{buildroot}%{_sysconfdir}/%{service}/
cp -a etc/cinder/rootwrap.d/ %{buildroot}%{_sysconfdir}/%{service}/
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/%{service}/README.config
install -p -D -m 640 %{SOURCE8} %{buildroot}%{_sysconfdir}/cinder/cinder.conf.d/010-cinder.conf

# install systemd service files
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 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}-scheduler
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-volume
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-backup
%endif

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

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

# man pages
%if 0%{?with_doc}
mkdir -p %{buildroot}%{_mandir}/man1
install -p -D -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1/
%endif

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

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

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

%check
stestr run

%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
%dir %attr(0750, root, cinder) %{_sysconfdir}/cinder/cinder.conf.d/
%{_sysconfdir}/%{service}/README.config
%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) %attr(0640, root, %{service}) %{_sysconfdir}/cinder/cinder.conf.d/010-cinder.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-%{service}
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-%{service}
%config(noreplace) %{_sysconfdir}/%{service}/policy.json
%config(noreplace) %{_sysconfdir}/%{service}/resource_filters.json
%_tmpfilesdir/%name.conf
%dir %attr(0750, %{service}, root) %{_sysconfdir}/%{service}/rootwrap.d/
%dir %attr(0750, %{service}, root) %{_localstatedir}/log/%{service}
%dir %attr(0750, %{service}, root) %{_localstatedir}/lib/%{service}
%{_bindir}/cinder-manage
%{_bindir}/cinder-rootwrap
%{_bindir}/cinder-rtstool
%{_bindir}/cinder-volume-usage-audit
%{_bindir}/cinder-status
%if 0%{?with_doc}
%{_mandir}/man1/cinder-manage.1.gz
%{_mandir}/man1/cinder-status.1.gz
%endif

%files -n python3-cinder
%license LICENSE
%{python3_sitelib}/cinder*

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

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

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

%files volume
%license LICENSE
%dir %{_sysconfdir}/%{service}/%{service}-volume.conf.d/
%config %{_sysconfdir}/%{service}/rootwrap.d/volume.filters
%{_bindir}/cinder-volume
%{_unitdir}/openstack-cinder-volume.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-volume
%endif

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

%changelog
openSUSE Build Service is sponsored by