Example #1
0
def _get_drivers_map():
    def get_key(driver_name):
        key = driver_name.lower()
        if key.endswith('driver'):
            key = key[:-6]
        return key

    try:
        drivers = cinderlib.list_supported_drivers()
    except Exception:
        LOG.warning('System driver mappings not loaded')
        return {}

    mapping = {get_key(k): v['class_fqn'] for k, v in drivers.items()}
    return mapping
Example #2
0
    def _get_drivers_map():
        """Get mapping for drivers NiceName to PythonNamespace."""
        def get_key(driver_name):
            """Return driver nice name.

            Driver nice name comes from lowercased class name without the
            driver sufix.
            """
            key = driver_name.lower()
            if key.endswith('driver'):
                key = key[:-6]
            return key

        try:
            drivers = cinderlib.list_supported_drivers()
        except Exception:
            LOG.warning('System driver mappings not loaded')
            return {}

        mapping = {get_key(k): v['class_fqn'] for k, v in drivers.items()}
        return mapping
Example #3
0
def main():
    def get_key(driver_name):
        if driver_name.lower().endswith('driver'):
            driver_name = driver_name[:-6]
        return driver_name

    parser = argparse.ArgumentParser(prog=sys.argv[0])
    parser.add_argument('-o',
                        '--output',
                        type=argparse.FileType('w'),
                        default=sys.stdout,
                        help="Output file")
    parser.add_argument('-d', '--detailed', action="store_true")
    args = parser.parse_args()

    drivers = cinderlib.list_supported_drivers()

    if not args.detailed:
        drivers = [get_key(k) for k in sorted(drivers.keys())]
    else:
        drivers = {get_key(k): v for k, v in drivers.items()}

    result = json.dumps(drivers, sort_keys=True, indent=4)
    args.output.write(result)