%global with_doc 1
Name:           openstack-ironic
Epoch:          0
Version:        16.0.4
Release:        0.2.dev3
Summary:        Openstack Provisioning of Bare Metal Servers
License:        ASL 2.0
URL:            https://launchpad.net/ironic
Source0:        ironic-stable-victoria.tar.gz
Source1:        openstack-ironic.sudoers
Source2:        openstack-ironic.logrotate
Source3:        openstack-ironic.tmpfiles
Source4:        openstack-ironic.defaultconf
Source5:        openstack-ironic.README.config
# systemd service files
Source6:        openstack-ironic-api.service
Source7:        openstack-ironic-conductor.service
BuildRequires:  openstack-macros
BuildRequires:  python3-jinja2
BuildRequires:  python3-sqlalchemy
BuildRequires:  python3-wsme
BuildRequires:  python3-webob
BuildRequires:  python3-alembic
BuildRequires:  python3-automaton
BuildRequires:  python3-cinderclient
BuildRequires:  python3-ddt
BuildRequires:  python3-eventlet
BuildRequires:  python3-fixtures
BuildRequires:  python3-futurist
BuildRequires:  python3-glanceclient
BuildRequires:  python3-ironic-lib
BuildRequires:  python3-iso8601
BuildRequires:  python3-jsonpatch
BuildRequires:  python3-jsonschema
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-mock
BuildRequires:  python3-neutronclient
BuildRequires:  python3-os-traits
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-rootwrap
BuildRequires:  python3-oslo-serialization
BuildRequires:  python3-oslo-service
BuildRequires:  python3-oslo-upgradecheck
BuildRequires:  python3-oslo-utils
BuildRequires:  python3-oslo-versionedobjects
BuildRequires:  python3-oslotest
BuildRequires:  python3-osprofiler
BuildRequires:  python3-pbr
BuildRequires:  python3-pecan
BuildRequires:  python3-psutil
BuildRequires:  python3-pysendfile
BuildRequires:  python3-pysnmp
BuildRequires:  python3-pytz
BuildRequires:  python3-requests
BuildRequires:  python3-retrying
BuildRequires:  python3-rfc3986
BuildRequires:  python3-stestr
BuildRequires:  python3-stevedore
BuildRequires:  python3-swiftclient
BuildRequires:  python3-testtools
BuildRequires:  python3-tooz
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-ironic = %{epoch}:%{version}-%{release}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(pre):  shadow-utils
Requires(preun): systemd
%endif

%description
Ironic is an Incubated OpenStack project which aims to provision bare metal
machines instead of virtual machines, forked from the Nova Baremetal driver.
It is best thought of as a bare metal hypervisor API and a set of plugins
which interact with the bare metal hypervisors. By default, it will use
PXE and IPMI in concert to provision and turn on/off machines, but Ironic
also supports vendor-specific plugins which may implement additional functionality.

%package -n     python3-ironic
Summary:        OpenStack shared file system service (ironic) - Python module
Group:          Development/Languages/Python
Requires:       python3-jinja2
Requires:       python3-sqlalchemy
Requires:       python3-wsme
Requires:       python3-webob
Requires:       python3-alembic
Requires:       python3-automaton
Requires:       python3-cinderclient
Requires:       python3-eventlet
Requires:       python3-futurist
Requires:       python3-glanceclient
Requires:       python3-ironic-lib
Requires:       python3-jsonpatch
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystonemiddleware
Requires:       python3-neutronclient
Requires:       python3-os-traits
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-rootwrap
Requires:       python3-oslo-serialization
Requires:       python3-oslo-service
Requires:       python3-oslo-upgradecheck
Requires:       python3-oslo-utils
Requires:       python3-oslo-versionedobjects
Requires:       python3-osprofiler
Requires:       python3-pbr
Requires:       python3-pecan
Requires:       python3-psutil
Requires:       python3-pysendfile
Requires:       python3-pysnmp
Requires:       python3-pytz
Requires:       python3-requests
Requires:       python3-retrying
Requires:       python3-rfc3986
Requires:       python3-stevedore
Requires:       python3-swiftclient
Requires:       python3-tooz
Requires:       sudo

%description -n python3-ironic
This package contains the core code of OpenStack Ironic.

%if 0%{?with_doc}
%package doc
Summary:        OpenStack bare metal provisioning service (ironic) - Documentation
Group:          Documentation/HTML
BuildRequires:  python3-sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinxcontrib-apidoc
BuildRequires:  python3-sphinxcontrib-httpdomain
BuildRequires:  python3-sphinxcontrib-pecanwsme
BuildRequires:  python3-sphinxcontrib-seqdiag
BuildRequires:  python3-sphinxcontrib-svg2pdfconverter

%description doc
OpenStack bare metal provisioning service.
This package contains the Documentation.
%endif

%package api
Summary:        OpenStack Ironic - API
Group:          System/Management
Requires:       openstack-ironic = %{epoch}:%{version}-%{release}

%description api
This package contains the OpenStack Ironic API Daemon.

%package conductor
Summary:        OpenStack Ironic - Conductor
Group:          System/Management
Requires:       openstack-ironic = %{epoch}:%{version}-%{release}

%description conductor
This package contains the OpenStack Ironic Conductor Manager Daemon.

%prep
%autosetup -p1 -n ironic-16.0.4.dev3
%py_req_cleanup

%build
%{py3_build}

%if 0%{?with_doc}
PYTHONPATH=. PBR_VERSION=16.0.4.dev3 sphinx-build --keep-going -b html doc/source doc/build/html
PYTHONPATH=. PBR_VERSION=16.0.4.dev3 sphinx-build --keep-going -b man doc/source doc/build/man
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
rm -rf doc/build/man/.{doctrees,buildinfo}
%endif

%install
%{py3_install}

### Setup directories
install -d -m 750 %{buildroot}%{_localstatedir}/{lib,log,cache}/ironic
install -d -m 755 %{buildroot}%{_sysconfdir}/ironic
install -d -m 755 %{buildroot}%{_sysconfdir}/ironic/ironic.conf.d/
install -d -m 700 %{buildroot}%{_localstatedir}/run/ironic

### Install configuration files
install -D -m 644 %{SOURCE3} %{buildroot}/%_tmpfilesdir/ironic.conf
install -p -D -m 640 %{SOURCE4} %{buildroot}%{_sysconfdir}/ironic/ironic.conf.d/010-ironic.conf
mv %{buildroot}%{_prefix}%{_sysconfdir}/ironic/* %{buildroot}%{_sysconfdir}/ironic/
cp -a etc/ironic/rootwrap.d/ %{buildroot}%{_sysconfdir}/ironic/
install -p -D -m 640 %{SOURCE5} %{buildroot}%{_sysconfdir}/ironic/README.config

### Install systemd service files
install -p -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}-api.service
install -p -D -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-conductor.service

### install symlinks on SUSE
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-api
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-conductor
%endif

### sudoers configuration for ironic-rootwrap:
install -D -m 440 %{SOURCE1} %{buildroot}%{_sysconfdir}/sudoers.d/openstack-ironic

### Install logrotate
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-ironic

### man pages
%if 0%{?with_doc}
mkdir -p %{buildroot}%{_mandir}/man1
install -p -D -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1/
%endif

%check
export LC_ALL=en_US.UTF-8
python3 -m stestr.cli run

%pre
%openstack_pre_user_group_create ironic ironic /sbin/nologin
exit 0

%post
%tmpfiles_create %{_tmpfilesdir}/ironic.conf

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

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

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

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

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

%postun conductor
%systemd_postun %{name}-conductor.service

%files
%doc README.rst
%license LICENSE
%dir %attr(0750, ironic, ironic) %{_localstatedir}/lib/ironic
%dir %attr(0750, ironic, ironic) %{_localstatedir}/cache/ironic
%dir %attr(0750, ironic, ironic) %{_localstatedir}/log/ironic
%_tmpfilesdir/ironic.conf
%dir %{_sysconfdir}/ironic
%dir %{_sysconfdir}/ironic/ironic.conf.d/
%{_sysconfdir}/ironic/README.config
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-ironic
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-ironic
%config(noreplace) %attr(0640, root, ironic) %{_sysconfdir}/ironic/ironic.conf.d/010-ironic.conf
%config %{_sysconfdir}/ironic/rootwrap.conf
%dir %{_sysconfdir}/ironic/rootwrap.d
%config(noreplace) %{_sysconfdir}/ironic/rootwrap.d/ironic-utils.filters
%{_bindir}/ironic-status
%{_bindir}/ironic-rootwrap
%{_bindir}/ironic-dbsync
%if 0%{?with_doc}
%{_mandir}/man1/ironic.1.gz
%endif

%files -n python3-ironic
%license LICENSE
%{python3_sitelib}/ironic/
%{python3_sitelib}/ironic-*.egg-info

%if 0%{?with_doc}
%files doc
%license LICENSE
%doc doc/build/html
%endif

%files api
%license LICENSE
%{_unitdir}/%{name}-api.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-api
%endif
%{_bindir}/ironic-api
%{_bindir}/ironic-api-wsgi

%files conductor
%license LICENSE
%{_unitdir}/%{name}-conductor.service
%if 0%{?suse_version}
%{_sbindir}/rc%{name}-conductor
%endif
%{_bindir}/ironic-conductor

%changelog
* Tue Feb 09 2021 huangtianhua <huangtianhua223@gmail.com>
- Enable with_doc to generate docs
* Mon Feb 08 2021 OpenStack rpm-packaging <huangtianhua223@gmail.com>
- Package Spec generated
