File openstack-heat.spec of Package openstack-heat

#
# spec file for package openstack-heat
#
# Copyright (c) 2014 SUSE LINUX Products 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 heat
%define groupname openstack-%{component}
%define username openstack-%{component}

Name:           openstack-%{component}
Version:        2013.2.4.dev12.g278f013
Release:        0
Summary:        Openstack Orchestration (Heat)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/heat
Source:         http://tarballs.openstack.org/heat/heat-stable-havana.tar.gz
Source1:        %{name}.init
Source2:        %{name}.logrotate
# PATCH-FIX-UPSTREAM https://review.openstack.org/94644
%if 0%{?suse_version} > 1230
Source10:       %name.conf
BuildRequires:  systemd
%endif
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-base
BuildRequires:  python-oslo.sphinx
BuildRequires:  python-pbr >= 0.5.21
BuildRequires:  python-setuptools
# Documentation requirements:
BuildRequires:  python-Sphinx
Requires:       logrotate
Requires:       openstack-heat-templates
Requires:       python >= 2.6.8
Requires:       python-heat = %{version}
Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
Heat is a service to orchestrate multiple composite cloud applications using
templates, through both an OpenStack-native ReST API and a
CloudFormation-compatible Query API.

%package -n python-heat
Summary:        Openstack Orchestration (Heat) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.6.8
Requires:       python-Babel >= 1.3
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-PyYAML >= 3.1.0
Requires:       python-Routes >= 1.12.3
Requires:       python-Routes >= 1.12.3
Requires:       python-SQLAlchemy >= 0.7.8
Requires:       python-WebOb >= 1.2.3
Requires:       python-argparse
Requires:       python-ceilometerclient >= 1.0.5
Requires:       python-cinderclient >= 1.0.6
Requires:       python-eventlet >= 0.13.0
Requires:       python-greenlet >= 0.3.2
Requires:       python-httplib2
Requires:       python-iso8601 >= 0.1.8
Requires:       python-keystoneclient >= 0.3.2
Requires:       python-kombu >= 2.4.8
Requires:       python-lxml >= 2.3
Requires:       python-netaddr
Requires:       python-neutronclient >= 2.3.0
Requires:       python-novaclient >= 2.15.0
Requires:       python-oslo.config >= 1.2.0
Requires:       python-paramiko >= 1.8.0
Requires:       python-pbr >= 0.5.21
Requires:       python-pycrypto >= 2.6
Requires:       python-python-memcached
Requires:       python-six >= 1.4.1
Requires:       python-sqlalchemy-migrate >= 0.7.2
Requires:       python-swiftclient >= 1.5

%description -n python-heat
This package contains the core Python module of OpenStack Heat.

%package api
Summary:        OpenStack Orchestration (Heat) - API
Group:          System/Management
Requires:       %{name} = %{version}

%description api
This package contains the OpenStack Heat API.

%package api-cfn
Summary:        OpenStack Orchestration (Heat) - CloudFormation API
Group:          System/Management
Requires:       %{name} = %{version}

%description api-cfn
This package contains the OpenStack Heat CloudFormation API.

%package api-cloudwatch
Summary:        OpenStack Orchestration (Heat) - CloudWatch API
Group:          System/Management
Requires:       %{name} = %{version}

%description api-cloudwatch
This package contains the OpenStack Heat CloudWatch API.

%package engine
Summary:        OpenStack Orchestration (Heat) - Engine
Group:          System/Management
Requires:       %{name} = %{version}

%description engine
This package contains the OpenStack Heat Engine.

%package test
Summary:        Openstack Orchestration (Heat) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       openstack-%{component}-api-cloudwatch
Requires:       python-coverage >= 3.6
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-discover
%endif
Requires:       python-flake8 >= 2.0
Requires:       python-glanceclient >= 0.9.0
Requires:       python-hacking >= 0.5.6
Requires:       python-mock >= 1.0
Requires:       python-mox >= 0.5.3
Requires:       python-paramiko >= 1.8.0
Requires:       python-pep8 >= 1.4.5
Requires:       python-pyflakes >= 0.7.2
Requires:       python-testrepository >= 0.0.17
Requires:       python-testtools >= 0.9.32

%description test
This package contains testsuite files for %{name}.

%prep
%setup -q -n %{component}-%{version}
%openstack_cleanup_prep
#NOTE(saschpe): Kill heat Sphinx extension, we're only building manpages:
sed -i "s|'heat.doc.resources'||" doc/source/conf.py

fgrep -q '#!/usr/bin' heat/cloudinit/loguserdata.py || {
  echo "Somebody removes shebangs again :-( Fix the stupid script!"
  exit 1
}

%build
python setup.py build
python setup.py build_sphinx -b man

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

### directories
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/{cache,log}/%{component}
install -d -m 700 %{buildroot}%{_localstatedir}/run/%{component}
%if 0%{?suse_version} > 1230
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf
%endif

### configuration files
install -d -m 755 %{buildroot}%{_sysconfdir}/%{component}/
mv etc/heat/heat.conf{.sample,}
install -p -m 644 etc/heat/*.{conf,json,ini} %{buildroot}%{_sysconfdir}/%{component}/
install -d -m 755  %{buildroot}%{_sysconfdir}/%{component}/{environment.d,templates}
install -p -m 644 etc/heat/environment.d/*.yaml %{buildroot}%{_sysconfdir}/%{component}/environment.d
install -p -m 644 etc/heat/templates/*.yaml %{buildroot}%{_sysconfdir}/%{component}/templates

crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT verbose True
crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT log_file heat.log
crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT log_dir /var/log/heat
crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT rpc_backend heat.openstack.common.rpc.impl_kombu
crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT sql_connection 'sqlite:///var/lib/heat/heat.db'
crudini --set %{buildroot}/etc/%{component}/heat.conf DEFAULT lock_path %{_localstatedir}/run/%{component}
crudini --set %{buildroot}/etc/%{component}/heat.conf keystone_authtoken signing_dir /var/cache/%component/keystone-signing
crudini --set %{buildroot}/etc/%{component}/heat.conf keystone_authtoken admin_tenant_name '%%SERVICE_TENANT_NAME%%'
crudini --set %{buildroot}/etc/%{component}/heat.conf keystone_authtoken admin_user heat
crudini --set %{buildroot}/etc/%{component}/heat.conf keystone_authtoken admin_password '%%SERVICE_PASSWORD%%'

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

### init scripts
mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_initddir}
for i in api api-cfn api-cloudwatch engine ; do
    install -m 755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}-$i
    sed -i -e "s/__NAME__/$i/g" %{buildroot}%{_initddir}/%{name}-$i
    ln -s ../..%{_initddir}/%{name}-$i %{buildroot}%{_sbindir}/rc%{name}-$i
done

### documentation
install -d %{buildroot}%{_mandir}/man1
install -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1

### test subpackage
%openstack_test_package_install
%fdupes %{buildroot}%{_localstatedir}/lib/%{name}-test

### misc
%fdupes %{buildroot}%{python_sitelib}/%{component}

%pre
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || useradd -r -g %{groupname} -d %{_localstatedir}/lib/%{component} -s /sbin/nologin -c "OpenStack Heat Daemons" %{username}
exit 0

%post api
%{fillup_and_insserv -f %{name}-api}

%preun api
%stop_on_removal %{name}-api

%postun api
%restart_on_update %{name}-api
%insserv_cleanup

%post api-cfn
%{fillup_and_insserv -f %{name}-api-cfn}

%preun api-cfn
%stop_on_removal %{name}-api-cfn

%postun api-cfn
%restart_on_update %{name}-api-cfn
%insserv_cleanup

%post api-cloudwatch
%{fillup_and_insserv -f %{name}-api-cloudwatch}

%preun api-cloudwatch
%stop_on_removal %{name}-api-cloudwatch

%postun api-cloudwatch
%restart_on_update %{name}-api-cloudwatch
%insserv_cleanup

%post engine
%{fillup_and_insserv -f %{name}-engine}

%preun engine
%stop_on_removal %{name}-engine

%postun engine
%restart_on_update %{name}-engine
%insserv_cleanup

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/%{component}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/lib/%{component}
%if 0%{?suse_version} > 1230
%ghost %dir %attr(700,%{username},%{groupname}) %{_localstatedir}/run/%{component}
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_localstatedir}/run/%{component}
%endif
%dir %{_sysconfdir}/%{component}
%config %{_sysconfdir}/%{component}/policy.json
%config %{_sysconfdir}/%{component}/environment.d
%config %{_sysconfdir}/%{component}/templates
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/%{component}/heat.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config %attr(0600, %{username}, root) %{_sysconfdir}/%{component}/api-paste.ini
%{_bindir}/heat-db-setup
%{_bindir}/heat-manage
%{_bindir}/heat-keystone-setup
%{_bindir}/cinder-keystone-setup
%{_mandir}/man1/%{component}-db-setup.1%{?ext_man}
%{_mandir}/man1/%{component}-keystone-setup.1%{?ext_man}

%files -n python-%{component}
%defattr(-,root,root,-)
%doc LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info

%files api
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-api
%{_sbindir}/rc%{name}-api
%{_bindir}/heat-api
%{_mandir}/man1/%{component}-api.1%{?ext_man}

%files api-cfn
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-api-cfn
%{_sbindir}/rc%{name}-api-cfn
%{_bindir}/heat-api-cfn
%{_mandir}/man1/%{component}-api-cfn.1%{?ext_man}

%files api-cloudwatch
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-api-cloudwatch
%{_sbindir}/rc%{name}-api-cloudwatch
%{_bindir}/heat-api-cloudwatch
%{_mandir}/man1/%{component}-api-cloudwatch.1%{?ext_man}

%files engine
%defattr(-,root,root,-)
%doc LICENSE
%{_initddir}/%{name}-engine
%{_sbindir}/rc%{name}-engine
%{_bindir}/heat-engine
%{_mandir}/man1/%{component}-engine.1%{?ext_man}

%files test
%defattr(-,root,root)
%{_localstatedir}/lib/%{name}-test/

%changelog
openSUSE Build Service is sponsored by