예제 #1
0
def get_infinisdk_from_arguments(arguments):
    from infinisdk import InfiniBox
    from infinidat_openstack.versioncheck import raise_if_unsupported, get_system_version
    system = InfiniBox(arguments.address, use_ssl=True, auth=(arguments.username, arguments.password))
    system.login()
    raise_if_unsupported(get_system_version(arguments.address, arguments.username, arguments.password, system))
    return system
예제 #2
0
def apply(config_parser, address, pool_name, username, password, volume_backend_name=None, thick_provisioning=False, prefer_fc=False, infinidat_allow_pool_not_found=False, infinidat_purge_volume_on_deletion=False):
    import sys
    from infinisdk import InfiniBox
    from infinisdk.core.exceptions import SystemNotFoundException
    from infinidat_openstack.versioncheck import raise_if_unsupported, get_system_version
    try:
        system = InfiniBox(address, use_ssl=True, auth=(username, password))
    except SystemNotFoundException:
        system = None
    if system is None:
        print("Could not connect to system \"{}\"".format(pool_name), file=sys.stderr)
        raise SystemExit(1)
    system.login()
    raise_if_unsupported(get_system_version(address, username, password, system))
    pool = system.pools.safe_get(name=pool_name)
    if pool is None:
        print("Pool \"{}\" not found".format(pool_name), file=sys.stderr)
        raise SystemExit(1)
    pool_id = pool.get_id()
    key = "infinibox-{0}-pool-{1}".format(system.get_serial(), pool.get_id()) if not volume_backend_name else volume_backend_name
    enabled = True
    for backend in get_volume_backends(config_parser):
        if backend['address'] == address and backend['pool_id'] == pool_id:
            key = backend['key']
            enabled = key in get_enabled_backends(config_parser)
    if not config_parser.has_section(key):
        config_parser.add_section(key)
    config_parser.set(key, "volume_driver", VOLUME_DRIVER)
    for setting in SETTINGS:
        config_parser.set(key, setting[1], locals()[setting[0]])
    config_parser.set(key, 'san_password', mask(password))
    config_parser.set(key, "infinidat_provision_type", "thick" if thick_provisioning else "thin")
    config_parser.set(key, "infinidat_prefer_fc", prefer_fc)
    config_parser.set(key, "infinidat_allow_pool_not_found", infinidat_allow_pool_not_found)
    config_parser.set(key, "infinidat_purge_volume_on_deletion", infinidat_purge_volume_on_deletion)
    if enabled:
        enable(config_parser, key)
    return key