Example #1
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()
Example #2
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()
Example #3
0
 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)
Example #4
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()
Example #5
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)
Example #6
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()
Example #7
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()
Example #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)
         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()
Example #9
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()
Example #10
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)
Example #11
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)
Example #12
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)
Example #13
0
 def putGroup(self, group, user=None):
     """ Creates a group, or if a user is passed, adds that user to the group """
     if(user != None):
         # assume group exists and add user to it
         return GroupManagement.addUserToGroup(user, group)
     if GroupInfo.groupExists(group):
         return "Group already exists"
     GroupManagement.addGroup(group)
Example #14
0
 def putGroup(self, group, user=None):
     """ Creates a group, or if a user is passed, adds that user to the group """
     if (user != None):
         # assume group exists and add user to it
         return GroupManagement.addUserToGroup(user, group)
     if GroupInfo.groupExists(group):
         return "Group already exists"
     GroupManagement.addGroup(group)
Example #15
0
 def group(self, groupName):
     """ Web page of details about the user, and sets user priority """
     self.validate(groupName)
     users = GroupInfo.usersInGroup(groupName)
     priority = GroupManagement.getPriority(groupName)
     return self.templatepage("Group",
                              group=groupName,
                              users=users,
                              priority=priority)
Example #16
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)
Example #17
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)
Example #18
0
 def group(self, groupName):
     """ Web page of details about the user, and sets user priority """
     self.validate(groupName)
     users = GroupInfo.usersInGroup(groupName)
     priority = GroupManagement.getPriority(groupName)
     return self.templatepage("Group", group=groupName, users=users, priority=priority)
Example #19
0
 def groups(self):
     """ Lists all users.  Should be paginated later """
     allGroups = GroupInfo.listGroups()
     self.validate(allGroups)
     return self.templatepage("Groups", groups=allGroups)
Example #20
0
 def group(self, groupName):
     """ Web page of details about the group."""
     self.validate(groupName)
     users = GroupInfo.usersInGroup(groupName)
     return self.templatepage("Group", group=groupName, users=users)