Пример #1
0
def _cache_check_default(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    ucache = FreeNAS_UserCache()
    gcache = FreeNAS_GroupCache()
    ducache = FreeNAS_Directory_UserCache()
    dgcache = FreeNAS_Directory_GroupCache()

    for arg in kwargs['args']:
        key = val = None
        try:
            parts = arg.split('=')
            key = parts[0]
            val = join(parts[1:], '=')

        except:
            continue

        if key == 'u':
            if ucache and ucache.has_key(val) and ucache[val]:
                print "%s: %s" % (val, ucache[val])

        elif key == 'g':
            if gcache and gcache.has_key(val) and gcache[val]:
                print "%s: %s" % (val, gcache[val])

        elif key == 'du':
            if ducache and ducache.has_key(val) and ducache[val]:
                print "%s: %s" % (val, ducache[val])

        elif key == 'dg':
            if dgcache and dgcache.has_key(val) and dgcache[val]:
                print "%s: %s" % (val, dgcache[val])
Пример #2
0
def _cache_check_default(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    ucache = FreeNAS_UserCache()
    gcache = FreeNAS_GroupCache()
    ducache = FreeNAS_Directory_UserCache()
    dgcache = FreeNAS_Directory_GroupCache()

    for arg in kwargs['args']:
        key = val = None
        try:
            parts = arg.split('=')
            key = parts[0]
            val = join(parts[1:], '=')

        except:
            continue

        if key == 'u':
            if ucache and ucache.has_key(val) and ucache[val]:
                print "%s: %s" % (val, ucache[val])

        elif key == 'g':
            if gcache and gcache.has_key(val) and gcache[val]:
                print "%s: %s" % (val, gcache[val])

        elif key == 'du':
            if ducache and ducache.has_key(val) and ducache[val]:
                print "%s: %s" % (val, ducache[val])

        elif key == 'dg':
            if dgcache and dgcache.has_key(val) and dgcache[val]:
                print "%s: %s" % (val, dgcache[val])
Пример #3
0
def _cache_check_NT4(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d
        valid[workgroup] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="): 
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="): 
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="): 
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="): 
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue


        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            workgroup = parts[0]
            if not valid.has_key(workgroup):
                continue

            ucache = FreeNAS_UserCache(dir=workgroup)
            gcache = FreeNAS_GroupCache(dir=workgroup)
            ducache = FreeNAS_Directory_UserCache(dir=workgroup)
            dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])


        elif key in ('du', 'dg'):
            for workgroup in valid.keys():
                ucache = FreeNAS_UserCache(dir=workgroup)
                gcache = FreeNAS_GroupCache(dir=workgroup)
                ducache = FreeNAS_Directory_UserCache(dir=workgroup)
                dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgcache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Пример #4
0
def _cache_check_NIS(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    ad = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        valid[d] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="): 
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="): 
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="): 
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="): 
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue


        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            d = parts[0]
            if not valid.has_key(d):
                continue

            ucache = FreeNAS_UserCache(dir=d)
            gcache = FreeNAS_GroupCache(dir=d)
            ducache = FreeNAS_Directory_UserCache(dir=d)
            dgcache = FreeNAS_Directory_GroupCache(dir=d)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])


        elif key in ('du', 'dg'):
            for d in valid.keys():
                ucache = FreeNAS_UserCache(dir=d)
                gcache = FreeNAS_GroupCache(dir=d)
                ducache = FreeNAS_Directory_UserCache(dir=d)
                dgcache = FreeNAS_Directory_GroupCache(dir=d)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Пример #5
0
def _cache_check_NT4(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d
        valid[workgroup] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="):
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="):
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="):
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="):
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue

        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            workgroup = parts[0]
            if not valid.has_key(workgroup):
                continue

            ucache = FreeNAS_UserCache(dir=workgroup)
            gcache = FreeNAS_GroupCache(dir=workgroup)
            ducache = FreeNAS_Directory_UserCache(dir=workgroup)
            dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])

        elif key in ('du', 'dg'):
            for workgroup in valid.keys():
                ucache = FreeNAS_UserCache(dir=workgroup)
                gcache = FreeNAS_GroupCache(dir=workgroup)
                ducache = FreeNAS_Directory_UserCache(dir=workgroup)
                dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgcache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Пример #6
0
def _cache_check_NIS(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    ad = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        valid[d] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="):
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="):
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="):
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="):
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue

        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            d = parts[0]
            if not valid.has_key(d):
                continue

            ucache = FreeNAS_UserCache(dir=d)
            gcache = FreeNAS_GroupCache(dir=d)
            ducache = FreeNAS_Directory_UserCache(dir=d)
            dgcache = FreeNAS_Directory_GroupCache(dir=d)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])

        elif key in ('du', 'dg'):
            for d in valid.keys():
                ucache = FreeNAS_UserCache(dir=d)
                gcache = FreeNAS_GroupCache(dir=d)
                ducache = FreeNAS_Directory_UserCache(dir=d)
                dgcache = FreeNAS_Directory_GroupCache(dir=d)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])