41
41
login = props['login']
47
# FIXME: check we're pending
49
details = db.get_user(login)
51
# make svn config/auth
53
repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
54
logging.debug("Creating user's Subversion repository")
55
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
57
rebuild_svn_config(props)
59
logging.debug("Adding Subversion authentication")
60
passwd = ivle.makeuser.make_svn_auth(login, throw_on_error=True)
61
logging.debug("passwd: %s" % passwd)
63
logging.debug("Creating jail")
64
ivle.makeuser.make_jail(login, details.unixid, svn_pass=passwd)
66
logging.info("Enabling user")
67
db.update_user(login, state='enabled')
69
return {"response": "okay"}
74
def rebuild_svn_config(props):
43
# FIXME: check we're pending
45
# Get the full User object from the db associated with this
46
user = ivle.database.User.get_by_login(store, login)
48
# make svn config/auth
49
repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
50
logging.debug("Creating user's Subversion repository")
51
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
53
rebuild_svn_config(store, props)
55
logging.debug("Adding Subversion authentication")
56
passwd = ivle.makeuser.make_svn_auth(store, login,
59
logging.debug("Creating jail")
60
ivle.makeuser.make_jail(user)
62
logging.info("Enabling user")
63
user.state = u'enabled'
65
return {"response": "okay"}
67
def rebuild_svn_config(store, props):
75
68
"""Rebuilds the svn config file
77
70
response (okay, failure)
80
ivle.makeuser.rebuild_svn_config()
73
ivle.makeuser.rebuild_svn_config(store)
81
74
except Exception, e:
82
75
logging.warning('Rebuild of Subversion authorization config failed!')
83
76
return{'response': 'failure', 'msg': repr(e)}
85
78
return {'response': 'okay'}
87
def rebuild_svn_group_config(props):
80
def rebuild_svn_group_config(store, props):
88
81
"""Rebuilds the svn group config file
90
83
response (okay, failure)
93
ivle.makeuser.rebuild_svn_group_config()
86
ivle.makeuser.rebuild_svn_group_config(store)
94
87
except Exception, e:
96
89
'Rebuild of Subversion group authorization config failed!')
99
92
return {'response': 'okay'}
101
def create_group_repository(props):
94
def create_group_repository(store, props):
102
95
"""Creates on disk repository for the given group
103
96
Expected properties:
104
97
subj_short_name, year, semester, groupnm
133
126
def initializer():
127
logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
128
logging.info("Starting usrmgt server on port %d (pid = %d)" %
129
(ivle.conf.usrmgt_port, pid))
135
132
pidfile = open('/var/run/usrmgt-server.pid', 'w')
136
133
pidfile.write('%d\n' % os.getpid())
142
139
def dispatch(props):
143
140
logging.debug(repr(props))
142
store = ivle.database.get_store()
144
143
action = props.keys()[0]
145
return actions[action](props[action])
144
res = actions[action](store, props[action])
146
if res['response'] == 'okay':
147
153
if __name__ == "__main__":
148
154
pid = os.getpid()
150
logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
151
logging.info("Starting usrmgt server on port %d (pid = %d)" %
152
(ivle.conf.usrmgt_port, pid))
154
156
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
155
157
True, dispatch, initializer)