#! /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"""

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:')
        format_description(driver.desc)
        print('')
    print('')


def main():
    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')


if __name__ == '__main__':
    main()

@@ -630,16 +630,27 @@
 ers%22%22%22%0A%0A
+import os%0A%0A
 from cin
@@ -1330,16 +1330,186 @@
 main():%0A
+    tools_dir = os.path.dirname(os.path.abspath(__file__))%0A    cinder_root = os.path.dirname(tools_dir)%0A    cur_dir = os.getcwd()%0A    os.chdir(cinder_root)%0A%0A    try:%0A    
     prin
@@ -1524,32 +1524,36 @@
 E DRIVERS')%0A    
+  
+  
 print('=========
@@ -1552,32 +1552,36 @@
 =============')%0A
+    
     print_driver
@@ -1627,24 +1627,28 @@
 iver')%0A%0A    
+  
+  
 print('BACKU
@@ -1655,32 +1655,36 @@
 P DRIVERS')%0A    
+  
+  
 print('=========
@@ -1687,32 +1687,36 @@
 =========')%0A    
+  
+  
 print_drivers(ut
@@ -1754,24 +1754,28 @@
 p_driver')%0A%0A
+    
     print('F
@@ -1799,24 +1799,28 @@
 IVERS')%0A    
+ 
+   
 print('=====
@@ -1836,24 +1836,28 @@
 =========')%0A
+    
     print_dr
@@ -1902,16 +1902,54 @@
 river')%0A
+    finally:%0A        os.chdir(cur_dir)
 %0A%0Aif __n

Remove generate_driver_list dependency on cur dir