Пример #1
0
def nfs_export_remove(req, host, path):
    found = False

    for e in Nfs.exports():
        if e.host == host and e.path == path:
            Nfs.export_remove(e)
            found = True

    if not found:
        raise TargetdError(-400, "NFS export to remove not found %s:%s",
                           (host, path))
Пример #2
0
def nfs_export_remove(req, host, path):
    found = False

    for e in Nfs.exports():
        if e.host == host and e.path == path:
            Nfs.export_remove(e)
            found = True

    if not found:
        raise TargetdError(
            TargetdError.NOT_FOUND_NFS_EXPORT,
            "NFS export to remove not found %s:%s" % (host, path))
Пример #3
0
def nfs_export_add(req,
                   host,
                   path,
                   options=None,
                   chown=None,
                   export_path=None):

    if not isinstance(options, list):
        if options is not None and len(options) > 0:
            options = [options]
        else:
            options = []

    if export_path is not None:
        raise TargetdError(
            TargetdError.NFS_NO_SUPPORT,
            "separate export path not supported at "
            "this time")
    bit_opt = 0
    key_opt = {}

    for o in options:
        if '=' in o:
            k, v = o.split('=')
            key_opt[k] = v
        else:
            bit_opt |= Export.bool_option[o]

    if chown is not None:
        if not allow_chown:
            raise TargetdError(
                TargetdError.NO_SUPPORT,
                "Chown is disabled. Consult manual before enabling it.")
        items = chown.split(':')
        try:
            uid = int(items[0])
            gid = -1
            if len(items) > 1:
                gid = int(items[1])
            os.chown(path, uid, gid)
        except ValueError as e:
            raise TargetdError(TargetdError.INVALID_ARGUMENT,
                               "Wrong chown arguments: {}".format(e))
    try:
        Nfs.export_add(host, path, bit_opt, key_opt)
    except ValueError as e:
        raise TargetdError(TargetdError.INVALID_ARGUMENT, "{}".format(e))
    return dict(host=host, path=path)
Пример #4
0
def nfs_export_add(req, host, path, export_path, options):

    if export_path is not None:
        raise TargetdError(
            -401, "separate export path not supported at "
            "this time")
    bit_opt = 0
    key_opt = {}

    for o in options:
        if '=' in o:
            k, v = o.split('=')
            key_opt[k] = v
        else:
            bit_opt |= Export.bool_option[o]

    Nfs.export_add(host, path, bit_opt, key_opt)
Пример #5
0
def nfs_export_list(req):
    rc = []
    exports = Nfs.exports()
    for e in exports:
        rc.append(dict(host=e.host, path=e.path, options=e.options_list()))
    return rc
Пример #6
0
def nfs_export_auth_list(req):
    return Nfs.security_options()