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

# spec file for package openstack-ec2-api
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# 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

%define component ec2-api
%define groupname %{component}
%define username %{component}

%define version_unconverted 7.1.1.dev4

Name:           openstack-%{component}
Version:        7.1.1~dev4
Release:        0
Summary:        OpenStack EC2 API
License:        Apache-2.0
Group:          System/Management
Source1:        %{name}-api.service
Source2:        %{name}-metadata.service
Source3:        %{name}-s3.service
Source6:        %{name}.logrotate
Source10:       %name.conf
Source50:       README.config
BuildRequires:  systemd
BuildRequires:  systemd-rpm-macros
Source99:       rpmlintrc
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-pbr
BuildRequires:  python-setuptools
# for oslo-config-generator
BuildRequires:  python-oslo.concurrency
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.db
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.messaging
BuildRequires:  python-oslo.service
Requires:       logrotate
Requires:       python >= 2.7
Requires:       python-ec2api = %{version}
Requires(post): sysconfig
Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Requires(pre):  %insserv_prereq %fillup_prereq

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

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

%description -n python-ec2api
This package contains the core Python module of OpenStack EC2 API.

%package test
Summary:        OpenStack EC2 API - Testsuite
Group:          System/Management
Requires:       python-fixtures
Requires:       python-mock
Requires:       python-nose
Requires:       python-oslotest
Requires:       python-python-subunit
Requires:       python-testrepository
Requires:       python-testtools

%description test
The OpenStack EC2 API testsuite. It is used to verify the functionality of
OpenStack EC2 API and its components.

%package api
Summary:        OpenStack EC2 API - API
# prereq for creating the right openstack-nova user/group
Group:          System/Management
PreReq:         %{name} = %{version}

%description api
This package contains the OpenStack EC2 API - API service.

%package metadata
Summary:        OpenStack EC2 API - metadata
# prereq for creating the right openstack-nova user/group
Group:          System/Management
PreReq:         %{name} = %{version}

%description metadata
This package contains the OpenStack EC2 API - metadata service.

%package s3
Summary:        OpenStack EC2 API - s3
# prereq for creating the right openstack-nova user/group
Group:          System/Management
PreReq:         %{name} = %{version}
# openstack-nova-objectstore was removed in Mitaka (v13) from Nova
Provides:       openstack-nova-objectstore = 12.5
Obsoletes:      openstack-nova-objectstore < 12.5

%description s3
This package contains the OpenStack EC2 API - s3 service.

%setup -q -n %{component}-%{version_unconverted}

python build
oslo-config-generator --config-file=etc/ec2api/ec2api-config-generator.conf

python install --root %{buildroot} --prefix %{_prefix}

### directories
install -d -m 755 %{buildroot}%{_localstatedir}/lib/ec2-api
install -d -m 750 %{buildroot}%{_localstatedir}/log/ec2-api
install -d -m 700 %{buildroot}%{_rundir}/ec2-api
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf

### configuration files
install -p -D -m 640 %{SOURCE50} %{buildroot}%{_sysconfdir}/ec2api/README.config
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/

### extra config dirs
install -d -m 755 %{buildroot}%{_sysconfdir}/ec2api/ec2api.conf.d/

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

### systemd unit files
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir}
install -p -D -m 444 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}-api.service
install -p -D -m 444 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}-metadata.service
install -p -D -m 444 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}-s3.service
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

### set default configuration
%define ec2api_conf %{buildroot}%{_sysconfdir}/ec2api/ec2api.conf.d/010-ec2api.conf
crudini --set %{ec2api_conf} DEFAULT log_dir /var/log/ec2-api
crudini --set %{ec2api_conf} DEFAULT state_path /var/lib/ec2-api

%openstack_pre_user_group_create %{username} %{groupname}

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

%pre api
%service_add_pre %{name}-api.service

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

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

%postun api
%restart_on_update %{name}-api.service
%service_del_postun %{name}-api.service

%pre metadata
%service_add_pre %{name}-metadata.service

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

%post metadata
%service_add_post %{name}-metadata.service

%postun metadata
%restart_on_update %{name}-metadata.service
%service_del_postun %{name}-metadata.service

%pre s3
%service_add_pre %{name}-s3.service

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

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

%postun s3
%restart_on_update %{name}-s3.service
%service_del_postun %{name}-s3.service

%doc README.rst
%license LICENSE 
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %{_sysconfdir}/ec2api
%dir %{_sysconfdir}/ec2api/ec2api.conf.d/
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/ec2api/api-paste.ini
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/ec2api/ec2api.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/ec2api/ec2api.conf.d/010-ec2api.conf
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/ec2-api
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/lib/ec2-api


%files -n python-ec2api
%license LICENSE
# Part of test subpackage
%exclude %{python_sitelib}/ec2api/tests/unit/

%files api
%license LICENSE

%files metadata
%license LICENSE

%files s3
%license LICENSE

%files test
%license LICENSE