File openstack-ironic-inspector.spec of Package openstack-ironic-inspector

#
# spec file for package openstack-ironic-inspector
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%global with_doc 1
Name:           openstack-ironic-inspector
Version:        10.5.0~dev11
Release:        0
Summary:        Hardware introspection service for OpenStack Ironic
License:        Apache-2.0
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/ironic-inspector
Source0:        ironic-inspector-master.tar.gz
Source1:        openstack-ironic-inspector.sudoers
Source2:        openstack-ironic-inspector.logrotate
Source3:        openstack-ironic-inspector.defaultconf
Source4:        openstack-ironic-inspector.dnsmasqconf
# systemd service files
Source5:        openstack-ironic-inspector.service
Source6:        openstack-ironic-inspector-dnsmasq.service
Source7:        openstack-ironic-inspector-conductor.service
BuildRequires:  openstack-macros
BuildRequires:  python3-Flask
BuildRequires:  python3-SQLAlchemy
BuildRequires:  python3-alembic
BuildRequires:  python3-automaton
BuildRequires:  python3-construct
BuildRequires:  python3-devel
BuildRequires:  python3-eventlet
BuildRequires:  python3-fixtures
BuildRequires:  python3-futurist
BuildRequires:  python3-ironic-lib
BuildRequires:  python3-jsonpath-rw
BuildRequires:  python3-jsonschema
BuildRequires:  python3-keystoneauth1
BuildRequires:  python3-keystonemiddleware
BuildRequires:  python3-mock
BuildRequires:  python3-netaddr
BuildRequires:  python3-openstacksdk
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.serialization
BuildRequires:  python3-oslo.utils
BuildRequires:  python3-oslotest
BuildRequires:  python3-pbr
BuildRequires:  python3-pytz
BuildRequires:  python3-retrying
BuildRequires:  python3-stestr
BuildRequires:  python3-stevedore
BuildRequires:  python3-testscenarios
BuildRequires:  python3-tooz
BuildRequires:  sudo
Requires:       logrotate
Requires:       python3-ironic-inspector = %{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 Inspector is an auxiliary service for discovering hardware properties
for a node managed by OpenStack Ironic. Hardware introspection or hardware
properties discovery is a process of getting hardware parameters required for
scheduling from a bare metal node, given its power management credentials
(e.g. IPMI address, user name and password).

This package contains Python modules and an ironic-inspector service combining
API and conductor in one binary.

%package -n   python3-ironic-inspector
Summary:        Hardware introspection service for OpenStack Ironic
Group:          Development/Languages/Python
Requires:       openstack-ironic-inspector-dnsmasq
Requires:       python3-Flask
Requires:       python3-SQLAlchemy
Requires:       python3-alembic
Requires:       python3-automaton
Requires:       python3-construct
Requires:       python3-eventlet
Requires:       python3-futurist
Requires:       python3-ironic-lib
Requires:       python3-jsonpath-rw
Requires:       python3-jsonschema
Requires:       python3-keystoneauth1
Requires:       python3-keystonemiddleware
Requires:       python3-netaddr
Requires:       python3-openstacksdk
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.rootwrap
Requires:       python3-oslo.serialization
Requires:       python3-oslo.service
Requires:       python3-oslo.utils
Requires:       python3-pbr
Requires:       python3-pytz
Requires:       python3-retrying
Requires:       python3-stevedore
Requires:       python3-tooz

%description -n python3-ironic-inspector

Ironic Inspector is an auxiliary service for discovering hardware properties
for a node managed by OpenStack Ironic. Hardware introspection or hardware
properties discovery is a process of getting hardware parameters required for
scheduling from a bare metal node, given its power management credentials
(e.g. IPMI address, user name and password).

This package contains Python modules and an ironic-inspector service combining
API and conductor in one binary.

%if 0%{?with_doc}
%package doc
Summary:        Documentation for Ironic Inspector
Group:          Documentation/HTML
BuildRequires:  python3-Sphinx
BuildRequires:  python3-openstackdocstheme
BuildRequires:  python3-sphinxcontrib-apidoc
BuildRequires:  python3-sphinxcontrib-svg2pdfconverter

%description doc
Documentation for Ironic Inspector.
%endif

%package -n openstack-ironic-inspector-dnsmasq
Summary:        DHCP service for ironic-inspector using dnsmasq
Group:          Development/Languages/Python
Requires:       dnsmasq
Requires:       openstack-ironic-inspector = %{version}-%{release}

%description -n openstack-ironic-inspector-dnsmasq
Ironic Inspector is an auxiliary service for discovering hardware properties
for a node managed by OpenStack Ironic. Hardware introspection or hardware
properties discovery is a process of getting hardware parameters required for
scheduling from a bare metal node, given its power management credentials
(e.g. IPMI address, user name and password).

This package contains a dnsmasq service pre-configured for using with
ironic-inspector.

%package -n openstack-ironic-inspector-conductor
Summary:        Conductor service for Ironic Inspector
Group:          Development/Languages/Python
Requires:       openstack-ironic-inspector = %{version}-%{release}

%description -n openstack-ironic-inspector-conductor
Ironic Inspector is an auxiliary service for discovering hardware properties
for a node managed by OpenStack Ironic. Hardware introspection or hardware
properties discovery is a process of getting hardware parameters required for
scheduling from a bare metal node, given its power management credentials
(e.g. IPMI address, user name and password).

This package contains an ironic-inspector conductor service, which can be used
to split ironic-inspector into API and conductor processes.

%package -n openstack-ironic-inspector-api
Summary:        WSGI service service for Ironic Inspector
Group:          Development/Languages/Python
Requires:       openstack-ironic-inspector = %{version}-%{release}

%description -n openstack-ironic-inspector-api
Ironic Inspector is an auxiliary service for discovering hardware properties
for a node managed by OpenStack Ironic. Hardware introspection or hardware
properties discovery is a process of getting hardware parameters required for
scheduling from a bare metal node, given its power management credentials
(e.g. IPMI address, user name and password).

This package contains an ironic-inspector WSGI service, which can be used
to split ironic-inspector into API and conductor processes.

%prep
%autosetup -p1 -n ironic-inspector-10.5.0.dev11
%py_req_cleanup

%build
%{py3_build}

%if 0%{?with_doc}
export PYTHONPATH=.
export PBR_VERSION=10.5.0.dev11
%sphinx_build --keep-going -b html doc/source doc/build/html
%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}

# logs configuration
install -d -m 750 %{buildroot}%{_localstatedir}/log/ironic-inspector
install -d -m 750 %{buildroot}%{_localstatedir}/log/ironic-inspector/ramdisk
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-ironic-inspector

# install systemd scripts
mkdir -p %{buildroot}%{_unitdir}
install -p -D -m 644 %{SOURCE5} %{buildroot}%{_unitdir}
install -p -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}
install -p -D -m 644 %{SOURCE7} %{buildroot}%{_unitdir}

# install sudoers file
mkdir -p %{buildroot}%{_sysconfdir}/sudoers.d
install -p -D -m 440 %{SOURCE1} %{buildroot}%{_sysconfdir}/sudoers.d/openstack-ironic-inspector

# install configuration files
install -d -m 750 %{buildroot}%{_sysconfdir}/ironic-inspector
install -p -D -m 640 %{SOURCE3} %{buildroot}/%{_sysconfdir}/ironic-inspector/ironic-inspector.conf
install -p -D -m 640 %{SOURCE4} %{buildroot}/%{_sysconfdir}/ironic-inspector/dnsmasq.conf

# rootwrap configuration
mkdir -p %{buildroot}%{_sysconfdir}/ironic-inspector/rootwrap.d
install -p -D -m 640 rootwrap.conf %{buildroot}/%{_sysconfdir}/ironic-inspector/rootwrap.conf
install -p -D -m 640 rootwrap.d/* %{buildroot}/%{_sysconfdir}/ironic-inspector/rootwrap.d/

### 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
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-dnsmasq
%endif

### man pages
%if 0%{?with_doc}
mkdir -p %{buildroot}%{_mandir}/man1
install -p -D -m 644 doc/build/man/ironic-inspector.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-inspector ironic-inspector /sbin/nologin
exit 0

%post api
%systemd_post %{name}.service

%preun api
%systemd_preun %{name}.service

%postun api
%systemd_postun %{name}.service

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

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

%postun dnsmasq
%systemd_postun %{name}-dnsmasq.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-inspector, ironic-inspector) %{_localstatedir}/log/ironic-inspector
%dir %{_sysconfdir}/ironic-inspector
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-ironic-inspector
%config(noreplace) %{_sysconfdir}/sudoers.d/openstack-ironic-inspector
%config(noreplace) %attr(0640, root, ironic-inspector) %{_sysconfdir}/ironic-inspector/ironic-inspector.conf
%config(noreplace) %attr(0640, root, ironic-inspector) %{_sysconfdir}/ironic-inspector/dnsmasq.conf
%config %{_sysconfdir}/ironic-inspector/rootwrap.conf
%dir %{_sysconfdir}/ironic-inspector/rootwrap.d
%config(noreplace) %{_sysconfdir}/ironic-inspector/rootwrap.d/ironic-inspector.filters
%{_bindir}/ironic-inspector-rootwrap
%{_bindir}/ironic-inspector-dbsync
%{_bindir}/ironic-inspector-migrate-data
%if 0%{?with_doc}
%{_mandir}/man1/ironic-inspector.1.gz
%endif

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

%files doc
%license LICENSE
%doc doc/build/html

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

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

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

%changelog