File openstack-ec2-api.spec of Package openstack-ec2-api

#
# spec file for package openstack-ec2-api
#
# 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
Name:           openstack-ec2-api
Version:        11.0.0.0~xrc2~dev1
Release:        0
Summary:        OpenStack EC2 API
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/ec2-api
Source0:        ec2-api-master.tar.gz
Source1:        openstack-ec2-api.logrotate
Source2:        openstack-ec2-api.tmpfiles
Source3:        openstack-ec2-api.defaultconf
Source20:       openstack-ec2-api-api.service
Source21:       openstack-ec2-api-metadata.service
Source22:       openstack-ec2-api-s3.service
Source50:       openstack-ec2-api.README.config
BuildRequires:  openstack-macros
BuildRequires:  python3-botocore
BuildRequires:  python3-cinderclient
BuildRequires:  python3-glanceclient
BuildRequires:  python3-httplib2
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-mock
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-oslo.cache
BuildRequires:  python3-oslo.concurrency
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.service
BuildRequires:  python3-oslotest
BuildRequires:  python3-pbr
BuildRequires:  python3-stestr
Requires:       logrotate
Requires:       python3-ec2-api = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
Requires(pre):  pwdutils
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(pre):  shadow-utils
Requires(preun): systemd
%endif

%description
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

%package -n python3-ec2-api
Summary:        OpenStack EC2 API
Group:          Development/Languages/Python
Requires:       python3-Babel
Requires:       python3-Paste
Requires:       python3-PasteDeploy
Requires:       python3-Routes
Requires:       python3-SQLAlchemy
Requires:       python3-WebOb
Requires:       python3-botocore
Requires:       python3-cinderclient
Requires:       python3-cryptography
Requires:       python3-eventlet
Requires:       python3-glanceclient
Requires:       python3-greenlet
Requires:       python3-httplib2
Requires:       python3-keystoneauth1
Requires:       python3-keystoneclient
Requires:       python3-lxml
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-openstackclient
Requires:       python3-oslo.cache
Requires:       python3-oslo.concurrency
Requires:       python3-oslo.config
Requires:       python3-oslo.context
Requires:       python3-oslo.db
Requires:       python3-oslo.log
Requires:       python3-oslo.serialization
Requires:       python3-oslo.service
Requires:       python3-oslo.utils
Requires:       python3-six
Requires:       python3-sqlalchemy-migrate

%description -n python3-ec2-api
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

This package contains the Python library.

%if 0%{?with_doc}
%package doc
Summary:        OpenStack EC2 API - Documentation
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme

%description doc
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

This package contains the documentation.
%endif

%package api
Summary:        OpenStack EC2 API - API
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description api
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

This package contains the API server.

%package metadata
Summary:        OpenStack EC2 API - Metadata
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description metadata
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

This package contains the metadata server.

%package s3
Summary:        OpenStack EC2 API - S3
Group:          Development/Languages/Python
Requires:       %{name} = %{version}-%{release}

%description s3
AWS EC2 and VPC API support in standalone service for OpenStack.
At first uses nova's EC2 API for non-VPC functionality.

This package contains the S3 server.

%prep
%autosetup -p1 -n ec2-api-11.0.0.0rc2.dev1
%py_req_cleanup

%build
%{py3_build}

# build documentation
%if 0%{?with_doc}
PBR_VERSION=11.0.0.0rc2.dev1 %sphinx_build --keep-going -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=etc/ec2api/ec2api-config-generator.conf

%install
%{py3_install}

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

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

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

# install config files
install -p -D -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/ec2api/ec2api.conf.d/010-ec2api.conf
install -p -D -m 640 etc/ec2api/ec2api.conf.sample %{buildroot}%{_sysconfdir}/ec2api/ec2api.conf
install -p -D -m 640 etc/ec2api/api-paste.ini %{buildroot}%{_sysconfdir}/ec2api/
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/ec2api/README.config

# install systemd service files
install -p -D -m 644 %{SOURCE20} %{buildroot}%{_unitdir}/openstack-ec2-api-api.service
install -p -D -m 644 %{SOURCE21} %{buildroot}%{_unitdir}/openstack-ec2-api-metadata.service
install -p -D -m 644 %{SOURCE22} %{buildroot}%{_unitdir}/openstack-ec2-api-s3.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}-metadata
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-s3
%endif

%pre
%openstack_pre_user_group_create ec2-api ec2-api /sbin/nologin
exit 0

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.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 metadata
%systemd_post %{name}-metadata.service

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

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

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

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

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

%check
rm -v ec2api/tests/unit/test_hacking.py
%{__python3} -m stestr.cli --test-path ec2api/tests/unit run

%files
%license LICENSE
%dir %attr(0750, root, ec2-api) %{_sysconfdir}/ec2api
%dir %attr(0750, root, ec2-api) %{_sysconfdir}/ec2api/ec2api.conf.d/
%{_sysconfdir}/ec2api/README.config
%config(noreplace) %attr(-, root, ec2-api) %{_sysconfdir}/ec2api/ec2api.conf
%config(noreplace) %attr(-, root, ec2-api) %{_sysconfdir}/ec2api/ec2api.conf.d/010-ec2api.conf
%config(noreplace) %attr(-, root, ec2-api) %{_sysconfdir}/ec2api/api-paste.ini
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-ec2-api
%_tmpfilesdir/%name.conf
%dir %attr(0750, ec2-api, root) %{_localstatedir}/log/ec2-api
%dir %attr(0750, ec2-api, root) %{_localstatedir}/lib/ec2-api
%{_bindir}/ec2-api-manage

%files -n python3-ec2-api
%license LICENSE
%{python3_sitelib}/ec2api*
%{python3_sitelib}/ec2_api-*.egg-info

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

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

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

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

%changelog