How to use the dirac.lib.credentials.getSelectedGroup function in DIRAC

To help you get started, we’ve selected a few DIRAC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / PilotMonitor.py View on Github external
def submit(self):
    pagestart = time()
    lhcbGroup = credentials.getSelectedGroup()
    if lhcbGroup == "visitor":
      c.result = {"success":"false","error":"You are not authorised"}
      return c.result
    RPC = getRPCClient("WorkloadManagement/WMSAdministrator")
    result = self.__request()
    result = RPC.getPilotMonitorWeb(result,globalSort,pageNumber,numberOfJobs)
    if result["OK"]:
      result = result["Value"]
      if result.has_key("TotalRecords") and  result["TotalRecords"] > 0:
        if result.has_key("ParameterNames") and result.has_key("Records"):
          if len(result["ParameterNames"]) > 0:
            if len(result["Records"]) > 0:
              c.result = []
              jobs = result["Records"]
              head = result["ParameterNames"]
              headLength = len(head)
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
  @jsonify
  def submit( self ):

    """
    Returns flatten list of components (services, agents) installed on hosts
    returned by getHosts function
    """

    checkUserCredentials()
    DN = getUserDN()
    group = getSelectedGroup()

    callback = list()
    
    request = self.request()
    if not 'Hostname' in request:
      return { "success" : "false" , "error" : "Name of the host is absent" }
    
    host = request[ 'Hostname' ]
    client = SystemAdministratorClient( host , None , delegatedDN=DN ,
                                          delegatedGroup=group )
    result = client.getOverallStatus()
    gLogger.debug( "Result of getOverallStatus(): %s" % result )

    if not result[ "OK" ]:
      return { "success" : "false" , "error" : result[ "Message" ] }
    overall = result[ "Value" ]
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
  @jsonify
  def showHostErrors( self ):

    DN = getUserDN()
    group = getSelectedGroup()
    
    if not "host" in request.params:
      return { "success" : "false" , "error" : "Name of the host is missing or not defined" }
    host = str( request.params[ "host" ] )

    client = SystemAdministratorClient( host , None , delegatedDN=DN , delegatedGroup=group )

    result = client.checkComponentLog( "*" )
    gLogger.debug( result )
    if not result[ "OK" ]:
      return { "success" : "false" , "error" : result[ "Message" ] }
    result = result[ "Value" ]
    
    callback = list()
    for key, value in result.items():
      system, component = key.split( "/" )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
  @jsonify
  def submit(self):
    pagestart = time()
    RPC = getRPCClient("WorkloadManagement/JobMonitoring")
    user = str(credentials.getUsername())
    userDN = str(credentials.getUserDN())
    group = str(credentials.getSelectedGroup())
    result = RPC.getOwners()
    haveJobsToDisplay = False
    if result["OK"]:
      resultEligible = self.__getEligibleOwners( userDN, group )
      if resultEligible['OK']:
        for own in resultEligible['Value']:
          if own in result["Value"]:
            # There is something to display probably
            haveJobsToDisplay = True
            break
        if not haveJobsToDisplay:
          c.result = {"success":"false","error":"You don't have any jobs eligible to display"}
          return c.result
      else:
        c.result = {"success":"false","error":"Failed to evaluate eligible users"}
        return c.result
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
def __getSelectionData(self):
    callback = {}
    group = credentials.getSelectedGroup()
    user = str(credentials.getUsername())
    if len(request.params) > 0:
      tmp = {}
      for i in request.params:
        tmp[i] = str(request.params[i])
      callback["extra"] = tmp
      if callback["extra"].has_key("prod"):
        callback["extra"]["prod"] = callback["extra"]["prod"].zfill(8)
        if callback["extra"]["prod"] == "00000000":
          callback["extra"]["prod"] = ""
      gLogger.info(" - ",callback["extra"])
    if user == "Anonymous":
      callback["prod"] = [["Insufficient rights"]]
    else:
      RPC = getRPCClient("WorkloadManagement/JobMonitoring")
      result = RPC.getProductionIds()
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
def __request(self):
    gLogger.always("!!!  PARAMS: ",str(request.params))
    req = {}
    group = credentials.getSelectedGroup()
    user = str(credentials.getUsername())
    global pageNumber
    global numberOfJobs
    global globalSort
    if request.params.has_key("limit") and len(request.params["limit"]) > 0:
      numberOfJobs = int(request.params["limit"])
      if request.params.has_key("start") and len(request.params["start"]) > 0:
        pageNumber = int(request.params["start"])
      else:
        pageNumber = 0
    else:
      numberOfJobs = 25
      pageNumber = 0
    if request.params.has_key("id") and len(request.params["id"]) > 0:
      testString = str(request.params["id"])
      testString = testString.strip(';, ')
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / diset.py View on Github external
def __prepareArgs( kwargs ):
  if ( 'static' not in kwargs or not kwargs[ 'static' ] ) and credentials.getUserDN():
    kwargs[ 'delegatedGroup' ] =  str( credentials.getSelectedGroup() )
    kwargs[ 'delegatedDN' ] = str( credentials.getUserDN() )
  kwargs[ 'useCertificates' ] = True
  kwargs[ 'setup' ] = credentials.getSelectedSetup()
  return kwargs
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / data / StorageDirectory.py View on Github external
def __request(self):
    req = {}
    lhcbGroup = credentials.getSelectedGroup()
    lhcbUser = str(credentials.getUsername())
    global pageNumber
    global numberOfJobs
    global globalSort
    if request.params.has_key("limit") and len(request.params["limit"]) > 0:
      numberOfJobs = int(request.params["limit"])
      if request.params.has_key("start") and len(request.params["start"]) > 0:
        pageNumber = int(request.params["start"])
      else:
        pageNumber = 0
    else:
      numberOfJobs = 25
      pageNumber = 0
    if request.params.has_key("prod") and len(request.params["prod"]) > 0:
      if str(request.params["prod"]) != "All":
        req["Production"] = str(request.params["prod"])
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / data / StorageDirectory.py View on Github external
def display(self):
    lhcbGroup = credentials.getSelectedGroup()
    if lhcbGroup == "visitor":
      return render("/login.mako")
    c.select = self.__getSelectionData()
    if not c.select.has_key("extra"):
      c.select["extra"] = {}
    userName = credentials.getUsername()
    path = "/lhcb/user/" + userName[0] + "/" + userName
    path = str(path)
    if lhcbGroup == "lhcb":
      c.select["extra"]["dir"] = path
    elif lhcbGroup == "lhcb_user":
      c.select["extra"]["dir"] = path
    else:
      c.select["extra"]["dir"] = "/lhcb/data/2010"
    return render("data/DirectorySummary.mako")
################################################################################
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / data / BK.py View on Github external
def __showFiles(self,request,sortDict,StartItem,MaxItems,mode="Configuration"):
    cl = LHCB_BKKDBClient(getRPCClient('Bookkeeping/BookkeepingManager'))
    lhcbGroup = credentials.getSelectedGroup()
    if lhcbGroup == "visitor":
      c.result = {"success":"false","error":"You are not authorised"}
    else:
      request = {'fullpath':request}
      try:
        cl.setParameter(mode)
        gLogger.info("\033[0;31m cl.getLimitedFiles(%s,%s,%s,%s) \033[0m" % (request,sortDict,StartItem,MaxItems))
        result = cl.getLimitedFiles(request,sortDict,StartItem,MaxItems)
      except:
        return {"success":"false","error":str(sys.exc_info()[1])}
      gLogger.info("\033[0;31m RESULT \033[0m",result)
      if result.has_key("TotalRecords"):
        if result["TotalRecords"] >= 0:
          if result.has_key("ParameterNames") and result.has_key("Records"):
            if len(result["ParameterNames"]) > 0:
              if len(result["Records"]) > 0: