Metadata-Version: 2.1
Name: cinderlib
Version: 0.2.1
Summary: Cinder Library allows using storage drivers outside of Cinder.
Home-page: https://github.com/akrog/cinderlib
Author: Gorka Eguileor
Author-email: geguileo@redhat.com
License: Apache Software License 2.0
Keywords: cinderlib
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Provides-Extra: ds8k
Provides-Extra: 3par
Provides-Extra: kaminario
Provides-Extra: xiv
Provides-Extra: drbd
Provides-Extra: infinidat
Provides-Extra: eternus
Provides-Extra: pure
Provides-Extra: vmax
Provides-Extra: violin
Provides-Extra: rbd
Provides-Extra: lefthand
Provides-Extra: vnx
Requires-Dist: cinder (>=11.0<12.0)
Provides-Extra: 3par
Requires-Dist: hpe3parclient (>=4.1.0); extra == '3par'
Provides-Extra: drbd
Requires-Dist: dbus; extra == 'drbd'
Requires-Dist: drbdmanage; extra == 'drbd'
Provides-Extra: ds8k
Requires-Dist: pyOpenSSL (>=1.0.0); extra == 'ds8k'
Provides-Extra: eternus
Requires-Dist: pywbem (>=0.7.0); extra == 'eternus'
Provides-Extra: infinidat
Requires-Dist: infinisdk; extra == 'infinidat'
Requires-Dist: capacity; extra == 'infinidat'
Requires-Dist: infi.dtypes.wwn; extra == 'infinidat'
Requires-Dist: infi.dtypes.iqn; extra == 'infinidat'
Provides-Extra: kaminario
Requires-Dist: krest (>=1.3.0); extra == 'kaminario'
Provides-Extra: lefthand
Requires-Dist: python-lefthandclient (>=2.0.0); extra == 'lefthand'
Provides-Extra: pure
Requires-Dist: purestorage (>=1.6.0); extra == 'pure'
Provides-Extra: rbd
Requires-Dist: rados; extra == 'rbd'
Requires-Dist: rbd; extra == 'rbd'
Provides-Extra: violin
Requires-Dist: vmemclient (>=1.1.8); extra == 'violin'
Provides-Extra: vmax
Requires-Dist: pyOpenSSL (>=1.0.0); extra == 'vmax'
Provides-Extra: vnx
Requires-Dist: storops (>=0.4.8); extra == 'vnx'
Provides-Extra: xiv
Requires-Dist: pyxcli (>=1.1.5); extra == 'xiv'

Cinder Library
===============================

.. image:: https://img.shields.io/pypi/v/cinderlib.svg
   :target: https://pypi.python.org/pypi/cinderlib

.. image:: https://readthedocs.org/projects/cinderlib/badge/?version=latest
   :target: https://cinderlib.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status

.. image:: https://img.shields.io/pypi/pyversions/cinderlib.svg
   :target: https://pypi.python.org/pypi/cinderlib

.. image:: https://img.shields.io/:license-apache-blue.svg
   :target: http://www.apache.org/licenses/LICENSE-2.0


Introduction
------------

Cinder Library is a Python library that allows using storage drivers outside of
Cinder.

* Free software: Apache Software License 2.0
* Documentation: https://cinderlib.readthedocs.io.

This library is currently in Alpha stage and is primarily intended as a proof
of concept at this stage.  While some drivers have been manually validated most
drivers have not, so there's a good chance that they could experience issues.

When using this library one should be aware that this is in no way close to the
robustness or feature richness that the Cinder project provides, for detailed
information on the current limitations please refer to the documentation.

Due to the limited access to Cinder backends and time constraints the list of
drivers that have been manually tested are (I'll try to test more):

- LVM with LIO
- Dell EMC XtremIO
- Dell EMC VMAX
- Kaminario K2
- Ceph/RBD
- NetApp SolidFire

If you try the library with another storage array I would appreciate a note on
the library version, Cinder release, and results of your testing.

Features
--------

* Use a Cinder driver without running a DBMS, Message broker, or Cinder
  service.
* Using multiple simultaneous drivers on the same program.
* Basic operations support:

  - Create volume
  - Delete volume
  - Extend volume
  - Clone volume
  - Create snapshot
  - Delete snapshot
  - Create volume from snapshot
  - Connect volume
  - Disconnect volume
  - Local attach
  - Local detach
  - Validate connector

* Code should support multiple concurrent connections to a volume, though this
  has not yet been tested.
* Metadata persistence plugin:

  - Stateless: Caller stores JSON serialization.
  - Database: Metadata is stored in a database: MySQL, PostgreSQL, SQLite...
  - Custom plugin: Metadata is stored in another metadata storage.

Example
-------

The following example uses CentOS 7 and the Cinder LVM driver, which should be
the easiest to setup and test.

First you need to setup your system:

.. code-block:: shell

    $ sudo yum install -y centos-release-openstack-pike
    $ sudo yum install -y openstack-cinder targetcli python-pip
    $ sudo pip install cinderlib
    $ sudo dd if=/dev/zero of=cinder-volumes bs=1048576 seek=22527 count=1
    $ sudo lodevice=`losetup --show -f ./cinder-volumes`
    $ sudo pvcreate $lodevice
    $ sudo vgcreate cinder-volumes $lodevice
    $ sudo vgscan --cache

Then you need to run `python`  with a passwordless sudo user (required to
control LVM and do the attach) and execute:

.. code-block:: python

    import cinderlib as cl
    from pprint import pprint as pp

    # We setup the library to setup the driver configuration when serializing
    cl.setup(output_all_backend_info=True)

    # Initialize the LVM driver
    lvm = cl.Backend(volume_driver='cinder.volume.drivers.lvm.LVMVolumeDriver',
                     volume_group='cinder-volumes',
                     iscsi_protocol='iscsi',
                     iscsi_helper='lioadm',
                     volume_backend_name='lvm_iscsi')

    # Show the LVM backend stats
    pp(lvm.stats())

    # Create a 1GB volume
    vol = lvm.create_volume(1, name='lvm-vol')

    # Export, initialize, and do a local attach of the volume
    attach = vol.attach()

    pp('Volume %s attached to %s' % (vol.id, attach.path))

    # Snapshot it
    snap = vol.create_snapshot('lvm-snap')

    # Show the JSON string
    pp(vol.jsons)

    # Save the whole environment to a file
    with open('cinderlib-test.txt', 'w') as f:
        f.write(cl.dumps())

    # Exit python
    exit()

Now we can check that the logical volume is there, exported, and attached to
our system:

.. code-block:: shell

    # lvdisplay
    # targetcli ls
    # iscsiadm -m session
    # lsblk

And now let's run a new `python` interpreter and clean things up:

.. code-block:: python

    import cinderlib as cl

    # Get the whole environment up
    with open('cinderlib-test.txt') as f:
        backends = cl.load(f.read(), save=True)

    # Get the volume reference we loaded from file and detach
    vol = list(backends[0].volumes)[0]
    vol.detach()

    # Get the snapshot and delete it
    snap = list(vol.snapshots)[0]
    snap.delete()

    # Finally delete the volume
    vol.delete()

We should confirm that the logical volume is no longer there, there's nothing
exported or attached to our system:

.. code-block:: shell

    # lvdisplay
    # targetcli ls
    # iscsiadm -m session
    # lsblk

.. _GIGO: https://en.wikipedia.org/wiki/Garbage_in,_garbage_out
.. _official project documentation: https://readthedocs.org/projects/cinderlib/badge/?version=latest
.. _OpenStack's Cinder volume driver configuration documentation: https://docs.openstack.org/cinder/latest/configuration/block-storage/volume-drivers.html


=======
History
=======

0.2.1 (2018-06-14)
------------------

- Features:

  - Modify fields on connect method.
  - Support setting custom root_helper.
  - Setting default project_id and user_id.
  - Metadata persistence plugin mechanism
  - DB persistence plugin
  - No longer dependent on Cinder's attach/detach code
  - Add device_attached method to update volume on attaching node
  - Support attaching/detaching RBD volumes
  - Support changing persistence plugin after initialization
  - Add saving and refreshing object's metadata
  - Add dump, dumps methods

- Bug fixes:

  - Serialization of non locally attached connections.
  - Accept id field set to None on resource creation.
  - Disabling of sudo command wasn't working.
  - Fix volume cloning on XtremIO
  - Fix iSCSI detach issue related to privsep
  - Fix wrong size in volume from snapshot
  - Fix name & description inconsistency
  - Set created_at field on creation
  - Connection fields not being set
  - DeviceUnavailable exception
  - Multipath settings after persistence retrieval
  - Fix PyPi package created tests module
  - Fix connector without multipath info
  - Always call create_export and remove_export
  - iSCSI unlinking on disconnect

0.1.0 (2017-11-03)
------------------

* First release on PyPI.


