File openstack-magnum.spec of Package openstack-magnum

#
# spec file for package openstack-magnum
#
# Copyright (c) 2023 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
Name:           openstack-magnum
Version:        14.0.1~dev4
Release:        0
Epoch:          0
Summary:        OpenStack container orchestration engines (Magnum)
License:        Apache-2.0
URL:            https://docs.openstack.org/magnum
Source0:        magnum-stable-yoga.tar.gz
Source1:        openstack-magnum.logrotate
Source2:        openstack-magnum.sudoers
Source3:        openstack-magnum.tmpfiles
Source4:        openstack-magnum.defaultconf
# systemd
Source20:       openstack-magnum-api.service
Source21:       openstack-magnum-conductor.service
Source50:       openstack-magnum.README.config
BuildRequires:  openstack-macros
BuildRequires:  python3-barbicanclient
BuildRequires:  python3-glanceclient
BuildRequires:  python3-heatclient
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-octaviaclient
BuildRequires:  python39-PyYAML
BuildRequires:  python39-SQLAlchemy
BuildRequires:  python39-WSME
BuildRequires:  python39-WebOb
BuildRequires:  python39-Werkzeug
BuildRequires:  python39-docker
BuildRequires:  python39-keystoneauth1
BuildRequires:  python39-keystonemiddleware
BuildRequires:  python39-kubernetes
BuildRequires:  python39-marathon
BuildRequires:  python39-mock
BuildRequires:  python39-oslo.concurrency
BuildRequires:  python39-oslo.config
BuildRequires:  python39-oslo.context
BuildRequires:  python39-oslo.db
BuildRequires:  python39-oslo.i18n
BuildRequires:  python39-oslo.log
BuildRequires:  python39-oslo.messaging
BuildRequires:  python39-oslo.middleware
BuildRequires:  python39-oslo.policy
BuildRequires:  python39-oslo.reports
BuildRequires:  python39-oslo.serialization
BuildRequires:  python39-oslo.service
BuildRequires:  python39-oslo.upgradecheck
BuildRequires:  python39-oslo.utils
BuildRequires:  python39-oslo.versionedobjects
BuildRequires:  python39-oslotest
BuildRequires:  python39-osprofiler
BuildRequires:  python39-pbr
BuildRequires:  python39-pecan
BuildRequires:  python39-stestr
BuildRequires:  python39-taskflow
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-magnum = %{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(preun):systemd
%endif
%if 0%{?suse_version}
Requires(pre):  pwdutils
%endif
%if 0%{?rdo}
Requires(pre):  shadow-utils
%endif

%description
Magnum is an OpenStack project which offers container orchestration engines for
deploying and managing containers as first class resources in OpenStack.

%package -n python3-magnum
Summary:        OpenStack container orchestration engines (Magnum) - python module
Group:          Development/Languages/Python
Requires:       python3-barbicanclient
Requires:       python3-glanceclient
Requires:       python3-heatclient
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-octaviaclient
Requires:       python39-Babel
Requires:       python39-PyYAML
Requires:       python39-SQLAlchemy
Requires:       python39-WSME
Requires:       python39-WebOb
Requires:       python39-Werkzeug
Requires:       python39-alembic
Requires:       python39-cliff
Requires:       python39-cryptography
Requires:       python39-decorator
Requires:       python39-docker
Requires:       python39-eventlet
Requires:       python39-iso8601
Requires:       python39-jsonpatch
Requires:       python39-keystoneauth1
Requires:       python39-keystonemiddleware
Requires:       python39-kubernetes
Requires:       python39-marathon
Requires:       python39-netaddr
Requires:       python39-oslo.concurrency
Requires:       python39-oslo.config
Requires:       python39-oslo.context
Requires:       python39-oslo.db
Requires:       python39-oslo.i18n
Requires:       python39-oslo.log
Requires:       python39-oslo.messaging
Requires:       python39-oslo.middleware
Requires:       python39-oslo.policy
Requires:       python39-oslo.reports
Requires:       python39-oslo.serialization
Requires:       python39-oslo.service
Requires:       python39-oslo.upgradecheck
Requires:       python39-oslo.utils
Requires:       python39-oslo.versionedobjects
Requires:       python39-osprofiler
Requires:       python39-pecan
Requires:       python39-pycadf
Requires:       python39-requests
Requires:       python39-setuptools
Requires:       python39-six
Requires:       python39-stevedore
Requires:       python39-taskflow
Requires:       sudo

%description -n python3-magnum
Magnum is an OpenStack project which offers container orchestration engines for
deploying and managing containers as first class resources in OpenStack.

This package contains the python module.

%if 0%{?with_doc}
%package doc
Summary:        OpenStack container orchestration engines (Magnum) - documentation
Group:          Documentation/HTML
BuildRequires:  python39-Sphinx
BuildRequires:  python39-openstackdocstheme

%description doc
Magnum is an OpenStack project which offers container orchestration engines for
deploying and managing containers as first class resources in OpenStack.

This package contains the documentation.
%endif

%package api
Summary:        OpenStack container orchestration engines (Magnum) - API
Group:          Development/Languages/Python
Requires:       python3-magnum = %{epoch}:%{version}-%{release}

%description api
Magnum is an OpenStack project which offers container orchestration engines for
deploying and managing containers as first class resources in OpenStack.

This package contains the API server.

%package conductor
Summary:        OpenStack container orchestration engines (Magnum) - Conductor
Group:          Development/Languages/Python
Requires:       python3-magnum = %{epoch}:%{version}-%{release}

%description conductor
Magnum is an OpenStack project which offers container orchestration engines for
deploying and managing containers as first class resources in OpenStack.

This package contains the conductor server.

%prep
%autosetup -p1 -n magnum-14.0.1.dev4
%py_req_cleanup

%build
%{py3_build}

# build documentation
%if 0%{?with_doc}
PYTHONPATH=. PBR_VERSION=14.0.1.dev4 %sphinx_build --keep-going -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif

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

%install
%{py3_install}

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

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

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

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

# install config files
mv %{buildroot}/%{_prefix}/%{_sysconfdir}/magnum/* %{buildroot}%{_sysconfdir}/magnum/
install -p -D -m 640 %{SOURCE4} %{buildroot}%{_sysconfdir}/magnum/magnum.conf.d/010-magnum.conf
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/magnum/README.config
install -p -D -m 644 etc/magnum.conf.sample %{buildroot}%{_sysconfdir}/magnum/magnum.conf
install -p -D -m 644 etc/magnum/policy.json.sample %{buildroot}%{_sysconfdir}/magnum/policy.json
install -p -D -m 644 etc/magnum/api-paste.ini %{buildroot}%{_sysconfdir}/magnum/

# install systemd service files
install -p -D -m 644 %{SOURCE20} %{buildroot}%{_unitdir}/openstack-magnum-api.service
install -p -D -m 644 %{SOURCE21} %{buildroot}%{_unitdir}/openstack-magnum-conductor.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}-conductor
%endif

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

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

%check
# we don't want to depend on hacking
rm magnum/tests/unit/test_hacking.py

export LC_ALL=en_US.UTF-8
export EDITOR=/bin/true
python3 -m stestr.cli run --concurrency 1

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

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

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

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

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

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

%files
%license LICENSE
%dir %attr(0750, magnum, magnum) %{_localstatedir}/log/magnum
%dir %attr(0750, magnum, magnum) %{_localstatedir}/lib/magnum
%dir %attr(0750, magnum, magnum) %{_localstatedir}/lib/magnum/certificates
%dir %attr(0750, magnum, magnum) %{_localstatedir}/cache/magnum
%dir %attr(0750, root, magnum) %{_sysconfdir}/magnum
%dir %attr(0750, root, magnum) %{_sysconfdir}/magnum/magnum.conf.d/
%{_sysconfdir}/magnum/README.config
%config(noreplace) %attr(0640, root, magnum) %{_sysconfdir}/magnum/magnum.conf
%config(noreplace) %attr(0640, root, magnum) %{_sysconfdir}/magnum/magnum.conf.d/010-magnum.conf
%config(noreplace) %attr(0640, root, magnum) %{_sysconfdir}/magnum/api-paste.ini
%config(noreplace) %{_sysconfdir}/magnum/policy.json
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-magnum
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-magnum
%_tmpfilesdir/%name.conf
%{_bindir}/magnum-db-manage
%{_bindir}/magnum-driver-manage
%{_bindir}/magnum-status

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

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

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

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

%changelog
openSUSE Build Service is sponsored by