This package provides a cross-platform API for working with iSCSI storage systems. Currently supported operating systems are Linux (Ubuntu, Redhat, SUSE) and Windows. Support for Solaris and AIX is underway.
Some operating systems need initial preparation to work with iSCSI. For example, on Windows the iSCSI service must be started and on Linux there may be packages that must be installed. The relevant API methods are:
is_installed
: Returns whether iSCSI can be usedinstall
: Activate the iSCSI feature or software on an operating systemuninstall
: Deactivate iSCSI feature or software
Example:
from infi.iscsiapi import get_iscsi_software_initiator
software_initiator = get_iscsi_software_initiator()
if not software_initiator.is_installed():
software_initiator.install()
The operating system generates an IQN address for the software initiator (for example: iqn.1994-05.com.redhat:d6677488767) The relevant API methods are:
get_source_iqn
: get the current source IQNset_source_iqn
: receive an IQN address as a string, verify it's valid and set it
Example:
from infi.iscsiapi import get_iscsiapi
api = get_iscsiapi()
print api.get_source_iqn()
To connect to an iSCSI storage array, the host first runs "discovery" on one of the IP addresses of the storage system to get all the relevant IP addresses. Then for each IP addresses the host runs "login" to get an iSCSI "session". The relevant API methods are:
discover
: perform an iSCSI discovery to an ip address. Returns aTarget
instance.get_discovered_targets
: return a list of discovered target objectsundiscover
: delete all discovered sessions or only iqn specific active sessionslogin
: receives target and endpoint (IP address and port) and login to itlogin_all
: login to all endpoints of a target and return the session it achievedget_sessions
: list all connected sessions or sessions connected to a specific target.logout
: receive a session and perform an iSCSI logoutlogout_all
: receive a target and logout of all its sessions
Example:
from infi.iscsiapi import get_iscsiapi
api = get_iscsiapi()
target = api.discover("192.168.1.10")
api.login_all(target)
This project is available on PyPI. You can install it by running:
easy_install infi.iscsiapi
or
pip install infi.iscsiapi
This project uses infi.projector for building the development environment. For development purposes, clone this repository and run the following commands:
easy_install infi.projector
projector devenv build
Python 3 support is experimental and not fully tested.