Example #1
0
 def listUserURNs (self):
   try:
     u = ConfigDB.getUser(request.environ["USER"])
     return jsonify(list(ConfigDB.getConfigItemByKey("geni.approval.user-urns").getValue(u)))
   except Exception, e:
     self._log.exception("Exception")
     return jsonify(None, code = 2, msg = traceback.format_exc())
Example #2
0
 def listUserURNs(self):
     try:
         u = ConfigDB.getUser(request.environ["USER"])
         return jsonify(
             list(
                 ConfigDB.getConfigItemByKey(
                     "geni.approval.user-urns").getValue(u)))
     except Exception, e:
         self._log.exception("Exception")
         return jsonify(None, code=2, msg=traceback.format_exc())
Example #3
0
 def removeUserURN (self):
   if not request.json:
     return
   try:
     objs = self.validate(request.json, [("urn", (unicode, str))])
     u = ConfigDB.getUser(request.environ["USER"])
     AppData.removeUserURN(objs["urn"], u)
     return jsonify(None)
   except JSONValidationError, e:
     jd = e.__json__()
     return jsonify(jd, code = 1, msg = jd["exception"])
Example #4
0
 def removeUserURN(self):
     if not request.json:
         return
     try:
         objs = self.validate(request.json, [("urn", (unicode, str))])
         u = ConfigDB.getUser(request.environ["USER"])
         AppData.removeUserURN(objs["urn"], u)
         return jsonify(None)
     except JSONValidationError, e:
         jd = e.__json__()
         return jsonify(jd, code=1, msg=jd["exception"])
Example #5
0
 def createPortGroup (self):
   if not request.json:
     return
   try:
     objs = self.validate(request.json, [("name", (unicode, str)),
                                         ("desc", (unicode, str))])
     u = ConfigDB.getUser(request.environ["USER"])
     pg = AppData.createPortGroup(objs["name"], objs["desc"])
     return jsonify(str(pg.uuid))
   except JSONValidationError, e:
     jd = e.__json__()
     return jsonify(jd, code = 1, msg = jd["exception"])
Example #6
0
 def createPortGroup(self):
     if not request.json:
         return
     try:
         objs = self.validate(request.json, [("name", (unicode, str)),
                                             ("desc", (unicode, str))])
         u = ConfigDB.getUser(request.environ["USER"])
         pg = AppData.createPortGroup(objs["name"], objs["desc"])
         return jsonify(str(pg.uuid))
     except JSONValidationError, e:
         jd = e.__json__()
         return jsonify(jd, code=1, msg=jd["exception"])
Example #7
0
 def setConfig (self):
   if not request.json:
     return
   try:
     objs = self.validate(request.json, [("key", (unicode,str)), ("value", (dict, int, unicode, str))])
     u = ConfigDB.getUser(request.environ["USER"])
     key = request.json["key"]
     ConfigDB.getConfigItemByKey(request.json["key"]).write(request.json["value"], u)
     return jsonify({"status" : "success"})
   except JSONValidationError, e:
     jd = e.__json__()
     return jsonify(jd, code = 1, msg = jd["exception"])
Example #8
0
    def setAdminPasswd(self):
        if not request.json:
            return
        try:
            u = ConfigDB.getUser(request.environ["USER"])
            u.assertPrivilege(self.attrSetAdminPasswd)

            opts = self.validate(request.json, [("passwd", (unicode, str))])

            self._log.info("Updating foamadmin password")
            self._htp.update("foamadmin", opts["passwd"])
            self._htp.save()

            return jsonify(None)
        except JSONValidationError, e:
            jd = e.__json__()
            return jsonify(jd, code=1, msg=jd["exception"])
Example #9
0
    def setAdminPasswd(self):
        if not request.json:
            return
        try:
            u = ConfigDB.getUser(request.environ["USER"])
            u.assertPrivilege(self.attrSetAdminPasswd)

            opts = self.validate(request.json, [("passwd", (unicode, str))])

            self._log.info("Updating foamadmin password")
            self._htp.update("foamadmin", opts["passwd"])
            self._htp.save()

            return jsonify(None)
        except JSONValidationError, e:
            jd = e.__json__()
            return jsonify(jd, code=1, msg=jd["exception"])
Example #10
0
  def getConfig (self):
    if not request.json:
      return

    try:
      objs = self.validate(request.json, [("key", (unicode,str))])
      u = ConfigDB.getUser(request.environ["USER"])
      # Don't look here - stupidity to get around the fact that we don't
      # have output processors
      if objs["key"] == "geni.max-lease":
        val = ConfigDB.getConfigItemByKey("geni.max-lease").getValue(u)
        return jsonify({"value" : str(val)})
      else:
        return jsonify({"value" : ConfigDB.getConfigItemByKey(request.json["key"]).getValue(u)})
    except JSONValidationError, e:
      jd = e.__json__()
      return jsonify(jd, code = 1, msg = jd["exception"])