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

#
# spec file for package openstack-monasca-api
#
# Copyright (c) 2020 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 https://bugs.opensuse.org/
#


Name:           openstack-monasca-api
Version:        3.2.0~dev39
Release:        0
Summary:        Monasca REST API
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://wiki.openstack.org/wiki/Monasca
Source0:        monasca-api-master.tar.gz
Source2:        api-logging.conf
Source3:        api-config.ini
Source4:        api-wsgi.conf
Source5:        api-wsgi.py
BuildRequires:  fdupes
BuildRequires:  openstack-macros
BuildRequires:  python3-PasteDeploy
BuildRequires:  python3-SQLAlchemy
BuildRequires:  python3-cassandra-driver
BuildRequires:  python3-eventlet
BuildRequires:  python3-falcon
BuildRequires:  python3-fixtures
BuildRequires:  python3-httplib2
BuildRequires:  python3-influxdb
BuildRequires:  python3-keystoneclient
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-mock
BuildRequires:  python3-monasca-common
BuildRequires:  python3-nose
BuildRequires:  python3-oslo.config
BuildRequires:  python3-oslo.context
BuildRequires:  python3-oslo.db
BuildRequires:  python3-oslo.log
BuildRequires:  python3-oslo.middleware
BuildRequires:  python3-oslo.serialization
BuildRequires:  python3-oslo.upgradecheck
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-oslotest
BuildRequires:  python3-pbr
BuildRequires:  python3-pyparsing
BuildRequires:  python3-python-subunit
BuildRequires:  python3-requests-mock
BuildRequires:  python3-simplejson
BuildRequires:  python3-six
BuildRequires:  python3-stestr
BuildRequires:  python3-testrepository
BuildRequires:  python3-testscenarios
BuildRequires:  python3-testtools
BuildRequires:  python3-voluptuous
Requires:       python3-monasca-api = %{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  apache2
Requires:       apache2-mod_wsgi-python3
%else
BuildRequires:  python3-mod_wsgi
Requires:       python3-mod_wsgi
%endif

%description
The Monasca API provides a RESTful JSON interface for interacting with
and managing monitoring related resources.

%package -n python3-monasca-api
Summary:        Monasca REST API
Group:          Development/Languages/Python
Requires:       python3-PasteDeploy
Requires:       python3-SQLAlchemy
Requires:       python3-eventlet
Requires:       python3-falcon
Requires:       python3-influxdb
Requires:       python3-keystoneclient
Requires:       python3-keystonemiddleware
Requires:       python3-monasca-common
Requires:       python3-oslo.config
Requires:       python3-oslo.context
Requires:       python3-oslo.db
Requires:       python3-oslo.log
Requires:       python3-oslo.middleware
Requires:       python3-oslo.serialization
Requires:       python3-oslo.upgradecheck
Requires:       python3-oslo.utils
Requires:       python3-pbr
Requires:       python3-pyparsing
Requires:       python3-simplejson
Requires:       python3-six
Requires:       python3-voluptuous
BuildArch:      noarch

%description -n python3-monasca-api
The Monasca API provides a RESTful JSON interface for interacting with
and managing monitoring related resources.

%prep
%autosetup -p1 -n monasca-api-3.2.0.dev39
%py_req_cleanup

%build
%py3_build
PYTHONPATH=. oslo-config-generator \
  --config-file config-generator/monasca-api.conf \
  --output-file etc/monasca-api.conf.sample

%install
%py3_install

# create all necessary directories
install -d -m 755 %{buildroot}%{_usr}/share/monasca-api/vertica
install -d -m 755 %{buildroot}%{_usr}/share/monasca-api/schema
install -d -m 755 %{buildroot}%{_sysconfdir}/monasca
install -d -m 755 %{buildroot}%{_var}/lib/monasca-api
install -d -m 755 %{buildroot}%{_var}/log/monasca-api
install -d -m 755 %{buildroot}%{apache_site_dir}

# copy embedded configuration files

## copy configs
install -D -m 644 etc/monasca-api.conf.sample %{buildroot}/%{_sysconfdir}/monasca/monasca-api.conf
install -D -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/monasca/api-logging.conf
install -D -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/monasca/api-config.ini
# some files from the devstack dir needed to do basic deployment
install -D -m 640 devstack/files/cassandra/monasca_schema.cql %{buildroot}%{_usr}/share/monasca-api/schema/
install -D -m 640 devstack/files/vertica/mon_alarms.sql %{buildroot}%{_usr}/share/monasca-api/vertica/
install -D -m 640 devstack/files/vertica/mon_metrics.sql %{buildroot}%{_usr}/share/monasca-api/vertica/
install -D -m 640 devstack/files/vertica/users.sql %{buildroot}%{_usr}/share/monasca-api/vertica/
install -D -m 640 devstack/files/vertica/roles.sql %{buildroot}%{_usr}/share/monasca-api/vertica/

## install apache configuration
install -p -D -m 640 %{SOURCE4} %{buildroot}%{apache_site_dir}/monasca-api.conf.sample

## install WSGIScriptAlias
install -D -m 755 %{SOURCE5} %{buildroot}%{_bindir}/monasca-api-wsgi.py

# remove duplicates
%fdupes %{buildroot}%{python3_sitelib}/monasca_api

%check
find . -type f -name *.pyc -delete
%{__python3} -m stestr.cli --test-path=./monasca_api/tests run

%pre
%openstack_pre_user_group_create monasca-api monasca /sbin/nologin

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

%files
%{_bindir}/monasca-api
%{_bindir}/monasca-api-wsgi
%{_bindir}/monasca-api-wsgi.py
%{_bindir}/monasca-status
%{_bindir}/monasca_db

%dir %attr(-, root, monasca) %{_sysconfdir}/monasca
%dir %attr(0750, monasca-api, monasca) %{_var}/lib/monasca-api
%dir %attr(0750, monasca-api, monasca) %{_var}/log/monasca-api
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/monasca-api
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/monasca-api/schema
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/monasca-api/vertica
%{_usr}/share/monasca-api/schema/*
%{_usr}/share/monasca-api/vertica/*
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/monasca-api.conf
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/api-logging.conf
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/api-config.ini
%config(noreplace) %attr(0640, root, monasca) %{apache_site_dir}/monasca-api.conf.sample

%files -n python3-monasca-api
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/monasca_api
%{python3_sitelib}/*.egg-info

%changelog