edit · history · print

Quick'n'dirty

#!/usr/bin/python

# sample usage:
# ./gen_usersconf.py biit 11600 50 1700 biit >> user.gen.conf

import sys

prefix=sys.argv[1]
start=int(sys.argv[2])
nr=int(sys.argv[3])
gids=sys.argv[4]
groups=prefix
vo=sys.argv[5]

def norm(nr, length):
        diff=length - len(str(nr))
        if (diff > 0):
                return "0"*diff + str(nr)
        else:
                return str(nr)

# simple users
for i in  range(start, start + nr + 1):
        row=str(i) + ":" + prefix + norm(i-start,3) + ":" + gids + ":" + groups + ":" + vo + "::"
        print row

# sgm
nrsgm=10
for i in range(start + nr + 1, start + nr + 1 + nrsgm):
        row=str(i) + ":" + prefix + "sgm" + norm(i-start - nr -1,3) + ":" + gids + "," + str(int(gids) +1) + ":" + groups + "," + groups +"sgm:"+ vo + ":sgm"
        print row

# prd
nrprd=10
for i in range(start + nr + 1 + nrsgm, start + nr + 1 + nrsgm + nrprd):
        row=str(i) + ":" + prefix + "prd" + norm(i-start - nr -1 -nrsgm,3) + ":" + gids + "," + str(int(gids) +2) + ":" + groups + "," + groups +"prd:"+ vo + ":prd"
        print row
edit · history · print
Page last modified on January 17, 2008, at 11:27 AM