예제 #1
0
    def invoke(self, _clerk, server='%'):
        mod = Model(readable=readable)
        yesterday = Date("today") - 1
        mod["server"] = server
        cur = _clerk.storage.dbc.cursor()
        sql =\
            """
            SELECT u.username, p.name, s.name, t.traffic
            FROM sys_user u, sys_user_traffic t, sys_server s, sys_plan p
            WHERE u.ID=t.userID
              AND p.ID=u.planID
              AND s.ID=u.serverID
              AND t.whichday = '%s'
              AND s.name like '%s%%'
            ORDER BY traffic DESC
            LIMIT 20
            """ % (yesterday.toSQL(), mod["server"])
        cur.execute(sql)
        mod["each"] = [{
            "username": username,
            "plan": plan,
            "server": server,
            "traffic": traffic,
        } for username, plan, server, traffic in cur.fetchall()]

        cur.execute("""
            SELECT name FROM sys_server
            """)
        mod["servers"] = [{"server": row[0]} for row in cur.fetchall()]
        return mod
예제 #2
0
    def invoke(self, _clerk, signupID, account, plan, server, cycLen, domains):

        p = _clerk.fetch(Signup, ID=long(signupID))
        p.plan = plan  # @TODO: capture plan in cornerhost signups
        p.username = account
        p.cycLen = cycLen

        #try:
        pw = self.makeUser(server, p)
        #except xmlrpclib.Fault, f:
        #    print >> self, "XMLRPC fault: %s" % f.faultString
        #    return

        ## now the account in duckbill:
        u = _clerk.fetch(User, username=account)
        u.account = p.toDuckbill()
        _clerk.store(u)

        p.status = "filled"
        _clerk.store(p)

        doms = [item.strip() for item in domains.split() if item.strip()]
        g = NewSiteGrunt(_clerk, u, sabrenOK=True)
        for dname in doms:
            g.newSite(dname)

        ## show the password!
        #@TODO: make this do something sensible instead
        assert 0, "password for %s is %s" % (account, pw)
        return Model(message=trim('''
            <p>password for %s is %s<br/>
            <a href="admin.app?action=jump&jumpto=%s">see user</a></p>
            ''' % (account, pw, username)))
예제 #3
0
    def invoke(self, _clerk):
        signups = _clerk.match(Signup)

        def byDate(a, b):
            return cmp(a.TS, b.TS)

        signups.sort(byDate)
        return Model(signups=[BoxView(p) for p in signups])
예제 #4
0
 def invoke(self):
     return Model()
예제 #5
0
 def invoke(self, _clerk, ID):
     p = _clerk.fetch(Signup, ID=ID)
     return Model(signup=BoxView(p))
예제 #6
0
 def invoke(self, _clerk):
     return Model(servers=[
         BoxView(s) for s in _clerk.match(Server, status="active")
     ])
예제 #7
0
 def invoke(self, _clerk, _sess, reversed):
     user = self.loadUser(_clerk, _sess)
     if reverse(user.username) == reversed:
         return Model(message=user.getBeaker().userdel(user.username))
     else:
         return Model(message="reversed name did not match")
예제 #8
0
 def invoke(self, _clerk, _sess, password):
     if self.loadUser(_clerk, _sess).ispasswd(password):
         return Model(message="yes")
     else:
         return Model(message="no")
예제 #9
0
 def invoke(self, server):
     beaker = remote.getBeaker(server)
     return Model(
         message="restarting apache on %s: %s" \
         % (server, beaker.genhttpconf()))