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

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


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

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

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

%description -n python-%{component}
The Monasca API provides a RESTful JSON interface for interacting with
and managing monitoring related resources.

%prep
%autosetup -n %{component}-2.5.0
%py_req_cleanup

%build
%py2_build

%install
%py2_install

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

# copy embedded configuration files

## copy configs
install -D -m 640 %{SOURCE1} %{buildroot}%{_sysconfdir}/monasca/api-config.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/schema/mon_postgresql.sql %{buildroot}%{_usr}/share/%{component}/schema/
install -D -m 640 devstack/files/schema/mon_mysql.sql %{buildroot}%{_usr}/share/%{component}/schema/
install -D -m 640 devstack/files/cassandra/monasca_schema.cql %{buildroot}%{_usr}/share/%{component}/schema/
install -D -m 640 devstack/files/vertica/mon_alarms.sql %{buildroot}%{_usr}/share/%{component}/vertica/
install -D -m 640 devstack/files/vertica/mon_metrics.sql %{buildroot}%{_usr}/share/%{component}/vertica/
install -D -m 640 devstack/files/vertica/users.sql %{buildroot}%{_usr}/share/%{component}/vertica/
install -D -m 640 devstack/files/vertica/roles.sql %{buildroot}%{_usr}/share/%{component}/vertica/

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

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

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

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

%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
%defattr(-, root, root)
%{_bindir}/monasca-api
%{_bindir}/monasca-api-wsgi.py

%dir %attr(-, root, monasca) %{_sysconfdir}/monasca
%dir %attr(0750, monasca-api, monasca) %{_var}/lib/%{component}
%dir %attr(0750, monasca-api, monasca) %{_var}/log/%{component}
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/%{component}
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/%{component}/schema
%dir %attr(0755, monasca-api, monasca) %{_usr}/share/%{component}/vertica
%{_usr}/share/%{component}/schema/*
%{_usr}/share/%{component}/vertica/*
%config(noreplace) %attr(0640, root, monasca) %{_sysconfdir}/monasca/api-config.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}/%{component}.conf.sample

%files -n python-%{component}
%defattr(-, root, root,-)
%license LICENSE
%doc README.md ChangeLog
%{python2_sitelib}/monasca_api
%{python2_sitelib}/*.egg-info

%changelog