~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to services/usrmgt-server

  • Committer: Matt Giuca
  • Date: 2009-02-24 02:02:03 UTC
  • mto: This revision was merged to the branch mainline in revision 1119.
  • Revision ID: matt.giuca@gmail.com-20090224020203-aqdcjnsj6y7wl32o
Added a new look to the IVLE header bar. Mmmm... Web 2.0.
Added top-level directory image-source, containing SVG and script files for
    generating the images.
ivle/webapp/coremedia/images: Added 'chrome' directory containing the rendered
    images.
Modified ivle/webapp/base/ivle-headings.html and
    ivle/webapp/coremedia/ivle.css to support the new images.
    Note that the H1 and H2 at the top of the page are no longer displayed
    (and their custom styles have been removed). There is a heading image
    instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#   - Rebuild svn auth file
28
28
#   - Rebuild passwd + push to nodes.
29
29
 
30
 
def activate_user(props):
 
30
def activate_user(store, props):
31
31
    """Create the on-disk stuff for the given user.
32
32
       Sets the state of the user in the db from pending to enabled.
33
33
       Expected properties:
40
40
 
41
41
    login = props['login']
42
42
 
43
 
    store = ivle.database.get_store()
44
 
 
45
 
    try:
46
 
 
47
 
        # FIXME: check we're pending
48
 
 
49
 
        # Get the full User object from the db associated with this
50
 
        user = ivle.database.User.get_by_login(store, login)
51
 
 
52
 
        # make svn config/auth
53
 
 
54
 
        repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
55
 
        logging.debug("Creating user's Subversion repository")
56
 
        ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
57
 
 
58
 
        rebuild_svn_config(props)
59
 
 
60
 
        logging.debug("Adding Subversion authentication")
61
 
        passwd = ivle.makeuser.make_svn_auth(store, login,
62
 
                                             throw_on_error=True)
63
 
        logging.debug("passwd: %s" % passwd)
64
 
 
65
 
        logging.debug("Creating jail")
66
 
        ivle.makeuser.make_jail(login, user.unixid, svn_pass=passwd)
67
 
 
68
 
        logging.info("Enabling user")
69
 
        user.state = u'enabled'
70
 
 
71
 
        store.commit()
72
 
 
73
 
        return {"response": "okay"}
74
 
 
75
 
    finally:
76
 
        store.close()
77
 
 
78
 
def rebuild_svn_config(props):
 
43
    # FIXME: check we're pending
 
44
 
 
45
    # Get the full User object from the db associated with this
 
46
    user = ivle.database.User.get_by_login(store, login)
 
47
 
 
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)
 
52
 
 
53
    rebuild_svn_config(store, props)
 
54
 
 
55
    logging.debug("Adding Subversion authentication")
 
56
    passwd = ivle.makeuser.make_svn_auth(store, login,
 
57
                                         throw_on_error=True)
 
58
 
 
59
    logging.debug("Creating jail")
 
60
    ivle.makeuser.make_jail(user)
 
61
 
 
62
    logging.info("Enabling user")
 
63
    user.state = u'enabled'
 
64
 
 
65
    return {"response": "okay"}
 
66
 
 
67
def rebuild_svn_config(store, props):
79
68
    """Rebuilds the svn config file
80
69
    Return value:
81
70
        response (okay, failure)
82
71
    """
83
72
    try:
84
 
        ivle.makeuser.rebuild_svn_config()
 
73
        ivle.makeuser.rebuild_svn_config(store)
85
74
    except Exception, e:
86
75
        logging.warning('Rebuild of Subversion authorization config failed!')
87
76
        return{'response': 'failure', 'msg': repr(e)}
88
77
 
89
78
    return {'response': 'okay'}
90
79
 
91
 
def rebuild_svn_group_config(props):
 
80
def rebuild_svn_group_config(store, props):
92
81
    """Rebuilds the svn group config file
93
82
    Return value:
94
83
        response (okay, failure)
95
84
    """
96
85
    try:
97
 
        ivle.makeuser.rebuild_svn_group_config()
 
86
        ivle.makeuser.rebuild_svn_group_config(store)
98
87
    except Exception, e:
99
88
        logging.warning(
100
89
            'Rebuild of Subversion group authorization config failed!')
102
91
 
103
92
    return {'response': 'okay'}
104
93
 
105
 
def create_group_repository(props):
 
94
def create_group_repository(store, props):
106
95
    """Creates on disk repository for the given group
107
96
    Expected properties:
108
97
        subj_short_name, year, semester, groupnm
135
124
    }
136
125
 
137
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))
 
130
 
138
131
    try:
139
132
        pidfile = open('/var/run/usrmgt-server.pid', 'w')
140
133
        pidfile.write('%d\n' % os.getpid())
145
138
 
146
139
def dispatch(props):
147
140
    logging.debug(repr(props))
 
141
 
 
142
    store = ivle.database.get_store()
148
143
    action = props.keys()[0]
149
 
    return actions[action](props[action])
 
144
    res = actions[action](store, props[action])
 
145
 
 
146
    if res['response'] == 'okay':
 
147
        store.commit()
 
148
    else:
 
149
        store.rollback()
 
150
    store.close()
 
151
    return res
150
152
 
151
153
if __name__ == "__main__":
152
154
    pid = os.getpid()
153
155
 
154
 
    logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
155
 
    logging.info("Starting usrmgt server on port %d (pid = %d)" %
156
 
                 (ivle.conf.usrmgt_port, pid))
157
 
 
158
156
    ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
159
157
                           True, dispatch, initializer)