File openstack-monasca-log-api.spec of Package openstack-monasca-log-api

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


%define sname           monasca-log-api
Name:           openstack-monasca-log-api
Version:        2.7.1~dev7
Release:        0
Summary:        OpenStack Monasca Log Api plugin
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://wiki.openstack.org/wiki/Monasca
Source0:        monasca-log-api-stable-rocky.tar.gz
Source1:        %{name}-wsgi.conf
BuildRequires:  fdupes
BuildRequires:  openstack-macros
BuildRequires:  python-falcon
BuildRequires:  python-fixtures
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-mock
BuildRequires:  python-monasca-common
BuildRequires:  python-monasca-statsd
BuildRequires:  python-os-testr
BuildRequires:  python-oslo.config
BuildRequires:  python-oslo.context
BuildRequires:  python-oslo.log
BuildRequires:  python-oslo.middleware
BuildRequires:  python-oslo.serialization
BuildRequires:  python-oslo.utils
BuildRequires:  python-oslotest
BuildRequires:  python-pbr
BuildRequires:  python-simplejson
Requires:       python-%{sname} = %{version}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  apache2-mod_wsgi
Requires:       apache2-mod_wsgi
%else
BuildRequires:  mod_wsgi
Requires:       mod_wsgi
%endif

%description
monasca-log-api is a RESTful API server receiving logs from the deployed
log agents.

%package -n python-%{sname}
Summary:        OpenStack Monasca Log Api plugin
Group:          Development/Languages/Python
Requires:       python-eventlet
Requires:       python-falcon
Requires:       python-keystonemiddleware
Requires:       python-monasca-common
Requires:       python-monasca-statsd
Requires:       python-oslo.config
Requires:       python-oslo.context
Requires:       python-oslo.log
Requires:       python-oslo.middleware
Requires:       python-oslo.serialization
Requires:       python-oslo.utils
Requires:       python-pbr
BuildArch:      noarch

%description -n python-%{sname}
monasca-log-api is a RESTful API server receiving logs from the deployed
log agents.

%prep
%autosetup -n %{sname}-2.7.1.dev7
%py_req_cleanup

%build
%py2_build
oslo-config-generator \
  --config-file config-generator/monasca-log-api.conf \
  --output-file etc/monasca/log-api.conf

%install
%py2_install

## directories
install -d -m 755 %{buildroot}%{_sysconfdir}/monasca
install -d -m 750 %{buildroot}%{_var}/log/monasca
install -d -m 755 %{buildroot}%{_var}/lib/monasca-log-api
install -d -m 755 %{buildroot}%{apache_site_dir}

## configuration directory
find %{buildroot}%{_prefix}%{_sysconfdir}/ -type f -name 'log-api-*' -print0 | xargs -0 mv -t %{buildroot}%{_sysconfdir}/monasca/
rm -rf %{buildroot}%{_prefix}%{_sysconfdir}/monasca

# configuration bits
# NOTEtrebskit) file names are hardcoded in monasca-log-api
# should be refactored when Bug#1670277 is resolved
install -D -m 640 etc/monasca/log-api.conf %{buildroot}%{_sysconfdir}/monasca/log-api.conf
install -D -m 640 etc/monasca/log-api-paste.ini %{buildroot}%{_sysconfdir}/monasca/log-api-paste.ini
install -D -m 640 etc/monasca/log-api-logging.conf %{buildroot}%{_sysconfdir}/monasca/log-api-logging.conf

## install apache configuration
install -p -D -m 640 %{SOURCE1} %{buildroot}%{apache_site_dir}/%{sname}.conf.sample
sed -e "
    s|__APACHE_NAME__|%{apache_name}|g;
" -i %{buildroot}%{apache_site_dir}/%{sname}.conf.sample

# there is extra directory /etc/monasca/monasca created, get rid of it
rm -rf %{_sysconfdir}/monasca/monasca || true

rm -f %{buildroot}%{python2_sitelib}/monasca_log_api/.gitignore

%fdupes %{buildroot}%{python2_sitelib}

%check
find . -type f -name *.pyc -delete
OS_TEST_PATH=./monasca_log_api/tests PYTHONPATH=. ostestr

%pre
%openstack_pre_user_group_create monasca-log-api monasca

%postun
if [ $1 -eq 0 ] ; then
  getent passwd monasca-log-api > /dev/null
  if [ "$?" == "0" ] ; then
      userdel monasca-log-api
  fi
fi

%files
%doc README.rst ChangeLog
%{_bindir}/monasca-log-api
%{_bindir}/monasca-log-api-wsgi

%dir %attr(-, root, monasca) %{_sysconfdir}/monasca
%dir %attr(0750, root, monasca) %{_var}/log/monasca
%dir %attr(0750, monasca-log-api, monasca) %{_var}/lib/monasca-log-api

%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/log-api.conf
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/log-api-logging.conf
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/log-api-paste.ini
%config(noreplace) %attr(0640, root, monasca) %{apache_site_dir}/%{sname}.conf.sample

%files -n python-%{sname}
%license LICENSE
%{python2_sitelib}/monasca_log_api
%{python2_sitelib}/*.egg-info

%changelog
openSUSE Build Service is sponsored by