Exemple #1
0
 def processExpirationEmails(self):
     now = _asUTC(datetime.datetime.utcnow())
     self._log.debug("Expiration check: %s" % (str(now)))
     day_alert = []
     week_alert = []
     try:
         slivers = GeniDB.getSliverList(False)
         for sliver in slivers:
             sobj = GeniDB.getSliverObj(sliver["sliver_urn"])
             (urn, action) = sobj.emailCheck(now)
             if action == 1:
                 day_alert.append(urn)
                 self._log.info(
                     "[%s] Sent email for expiry within 30 hours" % (urn))
             elif action == 2:
                 week_alert.append(urn)
                 self._log.info("[%s] Sent email for expiry within 7 days" %
                                (urn))
             else:
                 self._log.debug(
                     "[%s] Expiration check: No email required for sliver expiration (%s)"
                     % (urn, sobj.getExpiration()))
         return jsonify({
             "status": "success",
             "day_alerts": day_alert,
             "week_alerts": week_alert
         })
     except Exception, e:
         self._log.exception("Exception")
         return jsonify(None, code=2, msg=traceback.format_exc())
Exemple #2
0
 def insertSliver (self, slice_urn, obj, rspec, exp):
   urn = obj.generateURN(slice_urn)
   obj.setSliverURN(urn)
   mrspec = self.convertManifestRspec(rspec)
   ins = slivers.insert().values(slice_urn = slice_urn, sliver_urn = urn, fvslicename = str(obj.getUUID()),
             req_rspec = rspec, manifest_rspec = mrspec, parsed_obj = obj, expiration = exp,
             creation = _asUTC(datetime.datetime.utcnow()))
   conn = self.connection()
   conn.execute(ins)
   self.commit()
Exemple #3
0
 def insertSliver(self, slice_urn, obj, rspec, exp):
     urn = obj.generateURN(slice_urn)
     obj.setSliverURN(urn)
     mrspec = self.convertManifestRspec(rspec)
     ins = slivers.insert().values(slice_urn=slice_urn,
                                   sliver_urn=urn,
                                   fvslicename=str(obj.getUUID()),
                                   req_rspec=rspec,
                                   manifest_rspec=mrspec,
                                   parsed_obj=obj,
                                   expiration=exp,
                                   creation=_asUTC(
                                       datetime.datetime.utcnow()))
     conn = self.connection()
     conn.execute(ins)
     self.commit()
Exemple #4
0
  def expireSlivers (self):
    now = _asUTC(datetime.datetime.utcnow())
    exc_stack = []
    expired_slivers = []

    try:
      slivers = GeniDB.getExpiredSliverList(now)
      for sliver in slivers:
        try:
          data = GeniDB.getSliverData(sliver["sliver_urn"], True)

          TokenVerifier.checkToken("expire-sliver", sliver["sliver_urn"])
          foam.geni.lib.deleteSliver(sliver_urn = sliver["sliver_urn"])

          foam.task.emailExpireSliver(data)
          expired_slivers.append(data["sliver_urn"])
        except TokenError, e:
          exc_stack.append(jsonify({"exception" : traceback.format_exc()}))
      return jsonify({"expired" : expired_slivers})
Exemple #5
0
    def expireSlivers(self):
        now = _asUTC(datetime.datetime.utcnow())
        exc_stack = []
        expired_slivers = []

        try:
            slivers = GeniDB.getExpiredSliverList(now)
            for sliver in slivers:
                try:
                    data = GeniDB.getSliverData(sliver["sliver_urn"], True)

                    TokenVerifier.checkToken("expire-sliver",
                                             sliver["sliver_urn"])
                    foam.geni.lib.deleteSliver(sliver_urn=sliver["sliver_urn"])

                    foam.task.emailExpireSliver(data)
                    expired_slivers.append(data["sliver_urn"])
                except TokenError, e:
                    exc_stack.append(
                        jsonify({"exception": traceback.format_exc()}))
            return jsonify({"expired": expired_slivers})
Exemple #6
0
 def processExpirationEmails (self):
   now = _asUTC(datetime.datetime.utcnow())
   self._log.debug("Expiration check: %s" % (str(now)))
   day_alert = []
   week_alert = []
   try:
     slivers = GeniDB.getSliverList(False)
     for sliver in slivers:
       sobj = GeniDB.getSliverObj(sliver["sliver_urn"])
       (urn, action) = sobj.emailCheck(now)
       if action == 1:
         day_alert.append(urn)
         self._log.info("[%s] Sent email for expiry within 30 hours" % (urn))
       elif action == 2:
         week_alert.append(urn)
         self._log.info("[%s] Sent email for expiry within 7 days" % (urn))
       else:
         self._log.debug("[%s] Expiration check: No email required for sliver expiration (%s)" % (urn, sobj.getExpiration()))
     return jsonify({"status" : "success", "day_alerts" : day_alert, "week_alerts" : week_alert})
   except Exception, e:
     self._log.exception("Exception")
     return jsonify(None, code = 2, msg  = traceback.format_exc())
Exemple #7
0
    raise RspecParseError(slice_urn, str(exc))

  of3 = open("/opt/ofelia/ofam/local/schemas/of-resv-3.xsd", "r")
  xsdoc3 = etree.parse(of3)
  xs3 = etree.XMLSchema(xsdoc3)

  try:
    xs3.assertValid(rspec_dom)
  except etree.DocumentInvalid, e:
    flog.exception("XML rspec validation error")
    raise RspecValidationError()

  rspec_elem = rspec_dom.getroot()
  schemas = rspec_elem.get("{%s}schemaLocation" % (XSNS))

  expiration = _asUTC(datetime.datetime.utcnow()) + ConfigDB.getConfigItemByKey("geni.max-lease").getValue()
  for cred in creds:
    credexp = _asUTC(cred.expiration)
    if credexp < expiration:
      expiration = credexp

  GeniDB.refreshDevices()

  sliver = GENISliver(rspec_dom)

  sliver.setUserURN(user_info["urn"])
  sliver.setUserEmail(user_info["email"], overwrite=False)
  sliver.validate()

  GeniDB.insertSliver(slice_urn, sliver, rspec, expiration)
  return sliver
 def __init__(self, exp=None):
     self._uuid = uuid.uuid4()
     self._email = None
     self._description = None
     self._creationTime = _asUTC(datetime.datetime.utcnow())
     self._expireEmailStatus = {"day": False, "week": False}
Exemple #9
0
        raise RspecParseError(slice_urn, str(exc))

    of3 = open("/opt/ofelia/ofam/local/schemas/of-resv-3.xsd", "r")
    xsdoc3 = etree.parse(of3)
    xs3 = etree.XMLSchema(xsdoc3)

    try:
        xs3.assertValid(rspec_dom)
    except etree.DocumentInvalid, e:
        flog.exception("XML rspec validation error")
        raise RspecValidationError()

    rspec_elem = rspec_dom.getroot()
    schemas = rspec_elem.get("{%s}schemaLocation" % (XSNS))

    expiration = _asUTC(datetime.datetime.utcnow(
    )) + ConfigDB.getConfigItemByKey("geni.max-lease").getValue()
    for cred in creds:
        credexp = _asUTC(cred.expiration)
        if credexp < expiration:
            expiration = credexp

    GeniDB.refreshDevices()

    sliver = GENISliver(rspec_dom)

    sliver.setUserURN(user_info["urn"])
    sliver.setUserEmail(user_info["email"], overwrite=False)
    sliver.validate()

    GeniDB.insertSliver(slice_urn, sliver, rspec, expiration)
    return sliver
Exemple #10
0
 def __init__ (self, exp = None):
   self._uuid = uuid.uuid4()
   self._email = None
   self._description = None
   self._creationTime = _asUTC(datetime.datetime.utcnow())
   self._expireEmailStatus = { "day" : False, "week" : False }