
Cinderlib cannot properly load configuration options of the type ListOpt, or MultiOpt where each item is a dictionary, or DictOpt... For example, when we try to load a ListOpt option we will see: oslo_config.cfg.ConfigFileValueError: Value for option XYZ from LocationInfo(location=<Locations.user: (4, True)>, detail='/home/me/in_memory_file') is not valid: Value should start with "[" This is because cinderlib is treating this option as a MultiOpt. Cinderlib used to just set the values of the options in the instance and pass it to the driver, and back then we had no problems with complex types. The problem with that approach is that there are some drivers (like NetApp's) that dynamically add configuration options and then force a reload of the file, and they couldn't work with our old approach. So we changed to used oslo.config's normal parsing of files, but to do that we had to convert the driver parameters passed to cinderlib to a config file and make the parser use a StringIO instance instead of a real file. We also had to prevent it from looking at the CLI options (since those belong to the program that imports the library). This new approach is more complex, because cinderlib receives the parameters as Python primitives (list, dicts, integers, etc.), but the Oslo config parser expects an INI file conforming to the non standard types it provides. Some of these non standar types are: - DictOpt is in the form: option = key1:value1,key2:value2 - MultiOpt is in the form: option = value1 option = value2 - ListOpt is in the form: option = [value1,value2] So cinderlib would receive a list [value1, value2] or a tuple (value1, value2) and needs to generate a string with the right configuration option which can be in the form of a MultiOpt or a ListOpt, depending on how the configuration option was defined. This patch adds more logic to the conversion of cinder driver configuration parameters to oslo config file and uses the configuration options definitions to decide what conversion needs to be done. With this change we now do the right converstion for ListOpt, DictOpt, and we can even support MultiOpt options that have dictionaries as items. Closes-Bug: #1854188 Change-Id: I62e992804a3ae6aa0b4aa4f883807783197d4b33
Cinder Library
Introduction
The Cinder Library, also known as cinderlib, is a Python library that leverages the Cinder project to provide an object oriented abstraction around Cinder's storage drivers to allow their usage directly without running any of the Cinder services or surrounding services, such as KeyStone, MySQL or RabbitMQ.
- Free software: Apache Software License 2.0
- Documentation: https://docs.openstack.org/cinderlib/latest/
The library is intended for developers who only need the basic CRUD functionality of the drivers and don't care for all the additional features Cinder provides such as quotas, replication, multi-tenancy, migrations, retyping, scheduling, backups, authorization, authentication, REST API, etc.
The library was originally created as an external project, so it didn't have the broad range of backend testing Cinder does, and only a limited number of drivers were validated at the time. Drivers should work out of the box, and we'll keep a list of drivers that have added the cinderlib functional tests to the driver gates confirming they work and ensuring they will keep working.
Features
- Use a Cinder driver without running a DBMS, Message broker, or Cinder service.
- Using multiple simultaneous drivers on the same application.
- 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
- Extra Specs for specific backend functionality.
- Backend QoS
- Multi-pool support
- Metadata persistence plugins:
- Stateless: Caller stores JSON serialization.
- Database: Metadata is stored in a database: MySQL, PostgreSQL, SQLite...
- Custom plugin: Caller provides module to store Metadata and cinderlib calls it when necessary.
Demo
