Ejemplo n.º 1
0
 def display(self):
     gLogger.info("Running display()")
     msg = "display() for %s@%s" % (getUsername(), getSelectedGroup())
     if not authorizeAction():
         gLogger.info("Result %s: %s" % (msg, "Not authorized"))
         return render("/login.mako")
     result = self.__convert()
     if not result["OK"]:
         c.error = result["Message"]
         gLogger.error("Result %s: %s" % (msg, c.error))
         return render("/error.mako")
     c.select = dict()
     history = dict()
     for i in ["Save", "Load"]:
         result = self.__getHistory(i)
         if not result["OK"]:
             history[i] = result["Message"]
         else:
             history[i] = result["Value"]
     c.select["history"] = history
     result = self.__lastUsed()
     if not result["OK"]:
         c.select["layout"] = ""
         c.select["error"] = result["Message"]
         gLogger.error("Result %s: %s" % (msg, result["Message"]))
         return render("web/Presenter.mako")
     c.select["layout"] = result["Value"]
     gLogger.info("Result %s: %s" % (msg, c.select))
     return render("web/Presenter.mako")
Ejemplo n.º 2
0
 def display(self):
   gLogger.info( "Running display()" )
   msg = "display() for %s@%s" % ( getUsername() , getSelectedGroup() )
   if not authorizeAction():
     gLogger.info( "Result %s: %s" % ( msg , "Not authorized" ) )
     return render( "/login.mako" )
   result = self.__convert()
   if not result[ "OK" ]:
     c.error = result[ "Message" ]
     gLogger.error( "Result %s: %s" % ( msg , c.error ) )
     return render( "/error.mako" )
   c.select = dict()
   history = dict()
   for i in [ "Save" , "Load" ]:
     result = self.__getHistory( i )
     if not result[ "OK" ]:
       history[ i ] = result[ "Message" ]
     else:
       history[ i ] = result[ "Value" ]
   c.select[ "history" ] = history
   result = self.__lastUsed()
   if not result[ "OK" ]:
     c.select[ "layout" ] = ""
     c.select[ "error" ] = result[ "Message" ]
     gLogger.error( "Result %s: %s" % ( msg , result[ "Message" ] ) )
     return render("web/Presenter.mako")
   c.select[ "layout" ] = result[ "Value" ]
   gLogger.info( "Result %s: %s" % ( msg , c.select ) )
   return render("web/Presenter.mako")
Ejemplo n.º 3
0
 def rollbackToVersion(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     try:
         rollbackVersion = str(request.params['rollbackVersion'])
     except Exception, e:
         c.error = "Can't decode params: %s" % e
         return render("/error.mako")
Ejemplo n.º 4
0
 def rollbackToVersion(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     try:
         rollbackVersion = str(request.params["rollbackVersion"])
     except Exception, e:
         c.error = "Can't decode params: %s" % e
         return render("/error.mako")
Ejemplo n.º 5
0
 def showDiff(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     try:
         fromDate = str(request.params['fromVersion'])
         toDate = str(request.params['toVersion'])
     except Exception, e:
         c.error = "Can't decode params: %s" % e
         return render("/error.mako")
Ejemplo n.º 6
0
 def showDiff(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     try:
         fromDate = str(request.params["fromVersion"])
         toDate = str(request.params["toVersion"])
     except Exception, e:
         c.error = "Can't decode params: %s" % e
         return render("/error.mako")
Ejemplo n.º 7
0
 def showCurrentDiff(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     modifier = self.__getModificator()
     modifier.loadFromBuffer(session['cfgData'])
     diffGen = modifier.showCurrentDiff()
     c.titles = ("Server's version", "User's current version")
     c.diffList = self.__generateHTMLDiff(diffGen)
     return render("/systems/configuration/diff.mako")
Ejemplo n.º 8
0
 def showCurrentDiff(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to get diff's!! Bad boy!")
     modifier = self.__getModificator()
     modifier.loadFromBuffer(session["cfgData"])
     diffGen = modifier.showCurrentDiff()
     c.titles = ("Server's version", "User's current version")
     c.diffList = self.__generateHTMLDiff(diffGen)
     return render("/systems/configuration/diff.mako")
Ejemplo n.º 9
0
 def commitConfiguration(self):
     if not authorizeAction():
         return S_ERROR("You are not authorized to commit configurations!! Bad boy!")
     gLogger.always("User %s is commiting a new configuration version" % credentials.getUserDN())
     modifier = self.__getModificator()
     modifier.loadFromBuffer(session["cfgData"])
     retDict = modifier.commit()
     if not retDict["OK"]:
         return S_ERROR(retDict["Message"])
     return S_OK()
Ejemplo n.º 10
0
 def display(self):
   if not authorizeAction():
     return render("/login.mako")
   c.select = dict()
   result = self.__convert()
   if result["OK"]:
     c.select = self.__getData()
   if c.select.has_key("result"):
     c.select = c.select["result"]
   return render("web/Presenter.mako")
Ejemplo n.º 11
0
 def commitConfiguration(self):
     if not authorizeAction():
         return S_ERROR(
             "You are not authorized to commit configurations!! Bad boy!")
     gLogger.always("User %s is commiting a new configuration version" %
                    credentials.getUserDN())
     modifier = self.__getModificator()
     modifier.loadFromBuffer(session['cfgData'])
     retDict = modifier.commit()
     if not retDict['OK']:
         return S_ERROR(retDict['Message'])
     return S_OK()
Ejemplo n.º 12
0
 def showHistory(self):
     if not authorizeAction():
         return render("/error.mako")
     rpcClient = getRPCClient(gConfig.getValue("/DIRAC/Configuration/MasterServer", "Configuration/Server"))
     retVal = rpcClient.getCommitHistory()
     if retVal["OK"]:
         cDict = {"numVersions": 0, "versions": []}
         for entry in retVal["Value"]:
             cDict["numVersions"] += 1
             cDict["versions"].append({"version": entry[1], "commiter": entry[0]})
         c.versions = simplejson.dumps(cDict)
         return render("/systems/configuration/showHistory.mako")
     else:
         c.error = retVal["Message"]
         return render("/error.mako")
Ejemplo n.º 13
0
 def action(self):
   if not authorizeAction():
     return {"success":"false","error":"Insufficient rights"}
   if request.params.has_key("getBookmarks") > 0:
     name = str(request.params["getBookmarks"])
     return self.__getData(name)
   elif request.params.has_key("setBookmarks") and len(request.params["setBookmarks"]) > 0:
     name = str(request.params["setBookmarks"])
     return self.__setData(name)
   elif request.params.has_key("delBookmarks") and len(request.params["delBookmarks"]) > 0:
     name = str(request.params["delBookmarks"])
     return self.__delData(name)
   elif request.params.has_key("delAllBookmarks") and len(request.params["delAllBookmarks"]) > 0:
     return self.__delAllData()
   else:
     return {"success":"false","error":"Action is not defined"}
Ejemplo n.º 14
0
 def __getSelectionData(self):
   callback = {}
   if not authorizeAction():
     return {"success":"false","error":"You are not authorize to access these data"}
   if len(request.params) > 0:
     tmp = {}
     for i in request.params:
       tmp[i] = str(request.params[i])
     callback["extra"] = tmp
   rpcClient = getRPCClient( "Framework/ProxyManager" )
   retVal = rpcClient.getContents( {}, [], 0, 0 )
   if not retVal[ "OK" ]:
     return {"success":"false","error":retVal["Message"]}
   data = retVal[ "Value" ]
   users = []
   groups = []
   for record in data[ "Records" ]:
     users.append( str(record[0]) )
     groups.append( str(record[2]) )
   users = uniqueElements(users)
   groups = uniqueElements(groups)
   users.sort()
   groups.sort()
   users = map(lambda x: [x], users)
   groups = map(lambda x: [x], groups)
   if len(users) > 1:
     users.insert(0,["All"])
   if len(groups) > 1:
     groups.insert(0,["All"])
   callback["username"] = users
   callback["usergroup"] = groups
   result = gConfig.getOption("/Website/ProxyManagementMonitoring/TimeSpan")
   if result["OK"]:
     tmp = result["Value"]
     tmp = tmp.split(", ")
     if len(tmp)>0:
       timespan = []
       for i in tmp:
         human_readable = self.__humanize_time(i)
         timespan.append([i, human_readable])
     else:
       timespan = [["Nothing to display"]]
   else:
     timespan = [["Error during RPC call"]]
   callback["expiredBefore"] = timespan
   callback["expiredAfter"] = timespan
   return callback
Ejemplo n.º 15
0
 def action(self):
     if not authorizeAction():
         return {"success": "false", "error": "Insufficient rights"}
     if request.params.has_key("getAvailbleLayouts"):
         return self.__getLayout()
     if request.params.has_key("getUserLayouts"):
         return self.__getUserLayout()
     elif request.params.has_key("loadLayout"):
         if request.params.has_key("loadLast"):
             return self.__loadLast()
         return self.__loadLayout()
     elif request.params.has_key("saveLayout"):
         return self.__saveLayout()
     elif request.params.has_key("deleteLayout"):
         return self.__deleteLayout()
     else:
         return {"success": "false", "error": "Action is not defined"}
Ejemplo n.º 16
0
 def action(self):
   if not authorizeAction():
     return { "success" : "false" , "error" : "Insufficient rights" }
   if request.params.has_key( "getAvailbleLayouts" ):
     return self.__getLayout()
   if request.params.has_key( "getUserLayouts" ):
     return self.__getUserLayout()
   elif request.params.has_key( "loadLayout" ):
     if request.params.has_key( "loadLast" ):
       return self.__loadLast()
     return self.__loadLayout()
   elif request.params.has_key( "saveLayout" ):
     return self.__saveLayout()
   elif request.params.has_key( "deleteLayout" ):
     return self.__deleteLayout()
   else:
     return {"success":"false","error":"Action is not defined"}
Ejemplo n.º 17
0
 def showHistory(self):
     if not authorizeAction():
         return render("/error.mako")
     rpcClient = getRPCClient(
         gConfig.getValue("/DIRAC/Configuration/MasterServer",
                          "Configuration/Server"))
     retVal = rpcClient.getCommitHistory()
     if retVal['OK']:
         cDict = {'numVersions': 0, 'versions': []}
         for entry in retVal['Value']:
             cDict['numVersions'] += 1
             cDict['versions'].append({
                 'version': entry[1],
                 'commiter': entry[0]
             })
         c.versions = simplejson.dumps(cDict)
         return render("/systems/configuration/showHistory.mako")
     else:
         c.error = retVal['Message']
         return render("/error.mako")
Ejemplo n.º 18
0
 def getProxiesList(self):
   if not authorizeAction():
     return {"success":"false","error":"You are not authorize to access these data"}
   start, limit, sort, req = self.__request()
   rpcClient = getRPCClient( "Framework/ProxyManager" )
   retVal = rpcClient.getContents( req, sort, start, limit )
   gLogger.info("*!*!*!  RESULT: \n%s" % retVal )
   if not retVal[ 'OK' ]:
     return {"success":"false","error":retVal["Message"]}
   svcData = retVal[ 'Value' ]
   proxies = []
   dnMap = {}
   for record in svcData[ 'Records' ]:
     proxies.append( { 'proxyid': "%s@%s" % ( record[1], record[2] ),
                                 'UserName' : str( record[0] ),
                                 'UserDN' : record[1],
                                 'UserGroup' : record[2],
                                 'ExpirationTime' : str( record[3] ),
                                 'PersistentFlag' : str( record[4] ) } )
   timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
   data = {"success":"true","result":proxies,"total":svcData[ 'TotalRecords' ],"date":timestamp}
   return data
Ejemplo n.º 19
0
  def __getSelectionData(self):
    callback = {}
    if not authorizeAction():
      return {"success":"false","error":"Insufficient rights"}
    if len(request.params) > 0:
      tmp = {}
      for i in request.params:
        tmp[i] = str(request.params[i])
      callback["extra"] = tmp
    RPC = getRPCClient("RequestManagement/centralURL")
### R E Q U E S T T Y P E
    result = RPC.getDistinctValues("RequestType")
    gLogger.info("getDistinctValues(RequestType)",result)
    if result["OK"]:
      reqtype = list()
      if len(result["Value"])>0:
#        if len(result["Value"])>3:
#          reqtype.append(["All"])
        reqtype.append(["All"])
        for i in result["Value"]:
          reqtype.append([str(i)])
      else:
        reqtype = [["Nothing to display"]]
    else:
      reqtype = [["Error during RPC call"]]
    callback["requestType"] = reqtype
### O P E R A T I O N
    result = RPC.getDistinctValues("Operation")
    gLogger.info("getDistinctValues(Operation)",result)
    if result["OK"]:
      operation = list()
      if len(result["Value"])>0:
        operation.append(["All"])
        for i in result["Value"]:
          operation.append([str(i)])
      else:
        operation = [["Nothing to display"]]
    else:
      operation = [["Error during RPC call"]]
    callback["operation"] = operation
### U S E R
    result = RPC.getDistinctValues("OwnerDN")
    gLogger.info("getDistinctValues(OwnerDN)",result)
    if result["OK"]:
      owner = [["All"]]
      for i in result["Value"]:
        returnValue = CS.getUsernameForDN(i)
        if not returnValue["OK"]:
          gLogger.info("Error CS.getUsernameForDN(%s): %s" % (i,returnValue["Message"]) )
          nick = i
        else:
          nick = returnValue["Value"]
        owner.append([str(nick)])
      if len(owner) < 2:
        owner = [["Nothing to display"]]
    else:
      owner = [["Error during RPC call"]]
    callback["owner"] = owner
### G R O U P
    result = RPC.getDistinctValues("OwnerGroup")
    gLogger.info("getDistinctValues(OwnerGroup)",result)
    if result["OK"]:
      ownerGroup = list()
      if len(result["Value"])>0:
        ownerGroup.append(["All"])
        for i in result["Value"]:
          ownerGroup.append([str(i)])
      else:
        ownerGroup = [["Nothing to display"]]
    else:
      ownerGroup = [["Error during RPC call"]]
    callback["ownerGroup"] = ownerGroup
### S T A T U S
    result = RPC.getDistinctValues("Status")
    gLogger.info("getDistinctValues(Status)",result)
    if result["OK"]:
      status = list()
      if len(result["Value"])>0:
        status.append(["All"])
        for i in result["Value"]:
          status.append([str(i)])
      else:
        status = [["Nothing to display"]]
    else:
      status = [["Error during RPC call"]]
    callback["status"] = status
    return callback
Ejemplo n.º 20
0
 def showProxyActionLogs(self):
     if not authorizeAction():
         return render("/error.mako")
     return render("/systems/framework/showProxyActionLog.mako")
Ejemplo n.º 21
0
 def showProxyActionLogs(self):
   if not authorizeAction():
     return render( "/error.mako" )
   return render(  "/systems/framework/showProxyActionLog.mako" )
Ejemplo n.º 22
0
 def manageProxies(self):
   if not authorizeAction():
     return render("/login.mako")
   c.select = self.__getSelectionData()
   return render(  "/systems/framework/manageProxies.mako" )