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
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)))
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])
def invoke(self): return Model()
def invoke(self, _clerk, ID): p = _clerk.fetch(Signup, ID=ID) return Model(signup=BoxView(p))
def invoke(self, _clerk): return Model(servers=[ BoxView(s) for s in _clerk.match(Server, status="active") ])
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")
def invoke(self, _clerk, _sess, password): if self.loadUser(_clerk, _sess).ispasswd(password): return Model(message="yes") else: return Model(message="no")
def invoke(self, server): beaker = remote.getBeaker(server) return Model( message="restarting apache on %s: %s" \ % (server, beaker.genhttpconf()))