libStorageMgmt - universal storage management library

    I want to talk about a young, but promising library, born in the company Redhat, designed to simplify the life of the system administrators of large and heterogeneous data centers. The library works with data warehouses of different manufacturers (currently Linux, NetApp, Nexenta, EMC) using the same commands. For example, to create a file system on any of the storages, just run:
     # LSMCLI_URI=nstor://admin@192.168.1.138/ lsmcli --create-fs=test --pool=data --size=5G
    


    LSMCLI_URI is the destination address of the command. Depending on the “protocol” (nstor: //), lsmcli understands what type of storage it is necessary to communicate with and loads the appropriate plug-in. The plugin does all the necessary work.

    All lsm commands can be divided into 3 categories:
    • Work with file systems (create, listing, delete)
    • create, delete uninstall NFS exports
    • work with volumes (iSCSI), assignment of rights for initiators

    LibStorageMgmt is designed so that it does not store any states and values ​​inside. This is done because of possible actions on the repository itself, bypassing the library. The launch of the command performs a full cycle of necessary operations on the storage and immediately gives the result (a timeout is provided).

    At the request of Nexenta, I developed a plugin for this library. I want to share my experience, and most importantly to urge the development of plugins for other repositories!

    To do this is quite simple, and is detailed in the documentation. I will not repeat the texts, I will give only a couple of links:

    I will give an example of a template in Python (you can write in C), filling in which you can get a full-fledged plugin:
    File No. 1. lsm / anystorage_plugin:
    import sys
    from lsm.anystorage import AnyStorage
    from lsm.pluginrunner import PluginRunner
    if __name__ == '__main__':
        PluginRunner(AnyStorage, sys.argv).run()
    

    File number 2. lsm / lsm / anystorage.py:
    import urllib2
    import urlparse
    import simplejson as json
    import base64
    from iplugin import INfs, IStorageAreaNetwork
    from data import Pool, FileSystem, Snapshot, Capabilities, System, \
        NfsExport, Volume, Initiator, AccessGroup
    from common import LsmError, ErrorNumber, md5
    class AnyStorage(INfs, IStorageAreaNetwork):
        def __init__(self):
            self.password = None
            self.timeout = None
        def startup(self, uri, password, timeout, flags = 0):
            self.password = password or 'default_pass'
            self.timeout = timeout
        def pools(self, flags = 0):
            pools = []
            # Add pools here
            # ...	
            return pools
    


    The plugin will return a list of pools. The pools () function should return a list of objects of the Pool class. Further, lsm itself carries out list processing and displays (for lsmcli -l POOLS). Similar classes exist for file systems, snapshots, etc.

    A description of all other functions can be found in the declaration INfs, IStorageAreaNetwork (file lsm / lsm / iplugin.py).

    If you need to crash, you need to create an exception based on the LsmError class:
    raise LsmError(ErrorNumber.INVALID_SS, "Cant'create snapshot %s" % snapshot_name)
    


    Most functions should return None on success, or job_id on long execution. An example of a long command: replication, which can last minutes and hours. In the case of using job_id, it will be necessary to implement a couple of functions that will allow you to monitor jobs (job_status (), job_free ()).

    In general, the lsm library code is well documented and has a very clear structure.

    libStorageMgmt is so young that it doesn’t even realize all the features of working with Linux LVM. It's only the beginning!

    Also popular now: