cinder/tools/generate_driver_list.py
Sean McGinnis 3c18c6f440 Add interface documentation to driver devref
Link the docstring generated documentation for the driver interfaces into
the drivers devref page for easy access to driver method documentation.

Change-Id: Ie22599fef99ebfac12f3b9bb251ae5bdfff4bff6
2016-07-24 17:23:29 -05:00

67 lines
2.0 KiB
Python
Executable File

#! /usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Generate list of cinder drivers"""
import os
from cinder.interface import util
def format_description(desc):
desc = desc or '<None>'
lines = desc.rstrip('\n').split('\n')
for line in lines:
print(' %s' % line)
def print_drivers(drivers, config_name):
# for driver in drivers.sort(key=lambda x: x.class_fqn):
for driver in sorted(drivers, key=lambda x: x.class_fqn):
print(driver.class_name)
print('-' * len(driver.class_name))
if driver.version:
print('* Version: %s' % driver.version)
print('* %s=%s' % (config_name, driver.class_fqn))
print('* Description::')
print('')
format_description(driver.desc)
print('')
print('')
def main():
tools_dir = os.path.dirname(os.path.abspath(__file__))
cinder_root = os.path.dirname(tools_dir)
cur_dir = os.getcwd()
os.chdir(cinder_root)
try:
print('VOLUME DRIVERS')
print('==============')
print_drivers(util.get_volume_drivers(), 'volume_driver')
print('BACKUP DRIVERS')
print('==============')
print_drivers(util.get_backup_drivers(), 'backup_driver')
print('FC ZONE MANAGER DRIVERS')
print('=======================')
print_drivers(util.get_fczm_drivers(), 'zone_driver')
finally:
os.chdir(cur_dir)
if __name__ == '__main__':
main()