File openstack-placement.spec of Package openstack-placement

#
# spec file for package openstack-placement
#
# 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/
#


Name:           openstack-placement
Version:        4.1.0~dev4
Release:        0
Summary:        OpenStack Placement
License:        Apache-2.0
Group:          System/Management
URL:            https://docs.openstack.org/placement/
Source0:        placement-master.tar.gz
Source1:        openstack-placement.logrotate
Source3:        openstack-placement-api.conf.sample
Source4:        openstack-placement.tmpfiles
Source5:        openstack-placement.defaultconf
Source50:       openstack-placement.README.config
BuildRequires:  openstack-macros
BuildRequires:  python3-Routes
BuildRequires:  python3-WebOb
BuildRequires:  python3-jsonschema
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-microversion_parse
BuildRequires:  python3-mock
BuildRequires:  python3-os-resource-classes
BuildRequires:  python3-os-traits
BuildRequires:  python3-oslo.concurrency
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.middleware
BuildRequires:  python3-oslo.policy
BuildRequires:  python3-oslotest
BuildRequires:  python3-paramiko
BuildRequires:  python3-pbr
BuildRequires:  python3-stestr
Requires:       logrotate
Requires:       python3-openstack-placement = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
Requires(pre):  pwdutils
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(pre):  shadow-utils
Requires(preun): systemd
%endif

%description
OpenStack Placement provides an HTTP service for managing, selecting,
and claiming providers of classes of inventory representing available
resources in a cloud.

%package -n python3-openstack-placement
Summary:        OpenStack Placement - Python module
Group:          Development/Languages/Python
Requires:       python3-Routes
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-jsonschema
Requires:       python3-keystonemiddleware
Requires:       python3-microversion_parse
Requires:       python3-os-resource-classes
Requires:       python3-os-traits
Requires:       python3-oslo.concurrency
Requires:       python3-oslo.config
Requires:       python3-oslo.context
Requires:       python3-oslo.db
Requires:       python3-oslo.log
Requires:       python3-oslo.middleware
Requires:       python3-oslo.policy
Requires:       python3-oslo.serialization
Requires:       python3-oslo.upgradecheck
Requires:       python3-oslo.utils
Requires:       python3-pbr
Requires:       python3-requests
Requires:       python3-six
Requires:       python3-sqlalchemy
Requires:       python3-wsgi_intercept

%description -n python3-openstack-placement
This package contains the core Python module of OpenStack Placement.

%package doc
Summary:        OpenStack Placement - Documentation
Group:          Development/Languages/Python
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinx-feature-classification
BuildRequires:  python3-sphinxcontrib-actdiag
BuildRequires:  python3-sphinxcontrib-apidoc
BuildRequires:  python3-sphinxcontrib-seqdiag

%description doc
This package contains the documentation of OpenStack Placement.

%package api
Summary:        OpenStack Compute (Placement) - API
# prereq for creating the right openstack-placement user/group
Group:          System/Management
Requires:       %{name} = %{version}
Requires(pre):  %{name} = %{version}
%if 0%{?suse_version}
BuildRequires:  apache2-mod_wsgi-python3
Requires:       apache2-mod_wsgi-python3
%else
BuildRequires:  python3-mod_wsgi
Requires:       python3-mod_wsgi
%endif

%description api
This package contains the OpenStack Placement API.

%prep
%autosetup -p1 -n openstack-placement-4.1.0.dev4
%py_req_cleanup

%build
python3 setup.py build

# doc
PYTHONPATH=. PBR_VERSION=4.1.0.dev4 %sphinx_build -b man doc/source doc/build/man
# sample config
PYTHONPATH=. oslo-config-generator --config-file=etc/placement/config-generator.conf
# sample policy
PYTHONPATH=. oslopolicy-sample-generator --config-file=etc/placement/policy-generator.conf

%install
python3 setup.py install --root %{buildroot} --prefix %{_prefix}

### directories
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement/images
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement/instances
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement/keys
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement/networks
install -d -m 755 %{buildroot}%{_localstatedir}/lib/placement/tmp
install -d -m 750 %{buildroot}%{_localstatedir}/log/placement
install -d -m 700 %{buildroot}%{_rundir}/placement
install -d -m 700 %{buildroot}%{_localstatedir}/cache/placement
install -D -m 644 %{SOURCE4} %{buildroot}/%_tmpfilesdir/%name.conf
%if 0%{?suse_version}
install -d -m 755 %{buildroot}/srv/www/openstack-placement-api
%endif
install -d %{buildroot}%apache_site_dir

# apache vhost sample configs
install -p -D -m 644 %{SOURCE3} %{buildroot}%apache_site_dir

# WSGI
%if 0%{?suse_version}
install -p -D -m 644 %{buildroot}/%{_bindir}/placement-api %{buildroot}/srv/www/openstack-placement-api/app.wsgi
%endif

### configuration files
install -d -m 755 %{buildroot}%{_sysconfdir}/placement/
#mv %{buildroot}/usr/etc/placement/* %{buildroot}%{_sysconfdir}/placement/
install -d -m 755 %{buildroot}%{_sysconfdir}/placement/placement.conf.d
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/placement/README.config
install -p -D -m 640 etc/placement/placement.conf.sample %{buildroot}%{_sysconfdir}/placement/placement.conf
install -p -D -m 640 etc/placement/policy.yaml.sample %{buildroot}%{_sysconfdir}/placement/policy.yaml
# bash-completion/logrotate/etc.
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

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

### set default configuration
install -p -D -m 640 %{SOURCE5} %{buildroot}%{_sysconfdir}/placement/placement.conf.d/010-placement.conf

%check
PYTHONPATH=. python3 -m stestr.cli --test-path placement/tests/unit run

%pre
%openstack_pre_user_group_create placement placement

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

%post api
%systemd_post openstack-placement-api.service

%preun api
%systemd_preun openstack-placement-api.service

%postun api
%systemd_postun_with_restart openstack-placement-api.service

%files
%license LICENSE
%doc README.rst
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %{_sysconfdir}/placement
%dir %{_sysconfdir}/placement/placement.conf.d/
%{_sysconfdir}/placement/README.config
%dir %attr(0750, placement, placement) %{_localstatedir}/cache/placement
%config(noreplace) %attr(0640, root, placement) %{_sysconfdir}/placement/placement.conf
%config(noreplace) %attr(0640, root, placement) %{_sysconfdir}/placement/placement.conf.d/010-placement.conf
%config %attr(0640, root, placement) %{_sysconfdir}/placement/policy.yaml
%dir %attr(0755, placement, placement) %{_localstatedir}/lib/placement
%dir %attr(0750, placement, placement) %{_localstatedir}/log/placement
%_tmpfilesdir/%name.conf
%{_bindir}/placement-manage
%{_bindir}/placement-status
%{_mandir}/man1/openstack-placement.1%{?ext_man}
%dir %attr(0755, root, root) %{_localstatedir}/lib/placement/images
%dir %attr(0755, placement, root) %{_localstatedir}/lib/placement/instances
%dir %attr(0755, root, root) %{_localstatedir}/lib/placement/keys
%dir %attr(0755, root, root) %{_localstatedir}/lib/placement/networks
%dir %attr(0755, root, root) %{_localstatedir}/lib/placement/tmp

%files -n python3-openstack-placement
%license LICENSE
%{python3_sitelib}/placement/
%{python3_sitelib}/placement_db_tools/
%{python3_sitelib}/openstack_placement*egg-info

%files api
%license LICENSE
%{_bindir}/placement-api
%{apache_site_dir}/openstack-placement-api.conf.sample
%if 0%{?suse_version}
/srv/www/
/srv/www/openstack-placement-api/
%endif

%changelog