Name:           ceph-iscsi-config
Version:        2.6
Release:        18%{?dist}
Summary:        Python package providing modules for ceph iscsi gateway configuration management

License:        GPLv3
URL:            https://github.com/ceph/ceph-iscsi-config
Source0:        https://github.com/ceph/ceph-iscsi-config/archive/%{version}/%{name}-%{version}.tar.gz

Patch0001: 0001-make-prometheus-host-configurable-with-the-defualt-o.patch
Patch0002: 0002-Optionally-include-conf-path-to-ceph.conf-in-cfgstri.patch
Patch0003: 0003-move-define-clients-luns-to-lib-v2.patch
Patch0004: 0004-Move-size-suffix-array-to-utils.patch
Patch0005: 0005-Support-integers-as-size-args-for-LUN-RBDDev.patch
Patch0006: 0006-utils-remove-unused-human_size.patch
Patch0007: 0007-lun-use-a-copy-of-control-dict-when-instantiating-LU.patch
Patch0008: 0008-lun-carve-out-lun-config-update-into-a-separate-rout.patch
Patch0009: 0009-Allow-alua-failover-type-to-be-configurable.patch
Patch0010: 0010-Detect-and-handle-invalid-alua-failover-types.patch
Patch0011: 0011-Fix-indention-in-bind_alua_group_to_lun.patch
Patch0012: 0012-gateway-fixed-variable-name-for-exception.patch
Patch0013: 0013-lun-translate-all-thrown-exceptions-when-removing-a-.patch
Patch0014: 0014-settings-add-target-level-overrides-for-IO-configura.patch
Patch0015: 0015-common-helper-to-replace-config-without-merging-dict.patch
Patch0016: 0016-gateway-add-support-for-gateway-level-control-overri.patch
Patch0017: 0017-client-add-support-for-gateway-level-control-overrid.patch
Patch0018: 0018-gateway-add-reconfigure-support-to-the-manage-API-me.patch
Patch0019: 0019-client-add-reconfigure-support-to-the-manage-API-met.patch
Patch0020: 0020-group-fix-update_client.patch
Patch0021: 0021-Limit-log-file-size-to-5MB.patch
Patch0022: 0022-Move-valid_disk-from-gwcli-to-ceph-iscsi-config.patch
Patch0023: 0023-Only-allow-num-and-alpha-chars-for-image-name.patch
Patch0024: 0024-settings-fixed-int-regex-matcher-to-require-the-full.patch
Patch0025: 0025-mv-control-code-to-new-class.patch
Patch0026: 0026-Add-helper-to-normalize-a-dict-of-controls.patch
Patch0027: 0027-Use-controls-normalize-helper-to-validate-disk-ops.patch
Patch0028: 0028-Make-hw_max_sectors-configurable.patch
Patch0029: 0029-Move-lun-activate-deactivate-from-gwcli-to-config.patch
Patch0030: 0030-Handle-tcmu-control-errors.patch
Patch0031: 0031-lun-support-underscore-characters-in-image-name.patch
Patch0032: 0032-Initial-support-for-IPv6.patch
Patch0033: 0033-lun-helper-method-to-clear-the-rtslib_fb.tcm-bs_cach.patch
Patch0034: 0034-Do-not-use-TimeoutStopSec-infinity.patch
Patch0035: 0035-Fix-session-check-during-lun-deactivate.patch
Patch0036: 0036-Force-rtslib-bs-cache-to-be-updated.patch
Patch0037: 0037-Skip-storage-objects-not-managed-by-ceph.patch
Patch0038: 0038-Check-for-max-supported-disks-during-lun-validation.patch
Patch0039: 0039-lun-validate-that-image-doesn-t-have-snapshots-prior.patch

BuildArch:  noarch

Requires:  python-crypto
Requires:  python-flask >= 0.10.1
Requires:  python-rados >= 2:12.1.2
Requires:  python-rbd >= 2:12.1.2
Requires:  python-netifaces
Requires:  python-rtslib >= 2.1.fb67-3
Requires:  tcmu-runner >= 1.4.0-0.1

BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  systemd

%description
Python package providing the modules used to handle the configuration of an
iSCSI gateway, backed by ceph/RBD. The rpm installs configuration management
logic (ceph_iscsi_config modules) and an rbd-target-gw systemd service.

The configuration management modules may be are consumed by custom Ansible
playbooks, and API server available from a separate rpm.

The rbd-target-gw service is responsible for startup and shutdown actions,
replacing the 'target' service used in standalone LIO implementations.

%prep
%setup -q

%patch0001 -p1
%patch0002 -p1
%patch0003 -p1
%patch0004 -p1
%patch0005 -p1
%patch0006 -p1
%patch0007 -p1
%patch0008 -p1
%patch0009 -p1
%patch0010 -p1
%patch0011 -p1
%patch0012 -p1
%patch0013 -p1
%patch0014 -p1
%patch0015 -p1
%patch0016 -p1
%patch0017 -p1
%patch0018 -p1
%patch0019 -p1
%patch0020 -p1
%patch0021 -p1
%patch0022 -p1
%patch0023 -p1
%patch0024 -p1
%patch0025 -p1
%patch0026 -p1
%patch0027 -p1
%patch0028 -p1
%patch0029 -p1
%patch0030 -p1
%patch0031 -p1
%patch0032 -p1
%patch0033 -p1
%patch0034 -p1
%patch0035 -p1
%patch0036 -p1
%patch0037 -p1
%patch0038 -p1
%patch0039 -p1

%build
%{__python2} setup.py build

%install
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}  --install-scripts %{_bindir}
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}/usr/bin
install -m 0644 .%{_unitdir}/rbd-target-gw.service %{buildroot}%{_unitdir}

%post
/bin/systemctl --system daemon-reload &> /dev/null || :
/bin/systemctl --system enable rbd-target-gw &> /dev/null || :

%files
%doc LICENSE
%doc README
%{python2_sitelib}/*
%{_bindir}/rbd-target-gw
%{_unitdir}/rbd-target-gw.service

%changelog
* Mon Feb 04 2019 Jason Dillaman <dillaman@redhat.com> 2.6-18
- lun: validate that image doesn't have snapshots prior to removal (rhbz#1642411)

* Tue Dec 11 2018 Mike Christie <mchristi@redhat.com> 2.6-17
- Bring in updated rtslib with SO cache fix (rhbz#1658173)

* Wed Nov 28 2018 Mike Christie <mchristi@redhat.com> 2.6-16
- Check for max supported disks during lun validation (rhbz#1651442)

* Fri Nov 16 2018 Mike Christie <mchristi@redhat.com> 2.6-15
- Skip storage objects not managed by ceph (rhbz#1648353)
- Force rtslib bs cache to be updated (rhbz#1648353)
- Fix session check during lun deactivate (rhbz#1650100)

* Thu Nov 08 2018 Mike Christie <mchristi@redhat.com> 2.6-14
- Do not use TimeoutStopSec infinity (rhbz#1641636)

* Tue Nov 06 2018 Jason Dillaman <dillaman@redhat.com> 2.6-13
- lun: helper method to clear the rtslib_fb.tcm bs_cache (rhbz#1639561)

* Mon Nov 05 2018 Jason Dillaman <dillaman@redhat.com> 2.6-12
- Initial support for IPv6 (rhbz#1643584)

* Tue Oct 16 2018 Jason Dillaman <dillaman@redhat.com> 2.6-11
- lun: support underscore characters in image name (rhbz#1639561)

* Fri Oct 12 2018 Jason Dillaman <dillaman@redhat.com> 2.6-10
- Handle tcmu control errors (rhbz#1615234)
- Move lun activate/deactivate from gwcli to config (rhbz#1615234)
- Make hw_max_sectors configurable (rhbz#1615234)
- Use controls normalize helper to validate disk ops (rhbz#1615234)
- Add helper to normalize a dict of controls (rhbz#1615234)
- mv control code to new class (rhbz#1615234)
- settings: fixed int regex matcher to require the full string (rhbz#1615234)

* Tue Oct 09 2018 Jason Dillaman <dillaman@redhat.com> 2.6-9
- Only allow num and alpha chars for image name (rhbz#1615234)
- Move valid_disk from gwcli to ceph-iscsi-config (rhbz#1615234)
- Limit log file size to 5MB. (rhbz#1619168)
- group: fix update_client() (rhbz#1589347)
- client: add 'reconfigure' support to the manage API method (rhbz#1589347)
- gateway: add 'reconfigure' support to the manage API method (rhbz#1589347)
- client: add support for gateway-level control overrides (rhbz#1589347)
- gateway: add support for gateway-level control overrides (rhbz#1589347)
- common: helper to replace config without merging dicts (rhbz#1589347)
- settings: add target-level overrides for IO configuration (rhbz#1589347)

* Tue Aug 21 2018 Jason Dillaman <dillaman@redhat.com> 2.6-8
- lun: translate all thrown exceptions when removing a device (rhbz#1562389)

* Wed Jul 25 2018 Jason Dillaman <dillaman@redhat.com> 2.6-7
- gateway: fixed variable name for exception (rhbz#1602158)
- Fix indention in bind_alua_group_to_lun (rhbz#1602158)
- Detect and handle invalid alua failover types (rhbz#1602158)
- Allow alua failover type to be configurable (rhbz#1602158)

* Fri Jul 13 2018 Jason Dillaman <dillaman@redhat.com> 2.6-6
- lun: carve out lun config update into a separate routine (rhbz#1600071)
- lun: use a copy of control dict when instantiating LUN (rhbz#1600071)

* Fri Jul 13 2018 Jason Dillaman <dillaman@redhat.com> 2.6-5
- utils: remove unused human_size (rhbz#1600071)
- Support integers as size args for LUN/RBDDev (rhbz#1600071)
- Move size suffix array to utils (rhbz#1600071)
- move define clients/luns to lib v2: (rhbz#1600071)

* Thu Jul 12 2018 Jason Dillaman <dillaman@redhat.com> 2.6-4
- Added missing dependency on python-flask (rhbz#1600613)

* Fri Jul 06 2018 Jason Dillaman <dillaman@redhat.com> 2.6-3
- Optionally include 'conf=/path/to/ceph.conf' in cfgstring (rhbz#1502021)

* Thu May 24 2018 Jason Dillaman <dillaman@redhat.com> 2.6-2
- make prometheus host configurable, with the defualt of '::' (rhbz#1566513)

* Sat May 5 2018 Jason Dillaman <dillaman@redhat.com> 2.6-1
- rebased to v2.6

* Thu Mar 29 2018 Jason Dillaman <dillaman@redhat.com> 2.3-13
- client: fix issue at boot where luns would not be mapped to clients (rhbz#1508695)
- Merge pull request #15 from ceph/group-fix

* Mon Oct 30 2017 Jason Dillaman <dillaman@redhat.com> 2.3-12
- settings: default qfull_timeout to zero (rhbz#1500757)
- ceph iscsi config: add max_data_area setting (rhbz#1500757)

* Thu Oct 05 2017 Jason Dillaman <dillaman@redhat.com> 2.3-11
- Abort lun mapping when an error occurs (rhbz#1498505)

* Fri Sep 29 2017 Jason Dillaman <dillaman@redhat.com> 2.3-10
- Updated cfgstring to use comma as delimiter between optionals

* Wed Sep 27 2017 Jason Dillaman <dillaman@redhat.com> 2.3-9
- Activate portals when the gateway is freshly started

* Sun Sep 24 2017 Jason Dillaman <dillaman@redhat.com> 2.3-8
- lun: fix import requests that use 0G for rbd image size
- rbd-target-gw: add exception handler to cleanly shutdown on errors
- gateway: log messages corrected

* Fri Sep 15 2017 Jason Dillaman <dillaman@redhat.com> 2.3-7
- Restored accidentally deleted config initialization lines

* Thu Sep 14 2017 Jason Dillaman <dillaman@redhat.com> 2.3-6
- Improved systemd limits and system protection
- Explicitly shut down RADOS when Python object destroyed

* Wed Sep 06 2017 Jason Dillaman <dillaman@redhat.com> 2.3-5
- Exclusive-lock should be the only required RBD image feature

* Tue Sep 05 2017 Jason Dillaman <dillaman@redhat.com> 2.3-4
- group: fixes to process flow

* Fri Sep 01 2017 Jason Dillaman <dillaman@redhat.com> 2.3-3
- group: doctext update
- group: host group management fixes
- utils: minor changes to the ListComparison class
- client: changes to support host group management

* Tue Aug 15 2017 Jason Dillaman <dillaman@redhat.com> - 2.3-2
- require epoch 2 Ceph packages

* Tue Aug 15 2017 Jason Dillaman <dillaman@redhat.com> 2.3-1
- rebased to v2.3

* Wed Jun 07 2017 Jason Dillaman <dillaman@redhat.com> 2.0-4
- stronger version requirement on python-rtslib

* Wed May 03 2017 Jason Dillaman <dillaman@redhat.com> 2.0-3
- added missing python-crypto dependency

* Wed Apr 26 2017 Jason Dillaman <dillaman@redhat.com> 2.0-2
- Disable tcmu cmd timeout
- start/depend on tcmu-runner
- gateway: alua config added using the rtslib alua module
- lun: Use bitwise comparison to confirm rbd flags are compatible
- client: add group_name to client meta data
- client/rbd-target-gw: added error handling to chap encrypt/decrypt
- rbd-target-gw: removal of redundant code, addition of CHAP class
- lio: remove redundance dm/rbdmap code
- lun: removal of dm/rbdmap related code
- gateway: temporary removal of the alua config code
- client: encryption of the nodeacl's chap password added
- utils: unnecessary dm related code removed
- settings: updated to include pub/priv key file name defaults
- client: cosmetic change to error message
- client: catch duplicate rbd requests for the same client
- settings: Default settings file name changed to iscsi-gateway.cfg
- gateway: initial update for rtslib_fb based ALUA module
- common: Version of config objects increased 1 -> 2

* Thu Jan 05 2017 Paul Cuzner <pcuzner@redhat.com> - 2.0-1
- daemon now watches the config object for changes, and reloads (for API)

* Fri Nov 04 2016 Paul Cuzner <pcuzner@redhat.com> - 1.5-1
- fix - catch config errors at rbd-target-gw startup
- config.lun - trap unwanted rbd map stderr messages
- rbd-target-gw - bypass shutdown if the gateway is not in the configuration (rhbz 1390022)
- config.client - fix handling of invalid client iqn (rhbz 1390023)
- rbd-target-gw - fix behaviour when daemon started prematurely (rhbz 1390022)
- config.common - resolve invalid json backtrace during config read (rhbz 1387297)

* Thu Oct 27 2016 Paul Cuzner <pcuzner@redhat.com> - 1.4-1
- fix - ensure large config objects are read correctly (rhbz 1387297)
- provide support for the same image name across mulitple rados pools (rhbz 1387952)
- add lun id to config object preventing potential data corruptions (rhbz 1387953)
- add create/update datestamps to config object metadata
- resolve rbd-target-gw reload/restart issues (rhbz 1388703)
- add lun remove capability
- fix rbd-target-gw to drop LIO configuration on a systemctl stop request

* Fri Oct 21 2016 Paul Cuzner <pcuzner@redhat.com> - 1.3-1
- fix disk size not showing correctly in targetcli following a resize (BZ 1386149)
- use of fqdn in the LUN request (BZ 1386939)
- rbd-target-gw - ensure tpgs are disabled on service shutdown
- config.gateway - create alua group per tpg
- config.client - reduce timeouts for faster path failover
- use global settings config file across modules (BZ 1386617)
- resize dm device following rbd size request (BZ 1386149)
- allow host names to use FQDN on LUN request (BZ 1386939)

* Sat Oct 15 2016 Paul Cuzner <pcuzner@redhat.com> - 1.2-1
- fix for BZ 1384858 - admin updated hosts file but did not add an ip to gateway_ip_list
- fix unblacklisting process in rbd-target-gw
- correct ALUA binding issue
- added a version number to the rados configuration object
- fix i/o delays when using non-optimised paths with ALUA

* Wed Oct 12 2016 Paul Cuzner <pcuzner@redhat.com> - 1.1-1
- spec file updated - patch from ktdreyer
- alua module reformatting in line with PEP 8
- gateway object can now defer adding portal IP to the active TPG
- rbd-target-gw now defers port IP allocation until nodeACLs are applied
- deferring IP allocation at boot time, prevents windows connectivity issues

* Tue Oct 11 2016 Paul Cuzner <pcuzner@redhat.com> - 1.0-3
- Minor patches to the rbd-target-gw script from Mike Christie

* Mon Oct 10 2016 Paul Cuzner <pcuzner@redhat.com> - 1.0-1
- Included initial patch from Mike Christie for alua portal group support

* Thu Oct 06 2016 Paul Cuzner <pcuzner@redhat.com> - 0.8-1
- fixed tpg creation on existing gateways when a new gateway(s) is added to the configuration
- removed rpm packages from the source archive

* Wed Oct 05 2016 Paul Cuzner <pcuzner@redhat.com> - 0.7-1
- added rbd-target-gw daemon (started at boot)

* Tue Oct 04 2016 Paul Cuzner <pcuzner@redhat.com> - 0.6-2
- more meta data added to the gateway dict

* Mon Oct 03 2016 Paul Cuzner <pcuzner@redhat.com> - 0.6-1
- update LUN module to use a pool/image key, and include more meta data on the disk object
- moved generic rados query functions to the common.utils module
- updated the client module to handle rbd names in pool/image format

* Tue Sep 27 2016 Paul Cuzner <pcuzner@redhat.com> - 0.5-1
- initial rpm build