File openstack-glance.spec of Package openstack-glance

#
# spec file for package openstack-glance
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2011 B1 Systems GmbH, Vohburg, 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 glance
%define groupname %{component}
%define username %{component}

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif

%define version_unconverted 2014.2.4.dev13

Name:           openstack-%{component}
Version:        2014.2.4.juno
Release:        0
Summary:        OpenStack Image Service (Glance)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/glance
Source0:        http://tarballs.openstack.org/glance/glance-stable-juno.tar.gz
Source1:        openstack-glance.init
Source5:        %{name}.logrotate
%if 0%{?suse_version} > 1230
Source10:       %name.conf
BuildRequires:  systemd
%endif
# https://review.openstack.org/#/c/132717/
Patch0:         0001-Add-ability-to-deactivate-an-image.patch
Patch1:         0001-Fix-error-when-downloading-image-status-is-not-activ.patch
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-base
BuildRequires:  python-setuptools
# Documentation build requirements:
BuildRequires:  python-Sphinx
BuildRequires:  python-oslosphinx
Requires:       logrotate
Requires:       python >= 2.6.8
Requires:       python-glance = %{version}
Requires(post): sysconfig
%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif
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
The OpenStack Image Service provides discovery, registration and
delivery services for disk and server images. The ability to copy or
snapshot a server image and immediately store it away is a powerful
capability of the OpenStack cloud operating system. Stored images can
be used as a template to get new servers up and running quickly—and
more consistently if you are provisioning multiple servers—than
installing a server operating system and individually configuring
additional services. It can also be used to store and catalog an
unlimited number of backups.

The Image Service can store disk and server images in a variety of
back-ends, including OpenStack Object Storage. The Image Service API
provides a standard REST interface for querying information about disk
images and lets clients stream the images to new servers.

%package -n python-glance
Summary:        OpenStack Image Service (Glance) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.6.8
Requires:       python-Babel >= 1.3
Requires:       python-Paste
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-Routes >= 1.12.3
Requires:       python-SQLAlchemy >= 0.8.4
Requires:       python-WebOb >= 1.2.3
Requires:       python-anyjson >= 0.3.3
Requires:       python-argparse
Requires:       python-boto >= 2.32.1
Requires:       python-cinderclient >= 1.1.0
Requires:       python-eventlet >= 0.15.1
Requires:       python-glance_store >= 0.1.1
Requires:       python-greenlet >= 0.3.2
Requires:       python-httplib2 >= 0.7.5
Requires:       python-iso8601 >= 0.1.9
Requires:       python-jsonschema >= 2.0.0
Requires:       python-keystoneclient >= 0.10.0
Requires:       python-keystonemiddleware >= 1.0.0
Requires:       python-kombu >= 2.5.0
Requires:       python-netaddr >= 0.7.12
Requires:       python-oslo.config >= 1.4.0
Requires:       python-oslo.db >= 1.0.0
Requires:       python-oslo.i18n >= 1.3.0
Requires:       python-oslo.messaging >= 1.4.0
Requires:       python-oslo.vmware >= 0.6.0
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-ordereddict
%endif
Requires:       python-WSME >= 0.6
Requires:       python-osprofiler >= 0.3.0
Requires:       python-pbr >= 0.6
Requires:       python-posix_ipc
Requires:       python-psutil >= 1.1.1
Requires:       python-pyOpenSSL >= 0.11
Requires:       python-pycrypto >= 2.6
Requires:       python-retrying >= 1.2.2
Requires:       python-six >= 1.7.0
Requires:       python-sqlalchemy-migrate >= 0.9.1
Requires:       python-stevedore >= 1.0.0
Requires:       python-swiftclient >= 2.2.0
Requires:       python-xattr >= 0.4

%description -n python-glance
This package contains the core Python module of OpenStack Glance.

%package test
Summary:        OpenStack Image Service (Glance) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-discover
%endif
Requires:       python-fixtures >= 0.3.14
Requires:       python-glanceclient
Requires:       python-mock >= 1.0
Requires:       python-mox >= 0.5.3
Requires:       python-psycopg2
Requires:       python-pysendfile >= 2.0.0
Requires:       python-requests >= 2.1.0
Requires:       python-sqlalchemy-migrate >= 0.9.1
Requires:       python-testrepository >= 0.0.18
Requires:       python-testtools >= 0.9.34
Requires:       python-xattr >= 0.4

%description test
The OpenStack Glance testsuite. It is used to verify the functionality
of OpenStack Glance.

%prep
%setup -q -n %{component}-%{version_unconverted}
%patch0 -p1
%patch1 -p1
%openstack_cleanup_prep
sed -i "s|^#!.*||" tools/migrate_image_owners.py # Fix non-executable script warning
# NOTE(saschpe): The following test contains a pesky (commented) race condition
# that I don't see worth fixing, thus drop it:
rm glance/tests/functional/v1/test_multiprocessing.py

%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/glance
install -d -m 755 %{buildroot}%{_localstatedir}/lib/glance/images
install -d -m 750 %{buildroot}%{_localstatedir}/log/glance
install -d -m 700 %{buildroot}%{_rundir}/%{component}
%if 0%{?suse_version} > 1230
install -D -m 644 %{SOURCE10} %{buildroot}/%_tmpfilesdir/%name.conf
%endif

### configuration files
install -d -m 0755 %{buildroot}%{_sysconfdir}/glance
cp -pr etc/* %{buildroot}%{_sysconfdir}/glance
rm -rf %{buildroot}%{_sysconfdir}/glance/oslo-config-generator
install -p -D -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

### init scripts
mkdir -p %{buildroot}%{_sbindir}
for i in api registry ; do
    tmp=$(mktemp)
    cat %{SOURCE1} | sed "s/__NAME__/$i/g" > $tmp
    install -D -m 755 $tmp %{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}

mv %{buildroot}%{_sysconfdir}/glance/glance-swift.conf{.sample,}

### set default configuration (mostly applies to package-only setups and quickstart, i.e. not generally crowbar)
for i in api registry ; do
    crudini --set %{buildroot}%{_sysconfdir}/glance/glance-$i.conf DEFAULT verbose True
    crudini --set %{buildroot}%{_sysconfdir}/glance/glance-$i.conf paste_deploy flavor keystone
    crudini --set %{buildroot}%{_sysconfdir}/glance/glance-$i.conf database connection sqlite:////var/lib/glance/glance.db
done
#NOTE(saschpe): Needed for (at least) ceilometer to collect image counters stats:
crudini --set %{buildroot}%{_sysconfdir}/glance/glance-api.conf DEFAULT notification_driver messaging
crudini --set %{buildroot}%{_sysconfdir}/glance/glance-api.conf DEFAULT lock_path /var/run/glance
crudini --set %{buildroot}%{_sysconfdir}/glance/glance-api.conf keystone_authtoken signing_dir /var/cache/%component/keystone-signing
crudini --set %{buildroot}%{_sysconfdir}/glance/glance-scrubber.conf DEFAULT lock_path /var/run/glance

### authentication cache dir
mkdir -p %{buildroot}%{_localstatedir}/cache/glance/api
mkdir -p %{buildroot}%{_localstatedir}/cache/glance/registry

%pre
%openstack_pre_user_group_create %{username} %{groupname}

%post
%fillup_and_insserv openstack-glance-api openstack-glance-registry

%preun
%stop_on_removal openstack-glance-api openstack-glance-registry

%postun
%restart_on_update openstack-glance-api openstack-glance-registry
%insserv_cleanup

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%dir %{_sysconfdir}/glance
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/glance/glance-api.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/glance/glance-cache.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/glance/glance-registry.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/glance/glance-scrubber.conf
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/glance/glance-swift.conf
%config %{_sysconfdir}/glance/glance-api-paste.ini
%config %{_sysconfdir}/glance/glance-registry-paste.ini
%config %{_sysconfdir}/glance/logging.cnf.sample
%config %{_sysconfdir}/glance/policy.json
%config %{_sysconfdir}/glance/property-protections-policies.conf.sample
%config %{_sysconfdir}/glance/property-protections-roles.conf.sample
%config %{_sysconfdir}/glance/schema-image.json
%dir %config %{_sysconfdir}/glance/metadefs
%{_sysconfdir}/glance/metadefs/README
%config %{_sysconfdir}/glance/metadefs/*.json
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/lib/glance
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/lib/glance/images
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/glance
%if 0%{?suse_version} > 1230
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_rundir}/%{component}
%endif
%{_initddir}/openstack-glance-api
%{_initddir}/openstack-glance-registry
%{_sbindir}/rcopenstack-glance-api
%{_sbindir}/rcopenstack-glance-registry
%{_bindir}/glance-api
%{_bindir}/glance-cache-cleaner
%{_bindir}/glance-cache-manage
%{_bindir}/glance-cache-prefetcher
%{_bindir}/glance-cache-pruner
%{_bindir}/glance-control
%{_bindir}/glance-manage
%{_bindir}/glance-registry
%{_bindir}/glance-replicator
%{_bindir}/glance-scrubber
%{_mandir}/man1/glance-api.1%{?ext_man}
%{_mandir}/man1/glance-cache-cleaner.1%{?ext_man}
%{_mandir}/man1/glance-cache-manage.1%{?ext_man}
%{_mandir}/man1/glance-cache-prefetcher.1%{?ext_man}
%{_mandir}/man1/glance-cache-pruner.1%{?ext_man}
%{_mandir}/man1/glance-control.1%{?ext_man}
%{_mandir}/man1/glance-manage.1%{?ext_man}
%{_mandir}/man1/glance-registry.1%{?ext_man}
%{_mandir}/man1/glance-replicator.1%{?ext_man}
%{_mandir}/man1/glance-scrubber.1%{?ext_man}
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/glance

%files -n python-glance
%defattr(-,root,root,-)
%doc LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info
# Part of test subpackage
%exclude %{python_sitelib}/%{component}/tests/

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

%changelog
openSUSE Build Service is sponsored by