Name:           openstack-glance
Version:        19.0.4
Release:        1
Summary:        OpenStack Image Service (Glance)
License:        ASL 2.0
URL:            https://docs.openstack.org/glance
Source0:        https://tarballs.opendev.org/openstack/glance/glance-19.0.4.tar.gz
Source1:        openstack-glance.logrotate
Source2:        openstack-glance-api.service

BuildRequires:       openstack-macros
BuildRequires:       qemu-img
BuildRequires:       systemd
BuildRequires:       python3-paste
BuildRequires:       python3-paste-deploy
BuildRequires:       python3-prettytable
BuildRequires:       python3-routes
BuildRequires:       python3-sqlalchemy
BuildRequires:       python3-wsme
BuildRequires:       python3-webob
BuildRequires:       python3-alembic
BuildRequires:       python3-cryptography
BuildRequires:       python3-castellan
BuildRequires:       python3-cursive
BuildRequires:       python3-debtcollector
BuildRequires:       python3-defusedxml
BuildRequires:       python3-eventlet
BuildRequires:       python3-futurist
BuildRequires:       python3-glance-store
BuildRequires:       python3-httplib2
BuildRequires:       python3-iso8601
BuildRequires:       python3-jsonschema
BuildRequires:       python3-keystoneauth1
BuildRequires:       python3-keystoneclient
BuildRequires:       python3-keystonemiddleware
BuildRequires:       python3-oslo-concurrency
BuildRequires:       python3-oslo-config
BuildRequires:       python3-oslo-context
BuildRequires:       python3-oslo-db
BuildRequires:       python3-oslo-i18n
BuildRequires:       python3-oslo-log
BuildRequires:       python3-oslo-messaging
BuildRequires:       python3-oslo-middleware
BuildRequires:       python3-oslo-policy
BuildRequires:       python3-oslo-reports
BuildRequires:       python3-oslo-upgradecheck
BuildRequires:       python3-oslo-utils
BuildRequires:       python3-osprofiler
BuildRequires:       python3-pbr
BuildRequires:       python3-pyOpenSSL
BuildRequires:       python3-retrying
BuildRequires:       python3-six
BuildRequires:       python3-sqlalchemy-migrate
BuildRequires:       python3-sqlparse
BuildRequires:       python3-stevedore
BuildRequires:       python3-taskflow
BuildRequires:       python3-hacking
BuildRequires:       python3-babel
BuildRequires:       python3-coverage
BuildRequires:       python3-ddt
BuildRequires:       python3-fixtures
BuildRequires:       python3-requests
BuildRequires:       python3-testrepository
BuildRequires:       python3-testresources
BuildRequires:       python3-testscenarios
BuildRequires:       python3-testtools
BuildRequires:       python3-psutil
BuildRequires:       python3-oslotest
BuildRequires:       python3-stestr
BuildRequires:       python3-doc8
BuildRequires:       python3-pygments
BuildRequires:       python3-boto3
BuildRequires:       python3-PyMySQL
BuildRequires:       python3-psycopg2
BuildRequires:       python3-pysendfile
BuildRequires:       python3-xattr
BuildRequires:       python3-swiftclient
BuildRequires:       python3-cinderclient
BuildRequires:       python3-os-brick
BuildRequires:       python3-oslo-privsep

Requires:       openstack-glance-api = %{version}-%{release}
BuildArch:      noarch

%description
The Glance project provides a service where users can upload and discover
data assets that are meant to be used with other services. This currently
includes images and metadata definitions.
Glance image services include discovering, registering, and retrieving
virtual machine images. Glance has a RESTful API that allows querying of
VM image metadata as well as retrieval of the actual image.
VM images made available through Glance can be stored in a variety of
locations from simple filesystems to object-storage systems like the
OpenStack Swift project.

%package api
Summary:        OpenStack Image service (Glance) - API
Requires:         python3-glance = %{version}-%{release}
Requires:         logrotate
Requires(post):   systemd
Requires(postun): systemd
Requires(preun):  systemd
Requires(pre):    shadow-utils

%description api
The Glance project provides a service where users can upload and discover
data assets that are meant to be used with other services. This currently
includes images and metadata definitions.
Glance image services include discovering, registering, and retrieving
virtual machine images. Glance has a RESTful API that allows querying of
VM image metadata as well as retrieval of the actual image.
VM images made available through Glance can be stored in a variety of
locations from simple filesystems to object-storage systems like the
OpenStack Swift project.

This package contains the %{name} API server.

%package -n     python3-glance
Summary:        OpenStack Image Service (Glance) - Python module

Requires:       python3-paste
Requires:       python3-paste-deploy
Requires:       python3-prettytable
Requires:       python3-routes
Requires:       python3-sqlalchemy
Requires:       python3-wsme
Requires:       python3-webob
Requires:       python3-alembic
Requires:       python3-cryptography
Requires:       python3-castellan
Requires:       python3-cursive
Requires:       python3-debtcollector
Requires:       python3-defusedxml
Requires:       python3-eventlet
Requires:       python3-futurist
Requires:       python3-glance-store
Requires:       python3-httplib2
Requires:       python3-iso8601
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystoneclient
Requires:       python3-keystonemiddleware
Requires:       python3-oslo-concurrency
Requires:       python3-oslo-config
Requires:       python3-oslo-context
Requires:       python3-oslo-db
Requires:       python3-oslo-i18n
Requires:       python3-oslo-log
Requires:       python3-oslo-messaging
Requires:       python3-oslo-middleware
Requires:       python3-oslo-policy
Requires:       python3-oslo-reports
Requires:       python3-oslo-upgradecheck
Requires:       python3-oslo-utils
Requires:       python3-osprofiler
Requires:       python3-pbr
Requires:       python3-pyOpenSSL
Requires:       python3-retrying
Requires:       python3-six
Requires:       python3-sqlalchemy-migrate
Requires:       python3-sqlparse
Requires:       python3-stevedore
Requires:       python3-taskflow

%description -n python3-glance
The Glance project provides a service where users can upload and discover
data assets that are meant to be used with other services. This currently
includes images and metadata definitions.
Glance image services include discovering, registering, and retrieving
virtual machine images. Glance has a RESTful API that allows querying of
VM image metadata as well as retrieval of the actual image.
VM images made available through Glance can be stored in a variety of
locations from simple filesystems to object-storage systems like the
OpenStack Swift project.

This package contains the Glance Python library.

%package -n python3-glance-tests
Summary:        Glance tests
Requires:       python3-glance = %{version}-%{release}
Requires:       python3-hacking
Requires:       python3-babel
Requires:       python3-coverage
Requires:       python3-ddt
Requires:       python3-fixtures
Requires:       python3-requests
Requires:       python3-testrepository
Requires:       python3-testresources
Requires:       python3-testscenarios
Requires:       python3-testtools
Requires:       python3-psutil
Requires:       python3-oslotest
Requires:       python3-stestr
Requires:       python3-doc8
Requires:       python3-pygments
Requires:       python3-boto3
Requires:       python3-PyMySQL
Requires:       python3-psycopg2
Requires:       python3-pysendfile
Requires:       python3-xattr
Requires:       python3-swiftclient
Requires:       python3-cinderclient
Requires:       python3-os-brick
Requires:       python3-oslo-privsep

%description -n python3-glance-tests
The Glance project provides a service where users can upload and discover
data assets that are meant to be used with other services. This currently
includes images and metadata definitions.
Glance image services include discovering, registering, and retrieving
virtual machine images. Glance has a RESTful API that allows querying of
VM image metadata as well as retrieval of the actual image.
VM images made available through Glance can be stored in a variety of
locations from simple filesystems to object-storage systems like the
OpenStack Swift project.

This package contains the Glance test files.

%prep
%autosetup -p1 -n glance-%{version} 
%py_req_cleanup

%build
%{py3_build}
# regenerate the sample config files
for service in api scrubber cache manage image-import; do
    PYTHONPATH=. oslo-config-generator --config-file etc/oslo-config-generator/glance-$service.conf
done
# generate the sample policy
PYTHONPATH=. oslopolicy-sample-generator --config-file=etc/glance-policy-generator.conf --output etc/policy.json
rm -f etc/glance-policy-generator.conf

%install
%{py3_install}
# directories
install -d -m 755 %{buildroot}%{_sysconfdir}/glance
install -d -m 755 %{buildroot}%{_sysconfdir}/glance/glance.conf.d/
install -d -m 755 %{buildroot}%{_sysconfdir}/glance/glance-api.conf.d/
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 750 %{buildroot}%{_localstatedir}/cache/glance
install -d -m 700 %{buildroot}%{_rundir}/glance
# install sample configs
cp -pr etc/* %{buildroot}%{_sysconfdir}/glance
for service in api scrubber cache manage swift image-import; do
    mv %{buildroot}%{_sysconfdir}/glance/glance-$service.conf{.sample,}
done
rm -rf %{buildroot}%{_sysconfdir}/glance/oslo-config-generator

# systemd
install -p -D -m 444 %{SOURCE2} %{buildroot}%{_unitdir}/openstack-glance-api.service
# logrotate
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-glance
# move metadefs
mv %{buildroot}%{_prefix}%{_sysconfdir}/glance/metadefs/* %{buildroot}%{_sysconfdir}/glance/metadefs
# Remove duplicate files under /usr/etc
rm -rf %{buildroot}%{_prefix}%{_sysconfdir}/glance

%pre api
%openstack_pre_user_group_create glance glance /sbin/nologin

%check
stestr run --black-regex 'glance.tests.unit.common.test_format_inspector.TestFormatInspectors.test_vdi'

%post api
%systemd_post %{name}-api.service

%preun api
%systemd_preun %{name}-api.service

%postun api
%systemd_postun_with_restart %{name}-api.service

%files

%files api
%license LICENSE
%dir %attr(0750, root, glance) %{_sysconfdir}/glance
%dir %attr(0750, root, glance) %{_sysconfdir}/glance/glance.conf.d/
%dir %attr(0750, root, glance) %{_sysconfdir}/glance/glance-api.conf.d/
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-api.conf
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-cache.conf
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-image-import.conf
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-scrubber.conf
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-swift.conf
%config(noreplace) %attr(0640, root, glance) %{_sysconfdir}/glance/glance-manage.conf
%config %{_sysconfdir}/glance/glance-api-paste.ini
%config %{_sysconfdir}/glance/policy.json
%config %{_sysconfdir}/glance/property-protections-policies.conf.sample
%config %{_sysconfdir}/glance/property-protections-roles.conf.sample
%config %{_sysconfdir}/glance/ovf-metadata.json.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, glance, glance) %{_localstatedir}/lib/glance
%dir %attr(0755, glance, glance) %{_localstatedir}/lib/glance/images
%dir %attr(0750, glance, glance) %{_localstatedir}/log/glance
%dir %attr(0750, glance, glance) %{_localstatedir}/cache/glance
%{_bindir}/glance-cache-cleaner
%{_bindir}/glance-cache-manage
%{_bindir}/glance-cache-prefetcher
%{_bindir}/glance-cache-pruner
%{_bindir}/glance-control
%{_bindir}/glance-manage
%{_bindir}/glance-replicator
%{_bindir}/glance-scrubber
%{_bindir}/glance-status
%{_unitdir}/openstack-glance-api.service
%{_bindir}/glance-api
%{_bindir}/glance-wsgi-api

%files -n python3-glance
%license LICENSE
%{python3_sitelib}/glance*
%exclude %{python3_sitelib}/glance/tests

%files -n python3-glance-tests
%license LICENSE
%{python3_sitelib}/glance/tests

%changelog
* Fri Nov 05 2021 lijiawei <ljw1101.vip@gmail.com> - 19.0.4-1
- Support OpenStack Train release
