示例#1
0
 def index(self):
     """ Main web page for creating requests """
     # Get the scram Architecture from the keys and the
     # CMSSW versions from the values
     self.scramArchs = SoftwareAdmin.listSoftware().keys()
     versionLists = SoftwareAdmin.listSoftware().values()
     self.versions = []
     for l in versionLists:
         for v in l:
             if not v in self.versions:
                 self.versions.append(v)
     self.versions.sort()
     # see if this was configured with a hardcoded user.  If not, take from the request header 
     requestor = self.requestor
     if not requestor:
         requestor = cherrypy.request.user["login"]
     if not requestor:
         return "No username found in your certificate"
     if not requestor in Registration.listUsers():
         return "User %s is not registered.  Contact a ReqMgr administrator." % requestor
     groups = GroupInfo.groupsForUser(requestor).keys()
     if groups == []:
         return "User " + requestor + " is not in any groups.  Contact a ReqMgr administrator."
     campaigns = Campaign.listCampaigns()
     return self.templatepage("WebRequestSchema", yuiroot=self.yuiroot,
                              requestor=requestor,
                              groups=groups, 
                              versions=self.versions,
                              archs = self.scramArchs,
                              alldocs = Utilities.unidecode(self.allDocs()),
                              allcampaigns = campaigns,                     
                              defaultVersion=self.cmsswVersion,
                              defaultSkimConfig=self.defaultSkimConfig)
示例#2
0
 def index(self):
     """ Main web page for creating requests """
     # Get the scram Architecture from the keys and the
     # CMSSW versions from the values
     self.scramArchs = SoftwareAdmin.listSoftware().keys()
     versionLists = SoftwareAdmin.listSoftware().values()
     self.versions = []
     for l in versionLists:
         for v in l:
             if not v in self.versions:
                 self.versions.append(v)
     self.versions.sort()
     # see if this was configured with a hardcoded user.  If not, take from the request header
     requestor = self.requestor
     if not requestor:
         requestor = cherrypy.request.user["login"]
     if not requestor:
         return "No username found in your certificate"
     if not requestor in Registration.listUsers():
         return "User %s is not registered.  Contact a ReqMgr administrator." % requestor
     groups = GroupInfo.groupsForUser(requestor).keys()
     if groups == []:
         return "User " + requestor + " is not in any groups.  Contact a ReqMgr administrator."
     campaigns = Campaign.listCampaigns()
     return self.templatepage("WebRequestSchema",
                              yuiroot=self.yuiroot,
                              requestor=requestor,
                              groups=groups,
                              versions=self.versions,
                              archs=self.scramArchs,
                              alldocs=Utilities.unidecode(self.allDocs()),
                              allcampaigns=campaigns,
                              defaultVersion=self.cmsswVersion,
                              defaultArch=self.defaultArch,
                              defaultSkimConfig=self.defaultSkimConfig)
示例#3
0
 def deleteUser(self, user):
     """ Deletes a user, as well as deleting his requests and removing
         him from all groups """
     if user in self.getUser():
         requests = json.loads(self.getUser(user))['requests']
         for request in requests:
             self.deleteRequest(request)
         for group in GroupInfo.groupsForUser(user).keys():
             GroupManagement.removeUserFromGroup(user, group)
         return UserManagement.deleteUser(user)
示例#4
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users."""
     if group != None:
         result = {}
         result['users'] =  GroupInfo.usersInGroup(group)
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
示例#5
0
 def deleteUser(self, user):
     """ Deletes a user, as well as deleting his requests and removing
         him from all groups """
     if user in self.getUser():
         requests = json.loads(self.getUser(user))['requests']
         for request in requests:
             self.deleteRequest(request)
         for group in GroupInfo.groupsForUser(user).keys():
             GroupManagement.removeUserFromGroup(user, group)
         return UserManagement.deleteUser(user)
示例#6
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users."""
     if group != None:
         result = {}
         result['users'] = GroupInfo.usersInGroup(group)
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
示例#7
0
文件: Admin.py 项目: samircury/WMCore
 def user(self, userName):
     """ Web page of details about the user. """
     self.validate(userName)
     groups = GroupInfo.groupsForUser(userName).keys()
     requests = UserRequests.listRequests(userName).keys()
     allGroups = GroupInfo.listGroups()
     self.validate(groups)
     self.validate(requests)
     self.validate(allGroups)
     return self.templatepage("User", user=userName, groups=groups,
         allGroups=allGroups, requests=requests)
示例#8
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] =  GroupInfo.usersInGroup(group)
         result['priority'] = GroupManagement.getPriority(group)
         return json.dumps(result)
     elif user != None:   
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
示例#9
0
文件: Admin.py 项目: stuartw/WMCore
 def user(self, userName):
     """ Web page of details about the user, and sets user priority """
     self.validate(userName)
     groups = GroupInfo.groupsForUser(userName).keys()
     requests = UserRequests.listRequests(userName).keys()
     priority = UserManagement.getPriority(userName)
     allGroups = GroupInfo.listGroups()
     self.validate(groups)
     self.validate(requests)
     self.validate(allGroups)
     return self.templatepage("User", user=userName, groups=groups, 
         allGroups=allGroups, requests=requests, priority=priority)
示例#10
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] =  GroupInfo.usersInGroup(group)
         try:
             result['priority'] = GroupManagement.getPriority(group)
         except IndexError:
             raise cherrypy.HTTPError(404, "Cannot find group/group priority")
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
示例#11
0
 def getUser(self, userName = None, group = None):
     """ No args returns a list of all users.  Group returns groups this user is in.  Username
         returs a JSON with information about the user """
     if userName != None:
         if not Registration.isRegistered(userName):
             raise cherrypy.HTTPError(404, "Cannot find user")
         result = {}
         result['groups'] = GroupInfo.groupsForUser(userName).keys()
         result['requests'] = UserRequests.listRequests(userName).keys()
         result.update(Registration.userInfo(userName))
         return result
     elif group != None:
         GroupInfo.usersInGroup(group)
     else:
         return Registration.listUsers()
示例#12
0
 def getUser(self, userName=None, group=None):
     """ No args returns a list of all users.  Group returns groups this user is in.  Username
         returs a JSON with information about the user """
     if userName != None:
         if not Registration.isRegistered(userName):
             raise cherrypy.HTTPError(404, "Cannot find user")
         result = {}
         result['groups'] = GroupInfo.groupsForUser(userName).keys()
         result['requests'] = UserRequests.listRequests(userName).keys()
         result.update(Registration.userInfo(userName))
         return result
     elif group != None:
         GroupInfo.usersInGroup(group)
     else:
         return Registration.listUsers()
示例#13
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] = GroupInfo.usersInGroup(group)
         try:
             result['priority'] = GroupManagement.getPriority(group)
         except IndexError:
             raise cherrypy.HTTPError(404,
                                      "Cannot find group/group priority")
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
示例#14
0
 def user(self, userName):
     """ Web page of details about the user, and sets user priority """
     self.validate(userName)
     groups = GroupInfo.groupsForUser(userName).keys()
     requests = UserRequests.listRequests(userName).keys()
     priority = UserManagement.getPriority(userName)
     allGroups = GroupInfo.listGroups()
     self.validate(groups)
     self.validate(requests)
     self.validate(allGroups)
     return self.templatepage("User",
                              user=userName,
                              groups=groups,
                              allGroups=allGroups,
                              requests=requests,
                              priority=priority)