Example #1
0
def load(args):
    path = '{cluster}.conf'.format(cluster=args.cluster)
    try:
        f = file(path)
    except IOError as e:
        raise exc.ConfigError(e)
    else:
        with contextlib.closing(f):
            return parse(f)
Example #2
0
def load(args):
    path = '{cluster}.conf'.format(cluster=args.cluster)
    try:
        f = file(path)
    except IOError as e:
        raise exc.ConfigError(
            "%s; has `ceph-deploy new` been run in this directory?" % e)
    else:
        with contextlib.closing(f):
            return parse(f)
Example #3
0
def load_raw(args):
    """
    Read the actual file *as is* without parsing/modifiying it
    so that it can be written maintaining its same properties.
    """
    path = '{cluster}.conf'.format(cluster=args.cluster)
    try:
        with open(path) as ceph_conf:
            return ceph_conf.read()
    except (IOError, OSError) as e:
        raise exc.ConfigError(e)
Example #4
0
def load_raw(args):
    """
    Read the actual file *as is* without parsing/modifiying it
    so that it can be written maintaining its same properties.

    :param args: Will be used to infer the proper configuration name
    :paran path: alternatively, use a path for any configuration file loading
    """
    path = args.ceph_conf or '{cluster}.conf'.format(cluster=args.cluster)
    try:
        with open(path) as ceph_conf:
            return ceph_conf.read()
    except (IOError, OSError) as e:
        raise exc.ConfigError(
            "%s; has `ceph-deploy new` been run in this directory?" % e)
Example #5
0
def load(args):
    """
    :param args: Will be used to infer the proper configuration name, or
    if args.ceph_conf is passed in, that will take precedence
    """
    path = args.ceph_conf or '{cluster}.conf'.format(cluster=args.cluster)

    try:
        f = open(path)
    except IOError as e:
        raise exc.ConfigError(
            "%s; has `ceph-deploy new` been run in this directory?" % e)
    else:
        with contextlib.closing(f):
            return parse(f)